Skip to content

Commit

Permalink
fix: assign Discovery 1.0 defaults when discovering with .well-known
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Oct 10, 2018
1 parent 8ac18d1 commit 74b593e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/issuer.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Issuer {
if (parsed.pathname.includes('/.well-known/')) {
return this.httpClient.get(uri, this.httpOptions())
.then(expectResponseWithBody(200))
.then(response => new this(JSON.parse(response.body)))
.then(response => new this(Object.assign({}, ISSUER_DEFAULTS, JSON.parse(response.body))))
.catch(errorHandler.bind(this));
}

Expand Down
26 changes: 25 additions & 1 deletion test/issuer/discover_issuer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,31 @@ const fail = () => { throw new Error('expected promise to be rejected'); };
});
});

it('assigns Discovery 1.0 defaults', function () {
it('assigns Discovery 1.0 defaults 1/2', function () {
nock('https://op.example.com', { allowUnmocked: true })
.get('/.well-known/openid-configuration')
.reply(200, {
authorization_endpoint: 'https://op.example.com/o/oauth2/v2/auth',
issuer: 'https://op.example.com',
jwks_uri: 'https://op.example.com/oauth2/v3/certs',
token_endpoint: 'https://op.example.com/oauth2/v4/token',
userinfo_endpoint: 'https://op.example.com/oauth2/v3/userinfo',
});

return Issuer.discover('https://op.example.com/.well-known/openid-configuration')
.then((issuer) => {
expect(issuer).to.have.property('claims_parameter_supported', false);
expect(issuer).to.have.property('grant_types_supported').to.eql(['authorization_code', 'implicit']);
expect(issuer).to.have.property('request_parameter_supported', false);
expect(issuer).to.have.property('request_uri_parameter_supported', true);
expect(issuer).to.have.property('require_request_uri_registration', false);
expect(issuer).to.have.property('response_modes_supported').to.eql(['query', 'fragment']);
expect(issuer).to.have.property('claim_types_supported').to.eql(['normal']);
expect(issuer).to.have.property('token_endpoint_auth_methods_supported').to.eql(['client_secret_basic']);
});
});

it('assigns Discovery 1.0 defaults 2/2', function () {
nock('https://op.example.com', { allowUnmocked: true })
.get('/.well-known/openid-configuration')
.reply(200, {
Expand Down

0 comments on commit 74b593e

Please sign in to comment.