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

Commit b248b04

Browse files
gratclifferunion
authored andcommitted
Bug fix, test update (#251)
1 parent db7c3eb commit b248b04

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/api-explorer/__tests__/lib/get-auth.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ it('should return apiKey property for apiKey', () => {
5656
expect(getSingle(topLevelUser, { type: 'oauth2' })).toBe('123456');
5757
});
5858

59+
it('should return a default value if scheme is sec0 and default auth provided', () => {
60+
expect(getSingle({}, { type: 'apiKey', _key: 'sec0', 'x-default': 'default' })).toBe('default');
61+
});
62+
5963
it('should return apiKey property for bearer', () => {
6064
expect(getSingle(topLevelUser, { type: 'http', scheme: 'bearer' })).toBe('123456');
6165
});

packages/api-explorer/src/lib/get-auth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ function getKey(user, scheme) {
22
switch (scheme.type) {
33
case 'oauth2':
44
case 'apiKey':
5-
return user[scheme._key] || user.apiKey || '';
5+
return user[scheme._key] || user.apiKey || scheme['x-default'] || '';
66
case 'http':
77
if (scheme.scheme === 'basic') {
88
return user[scheme._key] || { user: user.user || '', pass: user.pass || '' };

0 commit comments

Comments
 (0)