Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lambdas/authorizer/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,25 @@

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 () => {

Check failure on line 148 in lambdas/authorizer/src/__tests__/index.test.ts

View workflow job for this annotation

GitHub Actions / Test stage / Linting

Move async arrow function to the outer scope
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", () => {
Expand Down
10 changes: 9 additions & 1 deletion lambdas/authorizer/src/authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ export default function createAuthorizerHandler(
context: Context,
callback: Callback<APIGatewayAuthorizerResult>,
): 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) => {
Expand Down
Loading