diff --git a/src/org.ts b/src/org.ts index e48f8fbc82..791911845e 100644 --- a/src/org.ts +++ b/src/org.ts @@ -379,7 +379,7 @@ export class Org extends AsyncCreatable { * @param {value} The value to save */ public async setSandboxOrgConfigField(field: SandboxOrgConfig.Fields, value: string): Promise { - const sandboxOrgConfig: SandboxOrgConfig = await this.retrieveSandboxOrgConfig(); + const sandboxOrgConfig = await this.retrieveSandboxOrgConfig(); sandboxOrgConfig.set(field, value); await sandboxOrgConfig.write(); return this; @@ -449,25 +449,6 @@ export class Org extends AsyncCreatable { return this.connection; } - /** - * Returns a promise to delete an auth info file from the local file system and any related cache information for - * this Org.. You don't want to call this method directly. Instead consider calling Org.remove() - */ - public async removeAuth(): Promise { - const username = ensure(this.getUsername()); - this.logger.debug(`Removing auth for user: ${username}`); - const config = await AuthInfoConfig.create({ - ...AuthInfoConfig.getOptions(username), - throwOnNotFound: false - }); - - this.logger.debug(`Clearing auth cache for user: ${username}`); - AuthInfo.clearCache(username); - if (await config.exists()) { - await config.unlink(); - } - } - /** * Initialize async components. */ @@ -504,6 +485,25 @@ export class Org extends AsyncCreatable { throw new SfdxError('Not Supported'); } + /** + * Returns a promise to delete an auth info file from the local file system and any related cache information for + * this Org.. You don't want to call this method directly. Instead consider calling Org.remove() + */ + private async removeAuth(): Promise { + const username = ensure(this.getUsername()); + this.logger.debug(`Removing auth for user: ${username}`); + const config = await AuthInfoConfig.create({ + ...AuthInfoConfig.getOptions(username), + throwOnNotFound: false + }); + + this.logger.debug(`Clearing auth cache for user: ${username}`); + AuthInfo.clearCache(username); + if (await config.exists()) { + await config.unlink(); + } + } + /** * Deletes the users config file */ diff --git a/test/unit/orgTest.ts b/test/unit/orgTest.ts index 13875f366a..b484aab00d 100644 --- a/test/unit/orgTest.ts +++ b/test/unit/orgTest.ts @@ -729,6 +729,15 @@ describe('Org Tests', () => { describe('sandbox org config', () => { it('set field', async () => { + const org: Org = await Org.create({ aliasOrUsername: testData.username }); + expect(await org.getSandboxOrgConfigField(SandboxOrgConfig.Fields.PROD_ORG_USERNAME)).to.be.undefined; + + await org.setSandboxOrgConfigField(SandboxOrgConfig.Fields.PROD_ORG_USERNAME, 'user@sandbox.org'); + + expect(await org.getSandboxOrgConfigField(SandboxOrgConfig.Fields.PROD_ORG_USERNAME)).to.eq('user@sandbox.org'); + }); + + it('Test sandbox config removal.', async () => { // Stub exists so only the auth file and sandbox config file exist. No users config file. stubMethod($$.SANDBOX, ConfigFile.prototype, 'exists').callsFake(async function() { if (this.path && this.path.endsWith(`${testData.orgId}.json`)) {