fix: fix test script for forgot password again
All checks were successful
Deploy / deploy (push) Successful in 56s
Security Tests / security-non-db (push) Successful in 19s
Security Tests / security-db (push) Successful in 23s

This commit is contained in:
2026-03-01 21:54:50 -06:00
parent b6db624d92
commit f2b80a1ca0

View File

@@ -1,5 +1,5 @@
import { createHmac } from "node:crypto"; import { createHmac } from "node:crypto";
import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import request from "supertest"; import request from "supertest";
import type { FastifyInstance } from "fastify"; import type { FastifyInstance } from "fastify";
import { buildApp } from "../src/server"; import { buildApp } from "../src/server";
@@ -122,17 +122,14 @@ describe("A04 Cryptographic Failures (runtime adversarial checks)", () => {
}); });
it("accepts token with correct signature, issuer, and audience", async () => { it("accepts token with correct signature, issuer, and audience", async () => {
const user = await app.prisma.user.create({ const userId = `valid-${Date.now()}`;
data: { const findUniqueMock = vi
email: `jwt-runtime-${Date.now()}@test.dev`, .spyOn((app as any).prisma.user, "findUnique")
emailVerified: true, .mockResolvedValue({ id: userId, passwordChangedAt: null });
},
select: { id: true },
});
const nowSeconds = Math.floor(Date.now() / 1000); const nowSeconds = Math.floor(Date.now() / 1000);
const token = signHs256Token( const token = signHs256Token(
{ {
sub: user.id, sub: userId,
iss: "skymoney-api", iss: "skymoney-api",
aud: "skymoney-web", aud: "skymoney-web",
iat: nowSeconds, iat: nowSeconds,
@@ -148,7 +145,6 @@ describe("A04 Cryptographic Failures (runtime adversarial checks)", () => {
expect(res.status).toBe(200); expect(res.status).toBe(200);
expect(res.body.ok).toBe(true); expect(res.body.ok).toBe(true);
findUniqueMock.mockRestore();
await app.prisma.user.delete({ where: { id: user.id } });
}); });
}); });