Skip to content

Commit

Permalink
Add test for logInNewDeviceVerification
Browse files Browse the repository at this point in the history
  • Loading branch information
alec-livefront committed Jan 14, 2025
1 parent 96a4f03 commit 100103d
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,24 @@ describe("PasswordLoginStrategy", () => {
);
expect(secondResult.forcePasswordReset).toEqual(ForceSetPasswordReason.WeakMasterPassword);
});

it("handles new device verification login with OTP", async () => {
const deviceVerificationOtp = "123456";
const tokenResponse = identityTokenResponseFactory();
apiService.postIdentityToken.mockResolvedValueOnce(tokenResponse);
tokenService.decodeAccessToken.mockResolvedValue({ sub: userId });

await passwordLoginStrategy.logIn(credentials);

const result = await passwordLoginStrategy.logInNewDeviceVerification(deviceVerificationOtp);

expect(apiService.postIdentityToken).toHaveBeenCalledWith(
expect.objectContaining({
newDeviceOtp: deviceVerificationOtp,
}),
);
expect(result.forcePasswordReset).toBe(ForceSetPasswordReason.None);
expect(result.resetMasterPassword).toBe(false);
expect(result.userId).toBe(userId);
});
});

0 comments on commit 100103d

Please sign in to comment.