test: add missing email-change verify edge cases (expired, max_attempts)
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 15m49s
All checks were successful
Build & Deploy to Staging / Build & Deploy to Staging (push) Successful in 15m49s
This commit is contained in:
parent
7808d85dde
commit
4887e8ffbe
1 changed files with 14 additions and 0 deletions
|
|
@ -105,6 +105,20 @@ describe("POST /v1/email-change/verify", () => {
|
||||||
expect(res.status).toBe(400);
|
expect(res.status).toBe(400);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("returns 410 for expired code", async () => {
|
||||||
|
const { verifyCode } = await import("../services/verification.js");
|
||||||
|
vi.mocked(verifyCode).mockResolvedValue({ status: "expired" });
|
||||||
|
const res = await request(app).post("/v1/email-change/verify").send({ apiKey: "df_pro_xxx", newEmail: "new@example.com", code: "999999" });
|
||||||
|
expect(res.status).toBe(410);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns 429 for max attempts", async () => {
|
||||||
|
const { verifyCode } = await import("../services/verification.js");
|
||||||
|
vi.mocked(verifyCode).mockResolvedValue({ status: "max_attempts" });
|
||||||
|
const res = await request(app).post("/v1/email-change/verify").send({ apiKey: "df_pro_xxx", newEmail: "new@example.com", code: "999999" });
|
||||||
|
expect(res.status).toBe(429);
|
||||||
|
});
|
||||||
|
|
||||||
it("returns 200 and updates email on success", async () => {
|
it("returns 200 and updates email on success", async () => {
|
||||||
const { queryWithRetry } = await import("../services/db.js");
|
const { queryWithRetry } = await import("../services/db.js");
|
||||||
const res = await request(app).post("/v1/email-change/verify").send({ apiKey: "df_pro_xxx", newEmail: "new@example.com", code: "123456" });
|
const res = await request(app).post("/v1/email-change/verify").send({ apiKey: "df_pro_xxx", newEmail: "new@example.com", code: "123456" });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue