-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return all info from AuthInfo.listAllAuthorizations (#449)
* fix: return all info from AuthInfo.listAllAuthorizations * chore: code review * chore: code review * chore: code review
- Loading branch information
1 parent
6514ad4
commit 17e60ea
Showing
6 changed files
with
90 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import { testSetup } from '../../../../src/testSetup'; | |
describe('OrgAccessor', () => { | ||
const username = '[email protected]'; | ||
const alias = 'MyAlias'; | ||
const org = { username, orgId: '12345', alias }; | ||
const org = { username, orgId: '12345', aliases: [alias] }; | ||
const token = { token: '123', url: 'https://login.salesforce.com', user: username }; | ||
const $$ = testSetup(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1806,7 +1806,6 @@ describe('AuthInfo', () => { | |
describe('listAllAuthorizations', () => { | ||
describe('with no AuthInfo.create errors', () => { | ||
const username = '[email protected]'; | ||
let timestamp; | ||
|
||
beforeEach(async () => { | ||
stubMethod($$.SANDBOX, ConfigAggregator.prototype, 'loadProperties').callsFake(async () => {}); | ||
|
@@ -1843,21 +1842,21 @@ describe('AuthInfo', () => { | |
authCode: testMetadata.authCode, | ||
}, | ||
}); | ||
timestamp = (await GlobalInfo.getInstance()).orgs.get(username).timestamp; | ||
stubMethod($$.SANDBOX, AuthInfo, 'create').withArgs({ username }).returns(Promise.resolve(authInfo)); | ||
}); | ||
|
||
it('should return list of authorizations with web oauthMethod', async () => { | ||
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: undefined, | ||
aliases: [], | ||
configs: [], | ||
isScratchOrg: false, | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: 'authInfoTest_access_token', | ||
oauthMethod: 'web', | ||
timestamp, | ||
}, | ||
]); | ||
}); | ||
|
@@ -1867,13 +1866,14 @@ describe('AuthInfo', () => { | |
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: undefined, | ||
aliases: [], | ||
configs: [], | ||
isScratchOrg: false, | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: 'authInfoTest_access_token', | ||
oauthMethod: 'jwt', | ||
timestamp, | ||
}, | ||
]); | ||
}); | ||
|
@@ -1884,29 +1884,58 @@ describe('AuthInfo', () => { | |
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: undefined, | ||
aliases: [], | ||
configs: [], | ||
isScratchOrg: false, | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: 'authInfoTest_access_token', | ||
oauthMethod: 'token', | ||
timestamp, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should return list of authorizations with alias', async () => { | ||
stubMethod($$.SANDBOX, AliasAccessor.prototype, 'get').returns('MyAlias'); | ||
it('should return list of authorizations with aliases', async () => { | ||
stubMethod($$.SANDBOX, AliasAccessor.prototype, 'getAll').returns(['MyAlias']); | ||
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: 'MyAlias', | ||
aliases: ['MyAlias'], | ||
configs: [], | ||
isScratchOrg: false, | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: 'authInfoTest_access_token', | ||
oauthMethod: 'web', | ||
}, | ||
]); | ||
}); | ||
|
||
it('should return list of authorizations with configs', async () => { | ||
stubMethod($$.SANDBOX, AliasAccessor.prototype, 'getAll').returns(['MyAlias']); | ||
stubMethod($$.SANDBOX, ConfigAggregator.prototype, 'getConfigInfo').returns([ | ||
{ | ||
value: 'MyAlias', | ||
key: OrgConfigProperties.TARGET_ORG, | ||
}, | ||
{ | ||
value: username, | ||
key: OrgConfigProperties.TARGET_DEV_HUB, | ||
}, | ||
]); | ||
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
aliases: ['MyAlias'], | ||
configs: [OrgConfigProperties.TARGET_ORG, OrgConfigProperties.TARGET_DEV_HUB], | ||
isScratchOrg: false, | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: 'authInfoTest_access_token', | ||
oauthMethod: 'web', | ||
timestamp, | ||
}, | ||
]); | ||
}); | ||
|
@@ -1934,31 +1963,31 @@ describe('AuthInfo', () => { | |
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: undefined, | ||
aliases: [], | ||
configs: [], | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: undefined, | ||
oauthMethod: 'unknown', | ||
error: 'FAIL!', | ||
timestamp: undefined, | ||
}, | ||
]); | ||
}); | ||
|
||
it('should return list of authorizations with unknown oauthMethod and alias', async () => { | ||
stubMethod($$.SANDBOX, AliasAccessor.prototype, 'get').returns('MyAlias'); | ||
stubMethod($$.SANDBOX, AliasAccessor.prototype, 'getAll').returns(['MyAlias']); | ||
const auths = await AuthInfo.listAllAuthorizations(); | ||
expect(auths).to.deep.equal([ | ||
{ | ||
alias: 'MyAlias', | ||
aliases: ['MyAlias'], | ||
configs: [], | ||
username: '[email protected]', | ||
orgId: '00DAuthInfoTest_orgId', | ||
instanceUrl: 'http://mydevhub.localhost.internal.salesforce.com:6109', | ||
accessToken: undefined, | ||
oauthMethod: 'unknown', | ||
error: 'FAIL!', | ||
timestamp: undefined, | ||
}, | ||
]); | ||
}); | ||
|