Skip to content

Commit f4211d9

Browse files
committed
CCM-10387: add api test for proof request shared ownership
1 parent fd89a76 commit f4211d9

File tree

14 files changed

+107
-460
lines changed

14 files changed

+107
-460
lines changed

lambdas/backend-api/src/__tests__/templates/api/process-proof.test.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -77,47 +77,3 @@ test.each([
7777
);
7878
}
7979
);
80-
81-
test('sets virus scan status for a user-owned template', async () => {
82-
const templateRepository = mockDeep<TemplateRepository>({
83-
getOwner: jest
84-
.fn()
85-
.mockReturnValue({ owner: 'user-template-owner', clientOwned: false }),
86-
});
87-
const letterFileRepository = mockDeep<LetterFileRepository>();
88-
89-
const handler = createHandler({
90-
templateRepository,
91-
letterFileRepository,
92-
logger: mockDeep<Logger>(),
93-
});
94-
95-
await handler({
96-
detail: {
97-
s3ObjectDetails: {
98-
objectKey: 'proofs/supplier/template-id/proof.pdf',
99-
versionId: 'version-id',
100-
},
101-
scanResultDetails: { scanResultStatus: 'NO_THREATS_FOUND' },
102-
},
103-
});
104-
105-
expect(templateRepository.getOwner).toHaveBeenCalledWith('template-id');
106-
107-
expect(
108-
letterFileRepository.copyFromQuarantineToInternal
109-
).toHaveBeenCalledWith(
110-
'proofs/supplier/template-id/proof.pdf',
111-
'version-id',
112-
'proofs/user-template-owner/template-id/proof.pdf'
113-
);
114-
115-
expect(
116-
templateRepository.setLetterFileVirusScanStatusForProof
117-
).toHaveBeenCalledWith(
118-
{ owner: 'user-template-owner', id: 'template-id', clientOwned: false },
119-
'proof.pdf',
120-
'PASSED',
121-
'supplier'
122-
);
123-
});

lambdas/backend-api/src/__tests__/templates/app/template-client.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,8 +1890,7 @@ describe('templateClient', () => {
18901890
'en',
18911891
pdfVersionId,
18921892
undefined,
1893-
defaultLetterSupplier,
1894-
false
1893+
defaultLetterSupplier
18951894
);
18961895

18971896
expect(result).toEqual({
@@ -1966,8 +1965,7 @@ describe('templateClient', () => {
19661965
'en',
19671966
pdfVersionId,
19681967
undefined,
1969-
defaultLetterSupplier,
1970-
false
1968+
defaultLetterSupplier
19711969
);
19721970

19731971
expect(result).toEqual({

lambdas/backend-api/src/templates/api/process-proof.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ export const createHandler =
2525
const { templateId, fileName, supplier } =
2626
LetterProofRepository.parseQuarantineKey(objectKey);
2727

28-
const { owner, clientOwned } =
29-
await templateRepository.getOwner(templateId);
28+
const { owner } = await templateRepository.getOwner(templateId);
3029

3130
const internalKey = LetterProofRepository.getInternalKey(
3231
owner,
@@ -63,7 +62,7 @@ export const createHandler =
6362
}
6463

6564
await templateRepository.setLetterFileVirusScanStatusForProof(
66-
{ owner, id: templateId, clientOwned },
65+
{ owner, id: templateId, clientOwned: true },
6766
fileName,
6867
virusScanResult,
6968
supplier

lambdas/backend-api/src/templates/app/template-client.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,9 @@ export class TemplateClient {
449449
language,
450450
letterType,
451451
name,
452-
owner,
453452
personalisationParameters,
454453
} = proofLetterValidationResult.data;
455454

456-
const clientOwned = owner?.startsWith('CLIENT#') || false;
457-
458455
const pdfVersionId = files.pdfTemplate.currentVersion;
459456
const testDataVersionId = files.testDataCsv?.currentVersion;
460457

@@ -468,8 +465,7 @@ export class TemplateClient {
468465
language,
469466
pdfVersionId,
470467
testDataVersionId,
471-
this.defaultLetterSupplier,
472-
clientOwned
468+
this.defaultLetterSupplier
473469
);
474470

475471
if (sendQueueResult.error) {

lambdas/backend-api/src/templates/infra/proofing-queue.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ export class ProofingQueue {
2323
language: Language,
2424
pdfVersionId: string,
2525
testDataVersionId: string | undefined,
26-
supplier: string,
27-
clientOwned: boolean
26+
supplier: string
2827
) {
2928
try {
3029
const response = await this.sqsClient.send(
3130
new SendMessageCommand({
3231
QueueUrl: this.queueUrl,
3332
MessageBody: JSON.stringify({
3433
campaignId,
35-
clientOwned,
3634
language,
3735
letterType,
3836
pdfVersionId,

0 commit comments

Comments
 (0)