From 3990a88fd5244f4389577b657dd5ca555246082f Mon Sep 17 00:00:00 2001 From: Nicolas Ayral Seydoux Date: Wed, 15 Jan 2025 10:07:22 +0100 Subject: [PATCH] Fix unit tests --- .../browser/src/login/oidc/ClientRegistrar.spec.ts | 10 ++++++---- packages/browser/src/login/oidc/ClientRegistrar.ts | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/browser/src/login/oidc/ClientRegistrar.spec.ts b/packages/browser/src/login/oidc/ClientRegistrar.spec.ts index bf9f6849c..1f97ce18e 100644 --- a/packages/browser/src/login/oidc/ClientRegistrar.spec.ts +++ b/packages/browser/src/login/oidc/ClientRegistrar.spec.ts @@ -154,7 +154,7 @@ describe("ClientRegistrar", () => { it("retrieves client id and secret from storage if they are present", async () => { const clientId = randomUUID(); const clientSecret = randomUUID(); - const expiresAt = Date.now() + 1000; + const expiresAt = Math.ceil((Date.now() + 100_000) / 1000); const clientRegistrar = getClientRegistrar({ storage: mockStorageUtility( { @@ -188,7 +188,8 @@ describe("ClientRegistrar", () => { const renewedClient: IOpenIdDynamicClient = { clientId: randomUUID(), clientSecret: randomUUID(), - expiresAt: Date.now() + 1000, + // Date.now is in ms, and the expiration date is in seconds. + expiresAt: Math.ceil((Date.now() + 100_000) / 1000), clientType: "dynamic", }; const { registerClient: mockedRegisterClient } = jest.requireMock( @@ -198,7 +199,8 @@ describe("ClientRegistrar", () => { const expiredClient: IOpenIdDynamicClient = { clientId: randomUUID(), clientSecret: randomUUID(), - expiresAt: Date.now() - 1000, + // Date.now is in ms, and the expiration date is in seconds. + expiresAt: Math.ceil((Date.now() - 100_000) / 1000), clientType: "dynamic", }; @@ -278,7 +280,7 @@ describe("ClientRegistrar", () => { const client: IOpenIdDynamicClient = { clientId: randomUUID(), clientSecret: randomUUID(), - expiresAt: Date.now() + 1000, + expiresAt: Math.ceil((Date.now() + 10_000) / 1000), clientType: "dynamic", }; const { registerClient: mockedRegisterClient } = jest.requireMock( diff --git a/packages/browser/src/login/oidc/ClientRegistrar.ts b/packages/browser/src/login/oidc/ClientRegistrar.ts index 047232d24..c6e3a2f63 100644 --- a/packages/browser/src/login/oidc/ClientRegistrar.ts +++ b/packages/browser/src/login/oidc/ClientRegistrar.ts @@ -98,7 +98,6 @@ export default class ClientRegistrar implements IClientRegistrar { } try { - console.log(`Registering a new client`); const registeredClient = await registerClient(options, issuerConfig); // Save info const infoToSave: Record = {