1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-22 03:03:15 +00:00

Add test for captcha

This commit is contained in:
Thomas Rittson
2021-12-15 11:10:15 +10:00
parent 5e8cc522fb
commit 6e34585dfd

View File

@@ -136,7 +136,7 @@ describe('Cipher Service', () => {
return tokenResponse;
}
it('logIn method: simple call: no 2FA, captcha or password reset', async () => {
it('logIn: simple call: no 2FA, captcha or password reset', async () => {
logInSetup();
commonSetup();
const tokenResponse = newTokenResponse();
@@ -180,4 +180,28 @@ describe('Cipher Service', () => {
// Return result:
expect(result).toEqual(expected);
});
it('logIn: bails out if captchaSiteKey is true', async () => {
const siteKey = 'CAPTCHA_SITE_KEY';
logInSetup();
commonSetup();
const tokenResponse = newTokenResponse();
(tokenResponse as any).siteKey = siteKey;
tokenService.getTwoFactorToken(email).resolves(null);
apiService.postIdentityToken(Arg.any()).resolves(tokenResponse);
const expected = new AuthResult();
expected.captchaSiteKey = siteKey;
// Act
const result = await authService.logIn(email, masterPassword);
// Assertions
stateService.didNotReceive().addAccount(Arg.any());
messagingService.didNotReceive().send(Arg.any());
expect(result).toEqual(expected);
});
});