Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Bug fix, test update (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
gratcliff authored and erunion committed Aug 5, 2019
1 parent db7c3eb commit b248b04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/api-explorer/__tests__/lib/get-auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ it('should return apiKey property for apiKey', () => {
expect(getSingle(topLevelUser, { type: 'oauth2' })).toBe('123456');
});

it('should return a default value if scheme is sec0 and default auth provided', () => {
expect(getSingle({}, { type: 'apiKey', _key: 'sec0', 'x-default': 'default' })).toBe('default');
});

it('should return apiKey property for bearer', () => {
expect(getSingle(topLevelUser, { type: 'http', scheme: 'bearer' })).toBe('123456');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/api-explorer/src/lib/get-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function getKey(user, scheme) {
switch (scheme.type) {
case 'oauth2':
case 'apiKey':
return user[scheme._key] || user.apiKey || '';
return user[scheme._key] || user.apiKey || scheme['x-default'] || '';
case 'http':
if (scheme.scheme === 'basic') {
return user[scheme._key] || { user: user.user || '', pass: user.pass || '' };
Expand Down

0 comments on commit b248b04

Please sign in to comment.