diff --git a/packages/node/src/login/oidc/ClientRegistrar.spec.ts b/packages/node/src/login/oidc/ClientRegistrar.spec.ts index 143a8c5ec8..826523a0c8 100644 --- a/packages/node/src/login/oidc/ClientRegistrar.spec.ts +++ b/packages/node/src/login/oidc/ClientRegistrar.spec.ts @@ -148,6 +148,46 @@ describe("ClientRegistrar", () => { expect(mockedIssuer.Client.register).toHaveBeenCalled(); }); + it("registers a new client if the one in storage has no expiry stored", async () => { + const { Issuer } = jest.requireMock("openid-client") as any; + const mockedIssuer = { + metadata: mockDefaultIssuerMetadata(), + Client: { + register: (jest.fn() as any).mockResolvedValueOnce({ + metadata: mockDefaultClientConfig(), + }), + }, + }; + Issuer.mockReturnValue(mockedIssuer); + + const clientRegistrar = getClientRegistrar({ + storage: mockStorageUtility( + { + "solidClientAuthenticationUser:mySession": { + clientId: "an id", + clientSecret: "a secret", + // Note: no clientExpiresAt has been stored + clientName: "my client name", + idTokenSignedResponseAlg: "ES256", + }, + }, + false + ), + }); + + const client = await clientRegistrar.getClient( + { + sessionId: "mySession", + redirectUrl: "https://example.com", + }, + { + ...IssuerConfigFetcherFetchConfigResponse, + } + ); + + expect(mockedIssuer.Client.register).toHaveBeenCalled(); + }); + it("negotiates signing alg if not found in storage", async () => { const clientRegistrar = getClientRegistrar({ storage: mockStorageUtility(