chore: Update auth flow (#9959)

This commit is contained in:
Oli Juhl
2024-11-06 21:21:45 +01:00
committed by GitHub
parent 505768dd9f
commit 441004cc21
3 changed files with 41 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
import { generateResetPasswordTokenWorkflow } from "@medusajs/core-flows"
import jwt from "jsonwebtoken"
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
import jwt from "jsonwebtoken"
import {
adminHeaders,
createAdminUser,
@@ -264,6 +264,28 @@ medusaIntegrationTestRunner({
expect(response.response.status).toEqual(401)
expect(response.response.data.message).toEqual("Invalid token")
})
it("should fail if no token is passed", async () => {
jest.useFakeTimers()
// Register user
await api.post("/auth/user/emailpass/register", {
email: "test@medusa-commerce.com",
password: "secret_password",
})
// Advance time by 15 minutes
jest.advanceTimersByTime(15 * 60 * 1000)
const response = await api
.post(`/auth/user/emailpass/update`, {
email: "test@medusa-commerce.com",
})
.catch((e) => e)
expect(response.response.status).toEqual(401)
expect(response.response.data.message).toEqual("Invalid token")
})
})
it("should refresh the token successfully", async () => {