Skip to content

Commit 92a2e66

Browse files
committed
CCM-10048: refactor s3 path options for proofs folder
1 parent 4d554a9 commit 92a2e66

File tree

4 files changed

+152
-147
lines changed

4 files changed

+152
-147
lines changed

tests/test-team/helpers/use-cases/simulate-guard-duty-scan.ts

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import { S3Helper } from '../s3/s3-helper';
77
type TemplateKey = { owner: string; id: string };
88

99
type S3GuardDutyEvent = {
10-
key: TemplateKey;
1110
type: GuardDutyScanResult;
12-
fileName?: string;
13-
fileType: 'csv' | 'pdf';
11+
path: string;
1412
};
1513

1614
export class SimulateGuardDutyScan {
@@ -23,43 +21,33 @@ export class SimulateGuardDutyScan {
2321
}
2422

2523
async publish(event: S3GuardDutyEvent): Promise<boolean> {
26-
if (!event.fileName) {
27-
throw new Error('No file name', {
28-
cause: event,
29-
});
30-
}
31-
32-
const s3FilePath = this.s3ObjectPath(
33-
event.key,
34-
event.fileName,
35-
event.fileType
36-
);
37-
3824
const s3VersionId = await this.#s3Helper.getVersionId(
3925
process.env.TEMPLATES_QUARANTINE_BUCKET_NAME,
40-
s3FilePath
26+
event.path
4127
);
4228

4329
if (!s3VersionId) {
44-
throw new Error(`Unable to get S3 versionId for ${s3FilePath}`);
30+
throw new Error(`Unable to get S3 versionId for ${event.path}`);
4531
}
4632

4733
this.#eventBridgeHelper.publishGuardDutyEvent(
48-
s3FilePath,
34+
event.path,
4935
s3VersionId,
5036
event.type
5137
);
5238

5339
return true;
5440
}
5541

56-
private s3ObjectPath(
57-
key: TemplateKey,
58-
fileName: string,
59-
fileType: 'pdf' | 'csv'
60-
) {
61-
const parentFolder = fileType === 'pdf' ? 'pdf-template' : 'test-data';
42+
static testDataPath(key: TemplateKey, fileName?: string): string {
43+
return `test-data/${key.owner}/${key.id}/${fileName}.csv`;
44+
}
45+
46+
static pdfTemplatePath(key: TemplateKey, fileName?: string): string {
47+
return `pdf-template/${key.owner}/${key.id}/${fileName}.pdf`;
48+
}
6249

63-
return `${parentFolder}/${key.owner}/${key.id}/${fileName}.${fileType}`;
50+
static proofsPath(key: TemplateKey, fileName: string): string {
51+
return `proofs/${key.id}/${fileName}.pdf`;
6452
}
6553
}

0 commit comments

Comments
 (0)