Skip to content

Commit e84797e

Browse files
committed
CCM-10048: clean up
1 parent 5dd66ee commit e84797e

File tree

11 files changed

+26
-158
lines changed

11 files changed

+26
-158
lines changed

infrastructure/terraform/modules/backend-api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ No requirements.
1616
| <a name="input_csi"></a> [csi](#input\_csi) | CSI from the parent component | `string` | n/a | yes |
1717
| <a name="input_enable_backup"></a> [enable\_backup](#input\_enable\_backup) | Enable Backups for the DynamoDB table? | `bool` | `true` | no |
1818
| <a name="input_enable_event_stream"></a> [enable\_event\_stream](#input\_enable\_event\_stream) | Enable DynamoDB streaming to SQS? | `bool` | `false` | no |
19-
| <a name="input_enable_guardduty"></a> [enable\_guardduty](#input\_enable\_guardduty) | Enable GuardDuty | `bool` | `false` | no |
19+
| <a name="input_enable_guardduty"></a> [enable\_guardduty](#input\_enable\_guardduty) | Enable GuardDuty | `bool` | `true` | no |
2020
| <a name="input_enable_proofing"></a> [enable\_proofing](#input\_enable\_proofing) | Enable proofing feature flag | `bool` | n/a | yes |
2121
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2222
| <a name="input_function_s3_bucket"></a> [function\_s3\_bucket](#input\_function\_s3\_bucket) | Name of S3 bucket to upload lambda artefacts to | `string` | n/a | yes |

infrastructure/terraform/modules/backend-api/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ variable "enable_backup" {
7474
variable "enable_guardduty" {
7575
type = bool
7676
description = "Enable GuardDuty"
77-
default = false
77+
default = true
7878
}
7979

8080
variable "enable_proofing" {

lambdas/backend-api/src/templates/infra/template-repository.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,7 @@ export class TemplateRepository {
500500
);
501501

502502
if (dbResponse.Items?.length !== 1) {
503-
throw new Error(
504-
`Could not identify item by id ${id}. Items found: ${dbResponse.Items?.length || 0}`,
505-
{ cause: dbResponse }
506-
);
503+
throw new Error(`Could not identify item by id ${id}`);
507504
}
508505

509506
return dbResponse.Items[0].owner;

run-e2e.sh

Lines changed: 0 additions & 94 deletions
This file was deleted.

tests/test-team/global.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ declare global {
1313
TEMPLATES_INTERNAL_BUCKET_NAME: string;
1414
TEMPLATES_QUARANTINE_BUCKET_NAME: string;
1515
TEMPLATES_DOWNLOAD_BUCKET_NAME: string;
16-
TEMPLATES_GUARDDUTY_RESOURCE_ARN: string;
1716
}
1817
}
1918

tests/test-team/helpers/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const templateTypeToUrlTextMappings: Record<string, string> = {
1212
LETTER: 'letter',
1313
};
1414

15-
export type TemplateFile = {
15+
export type File = {
1616
fileName: string;
1717
currentVersion: string;
1818
virusScanStatus: string;
@@ -24,9 +24,9 @@ type TypeSpecificProperties = {
2424
letterType?: string;
2525
language?: string;
2626
files?: {
27-
pdfTemplate?: TemplateFile;
28-
testDataCsv?: TemplateFile;
29-
proofs?: Record<string, Pick<TemplateFile, 'fileName' | 'virusScanStatus'>>;
27+
pdfTemplate?: File;
28+
testDataCsv?: File;
29+
proofs?: Record<string, Pick<File, 'fileName' | 'virusScanStatus'>>;
3030
};
3131
personalisationParameters?: string[];
3232
testDataCsvHeaders?: string[];

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-file-validation.e2e.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
assertTestDataGuardDutyEvent,
1414
} from './template-mgmt-letter-guardduty.steps';
1515

16-
test.describe('letter file validation', () => {
16+
// eslint-disable-next-line playwright/no-skipped-test
17+
test.describe.skip('letter file validation', () => {
1718
const templateStorageHelper = new TemplateStorageHelper();
1819
let user: TestUser;
1920

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-full.e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
const lambdaClient = new LambdaClient({ region: 'eu-west-2' });
2222

2323
// eslint-disable-next-line playwright/no-skipped-test
24-
test.describe('letter complete e2e journey', () => {
24+
test.describe.skip('letter complete e2e journey', () => {
2525
const templateStorageHelper = new TemplateStorageHelper();
2626

2727
let user: TestUser;

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-guardduty.steps.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
GuardDutyScanResult,
55
} from '../helpers/eventbridge/eventbridge-helper';
66
import { TemplateStorageHelper } from '../helpers/db/template-storage-helper';
7-
import { Template, TemplateFile } from '../helpers/types';
7+
import { Template, File } from '../helpers/types';
88

99
type EventConfig = {
1010
key: { id: string; owner: string };
@@ -13,8 +13,8 @@ type EventConfig = {
1313

1414
type FileConfig = {
1515
pathPrefix: 'pdf-template' | 'test-data' | 'proofs';
16-
getFile: (template: Template) => TemplateFile | undefined;
17-
getPath: (template: Template, file?: TemplateFile) => string;
16+
getFile: (template: Template) => File | undefined;
17+
getPath: (template: Template, file?: File) => string;
1818
};
1919

2020
const templateStorageHelper = new TemplateStorageHelper();
@@ -33,7 +33,7 @@ function assertGuardDutyEventForFile(
3333

3434
const file = getFile(template);
3535

36-
const path = getPath(template, file);
36+
const path = `${pathPrefix}/${getPath(template, file)}`;
3737

3838
const metadata = await templateStorageHelper.getS3Metadata(
3939
process.env.TEMPLATES_QUARANTINE_BUCKET_NAME,
@@ -60,7 +60,7 @@ export function assertPdfTemplateGuardDutyEvent(props: EventConfig) {
6060
pathPrefix: 'pdf-template',
6161
getFile: (template) => template.files?.pdfTemplate,
6262
getPath: (template, file) =>
63-
`pdf-template/${template.owner}/${template.id}/${file?.currentVersion}.pdf`,
63+
`${template.owner}/${template.id}/${file?.currentVersion}.pdf`,
6464
});
6565
}
6666

@@ -69,7 +69,7 @@ export function assertTestDataGuardDutyEvent(props: EventConfig) {
6969
pathPrefix: 'test-data',
7070
getFile: (template) => template.files?.testDataCsv,
7171
getPath: (template, file) =>
72-
`test-data/${template.owner}/${template.id}/${file?.currentVersion}.csv`,
72+
`${template.owner}/${template.id}/${file?.currentVersion}.csv`,
7373
});
7474
}
7575

@@ -85,6 +85,6 @@ export function assertProofGuardDutyEvent(
8585
return { ...file, currentVersion: 'unknown' };
8686
}
8787
},
88-
getPath: () => `proofs/${props.key.id}/${props.fileName}`,
88+
getPath: () => `${props.key.id}/${props.fileName}`,
8989
});
9090
}

tests/test-team/template-mgmt-e2e-tests/template-mgmt-proofing.e2e.spec.ts

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable sonarjs/no-dead-store */
2-
/* eslint-disable @typescript-eslint/no-unused-vars */
31
import { readFileSync } from 'node:fs';
42
import { expect, test } from '@playwright/test';
53
import {
@@ -11,7 +9,6 @@ import { TemplateStorageHelper } from '../helpers/db/template-storage-helper';
119
import { pdfUploadFixtures } from '../fixtures/pdf-upload/multipart-pdf-letter-fixtures';
1210
import { SftpHelper } from '../helpers/sftp/sftp-helper';
1311
import { InvokeCommand, LambdaClient } from '@aws-sdk/client-lambda';
14-
import { assertProofGuardDutyEvent } from './template-mgmt-letter-guardduty.steps';
1512

1613
const templateStorageHelper = new TemplateStorageHelper();
1714
const authHelper = createAuthHelper();
@@ -70,32 +67,12 @@ test.describe('Letter Proofing', () => {
7067
})
7168
);
7269

73-
const key = {
74-
id: templateId,
75-
owner: user.userId,
76-
};
77-
78-
await assertProofGuardDutyEvent({
79-
key,
80-
scanResult: 'NO_THREATS_FOUND',
81-
fileName: `proof-1.pdf`,
82-
});
83-
84-
await assertProofGuardDutyEvent({
85-
key,
86-
scanResult: 'NO_THREATS_FOUND',
87-
fileName: `proof-2.pdf`,
88-
});
89-
90-
await assertProofGuardDutyEvent({
91-
key,
92-
scanResult: 'NO_THREATS_FOUND',
93-
fileName: `proof-3.pdf`,
94-
});
95-
9670
// check for expected results
9771
await expect(async () => {
98-
const template = await templateStorageHelper.getTemplate(key);
72+
const template = await templateStorageHelper.getTemplate({
73+
owner: user.userId,
74+
id: templateId,
75+
});
9976

10077
expect(template.files?.proofs).toEqual({
10178
'proof-1.pdf': {
@@ -187,19 +164,12 @@ test.describe('Letter Proofing', () => {
187164
})
188165
);
189166

190-
const key = {
191-
owner: user.userId,
192-
id: templateId,
193-
};
194-
195-
await assertProofGuardDutyEvent({
196-
key,
197-
scanResult: 'THREATS_FOUND',
198-
fileName: `proof.pdf`,
199-
});
200-
167+
// check for expected results
201168
await expect(async () => {
202-
const template = await templateStorageHelper.getTemplate(key);
169+
const template = await templateStorageHelper.getTemplate({
170+
owner: user.userId,
171+
id: templateId,
172+
});
203173

204174
expect(template.files?.proofs).toEqual({
205175
'proof.pdf': {

0 commit comments

Comments
 (0)