Loading src/services/account_service.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ describe('AccountService', () => { await accountService.removeAccount(account.id); expect(accountService.getAllAccounts()).toHaveLength(0); expect(await secrets.get('gitlab-tokens')).toBe('{}'); }); describe('account from environment variable', () => { Loading src/services/account_service.ts +14 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ export class AccountService { this.onDidChangeEmitter.fire(); } async #storeToken(accountId: string, token: string) { async #validateSecretsAreUpToDate() { assert(this.context); const storedSecrets = await getSecrets(this.context); assert.deepStrictEqual( Loading @@ -118,6 +118,18 @@ export class AccountService { storedSecrets, 'The GitLab secrets stored in your keychain have changed. (Maybe another instance of VS Code or maybe OS synchronizing keychains.) Please restart VS Code.', ); } async #removeToken(accountId: string) { assert(this.context); await this.#validateSecretsAreUpToDate(); delete this.secrets[accountId]; await this.context.secrets.store(SECRETS_KEY, JSON.stringify(this.secrets)); } async #storeToken(accountId: string, token: string) { assert(this.context); await this.#validateSecretsAreUpToDate(); const secrets = { ...this.secrets, [accountId]: { token } }; await this.context.secrets.store(SECRETS_KEY, JSON.stringify(secrets)); this.secrets = secrets; Loading @@ -129,6 +141,7 @@ export class AccountService { delete accountMap[accountId]; await this.context.globalState.update(ACCOUNTS_KEY, accountMap); await this.#removeToken(accountId); this.onDidChangeEmitter.fire(); } Loading Loading
src/services/account_service.test.ts +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ describe('AccountService', () => { await accountService.removeAccount(account.id); expect(accountService.getAllAccounts()).toHaveLength(0); expect(await secrets.get('gitlab-tokens')).toBe('{}'); }); describe('account from environment variable', () => { Loading
src/services/account_service.ts +14 −1 Original line number Diff line number Diff line Loading @@ -110,7 +110,7 @@ export class AccountService { this.onDidChangeEmitter.fire(); } async #storeToken(accountId: string, token: string) { async #validateSecretsAreUpToDate() { assert(this.context); const storedSecrets = await getSecrets(this.context); assert.deepStrictEqual( Loading @@ -118,6 +118,18 @@ export class AccountService { storedSecrets, 'The GitLab secrets stored in your keychain have changed. (Maybe another instance of VS Code or maybe OS synchronizing keychains.) Please restart VS Code.', ); } async #removeToken(accountId: string) { assert(this.context); await this.#validateSecretsAreUpToDate(); delete this.secrets[accountId]; await this.context.secrets.store(SECRETS_KEY, JSON.stringify(this.secrets)); } async #storeToken(accountId: string, token: string) { assert(this.context); await this.#validateSecretsAreUpToDate(); const secrets = { ...this.secrets, [accountId]: { token } }; await this.context.secrets.store(SECRETS_KEY, JSON.stringify(secrets)); this.secrets = secrets; Loading @@ -129,6 +141,7 @@ export class AccountService { delete accountMap[accountId]; await this.context.globalState.update(ACCOUNTS_KEY, accountMap); await this.#removeToken(accountId); this.onDidChangeEmitter.fire(); } Loading