Skip to content

Commit

Permalink
feat(EMS-3490): no pdf - application submission - xlsx - protect from…
Browse files Browse the repository at this point in the history
… modification (#2584)
  • Loading branch information
ttbarnes authored Jun 18, 2024
1 parent 61c51a1 commit c6ef02d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 11 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ API_KEY=
SESSION_SECRET=
JWT_SIGNING_KEY=
MOCK_ACCOUNT_PASSWORD=
EXCELJS_PROTECTION_PASSWORD=

# UI
UI_PORT=
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ jobs:
COMPANIES_HOUSE_API_KEY='${{ secrets.COMPANIES_HOUSE_API_KEY }}' \
JWT_SIGNING_KEY='${{ secrets.JWT_SIGNING_KEY }}' \
UNDERWRITING_TEAM_EMAIL='${{ secrets.UNDERWRITING_TEAM_EMAIL }}' \
FEEDBACK_EMAIL_RECIPIENT='${{ secrets.FEEDBACK_EMAIL_RECIPIENT }}'
FEEDBACK_EMAIL_RECIPIENT='${{ secrets.FEEDBACK_EMAIL_RECIPIENT }}' \
EXCELJS_PROTECTION_PASSWORD='${{ secrets.EXCELJS_PROTECTION_PASSWORD }}'
- name: Slot 🔀
uses: azure/cli@v2.0.0
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ env:
FEEDBACK_EMAIL_RECIPIENT: ${{ secrets.FEEDBACK_EMAIL_RECIPIENT }}
MOCK_ACCOUNT_PASSWORD: ${{ secrets.MOCK_ACCOUNT_PASSWORD }}
JWT_SIGNING_KEY: ${{ secrets.JWT_SIGNING_KEY }}
EXCELJS_PROTECTION_PASSWORD: ${{ secrets.EXCELJS_PROTECTION_PASSWORD }}

jobs:
# 1. Setup test infrastructure
Expand Down
3 changes: 2 additions & 1 deletion src/api/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ API_KEY=
SESSION_SECRET=
JWT_SIGNING_KEY=
MOCK_ACCOUNT_PASSWORD=
EXCELJS_PROTECTION_PASSWORD=

# APIM
APIM_MDM_URL=
Expand Down Expand Up @@ -46,4 +47,4 @@ LOSS_PAYEE_ENCRYPTION_KEY=
CRON_SCHEDULE_UNVERIFIED_ACCOUNT=
CRON_SCHEDULE_INACTIVE_APPLICATION=
CRON_SCHEDULE_SUBMISSION_DEADLINE_REMINDER_EMAIL=
APPLICATION_URL=
APPLICATION_URL=
20 changes: 12 additions & 8 deletions src/api/.keystone/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/api/generate-xlsx/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ describe('api/generate-xlsx/index', () => {

expect(result).toEqual(expected);

// delete the file so we don't create a file during unit tests.
/**
* delete the file,
* so that we don't create a file during unit tests.
*/

await fileSystem.unlink(expected);
});
Expand Down
8 changes: 8 additions & 0 deletions src/api/generate-xlsx/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import dotenv from 'dotenv';
import ExcelJS from 'exceljs';
import mapApplicationToXLSX from './map-application-to-XLSX';
import HEADER_COLUMNS from './header-columns';
import styledColumns from './styled-columns';
import { Application } from '../types';

dotenv.config();

const { EXCELJS_PROTECTION_PASSWORD } = process.env;

/**
* XLSX
* Generate an XLSX file with exceljs
Expand Down Expand Up @@ -33,6 +38,9 @@ const XLSX = (application: Application): Promise<string> => {

let worksheet = workbook.addWorksheet(refNumber);

// protect the worksheet from modification
worksheet.protect(String(EXCELJS_PROTECTION_PASSWORD), {});

// add header columns to the worksheet
worksheet.columns = HEADER_COLUMNS;

Expand Down

0 comments on commit c6ef02d

Please sign in to comment.