From 1ec50eb1e8fe0655ed6ae771d45af308ad2c9662 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Thu, 16 Dec 2021 09:21:10 +1000 Subject: [PATCH] Add test: do not set keys in new SSO user flow --- spec/common/services/auth.service.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/common/services/auth.service.spec.ts b/spec/common/services/auth.service.spec.ts index ca8b3882..7cee6d58 100644 --- a/spec/common/services/auth.service.spec.ts +++ b/spec/common/services/auth.service.spec.ts @@ -333,7 +333,6 @@ describe('Cipher Service', () => { actual.captchaResponse == null)); // Sets local environment: - // TODO: analyse actual behaviour and update commonSuccessAssertions(); cryptoService.received(1).setEncPrivateKey(privateKey); cryptoService.received(1).setEncKey(encKey); @@ -352,6 +351,22 @@ describe('Cipher Service', () => { expect(result).toEqual(expected); }); + + it('logInSso: do not set keys for new SSO user flow', async () => { + commonSetup(); + const tokenResponse = newTokenResponse(); + tokenResponse.key = null; + + tokenService.getTwoFactorToken(null).resolves(null); + apiService.postIdentityToken(Arg.any()).resolves(tokenResponse); + + const result = await authService.logInSso(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId); + + // Assert + cryptoService.didNotReceive().setEncPrivateKey(privateKey); + cryptoService.didNotReceive().setEncKey(encKey); + }); + it('logInSso: gets and sets KeyConnector key for enrolled user', async () => { commonSetup(); const tokenResponse = newTokenResponse();