From 45bcf354209381d3a59ad6228193c07079d840cc Mon Sep 17 00:00:00 2001 From: Vlasis-Perdikidis Date: Fri, 16 Oct 2026 15:57:47 +0000 Subject: [PATCH 1/3] fix sonarqube error in main --- lambdas/authorizer/src/authorizer.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lambdas/authorizer/src/authorizer.ts b/lambdas/authorizer/src/authorizer.ts index b26ddd253..aca4e03e7 100644 --- a/lambdas/authorizer/src/authorizer.ts +++ b/lambdas/authorizer/src/authorizer.ts @@ -19,7 +19,15 @@ export default function createAuthorizerHandler( context: Context, callback: Callback, ): void => { - checkCertificateExpiry(event.requestContext.identity.clientCert, deps); + checkCertificateExpiry( + event.requestContext.identity.clientCert, + deps, + ).catch((error) => { + deps.logger.error({ + description: "Error checking certificate expiry", + err: error, + }); + }); getSupplier(event.headers, deps) .then((supplier: Supplier) => { From 18d08d25d7802662dcad3e737b258ae06b26b321 Mon Sep 17 00:00:00 2001 From: Vlasis-Perdikidis Date: Fri, 16 Oct 2026 16:11:39 +0000 Subject: [PATCH 2/3] update unit test coverage --- .../authorizer/src/__tests__/index.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lambdas/authorizer/src/__tests__/index.test.ts b/lambdas/authorizer/src/__tests__/index.test.ts index ae8770f46..b10693e72 100644 --- a/lambdas/authorizer/src/__tests__/index.test.ts +++ b/lambdas/authorizer/src/__tests__/index.test.ts @@ -139,6 +139,25 @@ describe("Authorizer Lambda Function", () => { expect(metricScope).not.toHaveBeenCalled(); }); + + it("Should log an error when the certificate expiry check fails", async () => { + mockEvent.requestContext.identity.clientCert = buildCertWithExpiry( + "2025-11-31T14:19:00Z", + ); + const error = new Error("Metrics failure"); + (metricScope as jest.Mock).mockImplementationOnce(() => async () => { + throw error; + }); + + const handler = createAuthorizerHandler(mockedDeps); + handler(mockEvent, mockContext, mockCallback); + await new Promise(process.nextTick); + + expect(mockedDeps.logger.error).toHaveBeenCalledWith({ + description: "Error checking certificate expiry", + err: error, + }); + }); }); describe("Supplier ID lookup", () => { From e77c140a5d2757e66f50e0e378b9b454c8f74788 Mon Sep 17 00:00:00 2001 From: Vlasis-Perdikidis Date: Fri, 16 Oct 2026 16:21:47 +0000 Subject: [PATCH 3/3] fix lint issues --- lambdas/authorizer/src/__tests__/index.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lambdas/authorizer/src/__tests__/index.test.ts b/lambdas/authorizer/src/__tests__/index.test.ts index b10693e72..2b108a6fc 100644 --- a/lambdas/authorizer/src/__tests__/index.test.ts +++ b/lambdas/authorizer/src/__tests__/index.test.ts @@ -145,9 +145,9 @@ describe("Authorizer Lambda Function", () => { "2025-11-31T14:19:00Z", ); const error = new Error("Metrics failure"); - (metricScope as jest.Mock).mockImplementationOnce(() => async () => { - throw error; - }); + (metricScope as jest.Mock).mockImplementationOnce(() => + jest.fn().mockRejectedValue(error), + ); const handler = createAuthorizerHandler(mockedDeps); handler(mockEvent, mockContext, mockCallback);