Skip to content

Commit

Permalink
fix: ignore sector_identifier_uri when subject_type is not pairwise
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Sep 30, 2018
1 parent 3a01a6f commit 416e379
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/helpers/client_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ module.exports = function getSchema(provider) {
}
}

if (this.sector_identifier_uri !== undefined && this.subject_type !== 'pairwise') {
this.sector_identifier_uri = undefined;
}

// SECTOR IDENTIFIER VALIDATION
sectorIdentifier({
subjectType: this.subject_type,
Expand Down
15 changes: 13 additions & 2 deletions test/pairwise/pairwise_clients.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ describe('pairwise features', () => {
});

context('sector_identifier_uri is provided', () => {
it('is ignored unless pairwise subject_type is used', function () {
return i(this.provider).clientAdd({
client_id: 'client',
client_secret: 'secret',
redirect_uris: ['https://client.example.com/cb', 'https://another.example.com/forum/cb'],
sector_identifier_uri: 'https://foobar.example.com/file_of_redirect_uris',
subject_type: 'public',
}).then((client) => {
expect(client).to.be.ok;
expect(client.sectorIdentifier).to.eq(undefined);
});
});

it('validates the sector from the provided uri', function () {
nock('https://foobar.example.com')
.get('/file_of_redirect_uris')
Expand All @@ -85,8 +98,6 @@ describe('pairwise features', () => {
}).then((client) => {
expect(client).to.be.ok;
expect(client.sectorIdentifier).to.eq('foobar.example.com');
}, (err) => {
expect(err).not.to.be.ok;
});
});

Expand Down

0 comments on commit 416e379

Please sign in to comment.