Skip to content

Commit

Permalink
F^ add test for missing clientExpiresAt in storage
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsMissEm committed Apr 30, 2022
1 parent dead2c9 commit c153424
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/node/src/login/oidc/ClientRegistrar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit c153424

Please sign in to comment.