Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+24
@@ -15,6 +15,7 @@ vi.mock("@hivegrid/config", () => ({
|
||||
|
||||
vi.mock("~/utils/db/users.db.server", () => ({
|
||||
activateUserTotpPendingSecret: vi.fn(),
|
||||
clearUserTotpPendingSecret: vi.fn(),
|
||||
getUserTotpPendingEnrollment: vi.fn(),
|
||||
setUserMfaRecoveryCodes: vi.fn(),
|
||||
setUserTotpPendingSecret: vi.fn(),
|
||||
@@ -222,6 +223,7 @@ describe("services/auth/totp.server", () => {
|
||||
const usersDb = await import("~/utils/db/users.db.server");
|
||||
vi.mocked(usersDb.getUserTotpPendingEnrollment).mockResolvedValueOnce({
|
||||
totpPendingSecretEncrypted: `encrypted:${vectorSecret}`,
|
||||
totpPendingCreatedAt: new Date("2026-05-25T09:00:00.000Z"),
|
||||
} as never);
|
||||
const { activatePendingTotpForUser } = await import("./totp.server");
|
||||
|
||||
@@ -236,6 +238,27 @@ describe("services/auth/totp.server", () => {
|
||||
expect(usersDb.setUserMfaRecoveryCodes).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("activatePendingTotpForUser clears and rejects an enrollment older than ten minutes", async () => {
|
||||
const usersDb = await import("~/utils/db/users.db.server");
|
||||
const pending = {
|
||||
totpPendingSecretEncrypted: `encrypted:${vectorSecret}`,
|
||||
totpPendingCreatedAt: new Date("2026-05-25T09:00:00.000Z"),
|
||||
};
|
||||
vi.mocked(usersDb.getUserTotpPendingEnrollment).mockResolvedValueOnce(pending);
|
||||
const { activatePendingTotpForUser } = await import("./totp.server");
|
||||
|
||||
await expect(
|
||||
activatePendingTotpForUser({
|
||||
userId: "user_1",
|
||||
token: generateExpectedCode(vectorSecret, new Date("2026-05-25T09:10:00.001Z").getTime()),
|
||||
now: new Date("2026-05-25T09:10:00.001Z"),
|
||||
})
|
||||
).resolves.toEqual({ activated: false, recoveryCodes: [] });
|
||||
expect(usersDb.clearUserTotpPendingSecret).toHaveBeenCalledWith("user_1", pending);
|
||||
expect(usersDb.activateUserTotpPendingSecret).not.toHaveBeenCalled();
|
||||
expect(usersDb.setUserMfaRecoveryCodes).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("activatePendingTotpForUser promotes the pending secret and stores recovery codes", async () => {
|
||||
const usersDb = await import("~/utils/db/users.db.server");
|
||||
const { generateRecoveryCodes } = await import("~/utils/auth/mfa/recovery-codes.server");
|
||||
@@ -243,6 +266,7 @@ describe("services/auth/totp.server", () => {
|
||||
const code = generateExpectedCode(vectorSecret, now.getTime());
|
||||
vi.mocked(usersDb.getUserTotpPendingEnrollment).mockResolvedValueOnce({
|
||||
totpPendingSecretEncrypted: `encrypted:${vectorSecret}`,
|
||||
totpPendingCreatedAt: now,
|
||||
} as never);
|
||||
const { activatePendingTotpForUser, TOTP_RECOVERY_CODE_COUNT } = await import("./totp.server");
|
||||
|
||||
|
||||
Reference in new issue
Block a user