levino/mock-jwks

jwks-rsa upgrade is causing mock to fail?

avenmia opened this issue · 5 comments

jwks-rsa is up to version 2.0.0 and includes some breaking changes. This includes supporting async await over callbacks, which may be breaking the library.

https://github.com/auth0/node-jwks-rsa/releases/tag/v2.0.0

When I tried to bump my version of jwks-rsa to 2.0.0 my mock-jwks unit tests fail with the following error:

JwksError: The JWKS endpoint did not contain any signing keys

at JwksClient.getSigningKeys (node_modules/jwks-rsa/src/JwksClient.js:63:13)
at JwksClient.getSigningKey (node_modules/jwks-rsa/src/JwksClient.js:72:18) 

Here is my unit test. I'm setting it up using mock-jwks and nock.

import * as nock from "nock";
import createJWKSMock from "mock-jwks";

const jwks = createJWKSMock(config.authEndpoint);

beforeEach(() => 
{
    jwks.start();
});

afterEach(() => {jwks.stop(); jest.resetAllMocks();});


afterEach(() => { jest.resetAllMocks(); });



test("Given a JWT this function verifies whether whether the token is correct", async () => 
{
    nock(config.authEndpoint).get('/.well-known/jwks.json').reply(
        200,
        {}
    );
    const testToken = jwks.token({test: "test"});
    const result = await verifyJWT(testToken);
    expect(result).toEqual({test: "test"});
});

This error is getting thrown by the jose library. I think the fix could be to change the x5c property in createJWKS?

image

Changing alg from 'RSA256' to 'RS256' as noted here:

#33

gave the following error when running the unit tests:

image

Could you please make a PR with a failing test?

Superseded by #38