fix: Use the correct defaults for the invite token expiry (#10344)

This commit is contained in:
Stevche Radevski
2024-11-28 12:06:32 +01:00
committed by GitHub
parent aced04e182
commit f7279f1b96
3 changed files with 45 additions and 8 deletions

View File

@@ -156,6 +156,37 @@ medusaIntegrationTestRunner({
expect(e.response.data.message).toEqual("Unauthorized")
})
})
it("should fail to accept with an expired token", async () => {
jest.useFakeTimers()
const signup = await api.post("/auth/user/emailpass/register", {
email: "test@medusa-commerce.com",
password: "secret_password",
})
// Advance time by 25 hours
jest.advanceTimersByTime(25 * 60 * 60 * 1000)
await api
.post(
`/admin/invites/accept?token=${invite.token}`,
{
first_name: "Another Test",
last_name: "User",
},
{
headers: { authorization: `Bearer ${signup.data.token}` },
}
)
.catch((e) => {
expect(e.response.status).toEqual(401)
expect(e.response.data.message).toEqual("Unauthorized")
})
jest.useRealTimers()
})
it("should resend an invite", async () => {
const resendResponse = (
await api.post(`/admin/invites/${invite.id}/resend`, {}, adminHeaders)