mirror of
https://github.com/Paris-est-Ludique/intranet.git
synced 2025-06-08 08:34:20 +02:00
Fix jwt testing
This commit is contained in:
parent
6541de5ff9
commit
040f1e6a0e
@ -56,5 +56,6 @@ module.exports = {
|
||||
__SERVER__: true,
|
||||
__DEV__: true,
|
||||
__LOCAL__: false,
|
||||
__TEST__: false,
|
||||
},
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ module.exports = {
|
||||
__CLIENT__: true,
|
||||
__SERVER__: false,
|
||||
__LOCAL__: false,
|
||||
__TEST__: true,
|
||||
localStorage: { getItem: () => null, setItem: () => null, removeItem: () => null },
|
||||
},
|
||||
maxConcurrency: 50,
|
||||
maxWorkers: 1,
|
||||
|
@ -51,8 +51,14 @@ async function getSecret() {
|
||||
}
|
||||
|
||||
export async function getJwt(email: string): Promise<string> {
|
||||
const jwt = sign({ user: canonicalEmail(email), permissions: [] }, await getSecret(), {
|
||||
expiresIn: "365d",
|
||||
})
|
||||
const jwt = sign(
|
||||
{ user: canonicalEmail(email), permissions: [] },
|
||||
await getSecret(),
|
||||
__TEST__
|
||||
? undefined
|
||||
: {
|
||||
expiresIn: "365d",
|
||||
}
|
||||
)
|
||||
return jwt
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import _ from "lodash"
|
||||
import { login } from "../login"
|
||||
|
||||
// Could do a full test with wget --header='Content-Type:application/json' --post-data='{"email":"pikiou.sub@gmail.com","password":"mot de passe"}' http://localhost:3000/api/user/login
|
||||
@ -19,11 +20,12 @@ jest.mock("../../gsheets/accessors", () => () => ({
|
||||
describe("login with", () => {
|
||||
it("right password", async () => {
|
||||
const res = await login("my.email@gmail.com", "12345678")
|
||||
expect(res).toEqual({
|
||||
expect(_.omit(res, "jwt")).toEqual({
|
||||
membre: {
|
||||
prenom: mockUser.prenom,
|
||||
},
|
||||
})
|
||||
expect(res.jwt).toBeDefined()
|
||||
})
|
||||
|
||||
it("invalid password length", async () => {
|
||||
|
2
src/types/index.d.ts
vendored
2
src/types/index.d.ts
vendored
@ -2,6 +2,7 @@ declare const __CLIENT__: boolean
|
||||
declare const __SERVER__: boolean
|
||||
declare const __DEV__: boolean
|
||||
declare const __LOCAL__: boolean
|
||||
declare const __TEST__: boolean
|
||||
|
||||
declare module "*.svg"
|
||||
declare module "*.gif"
|
||||
@ -18,6 +19,7 @@ declare namespace NodeJS {
|
||||
__SERVER__: boolean
|
||||
__DEV__: boolean
|
||||
__LOCAL__: boolean
|
||||
__TEST__: boolean
|
||||
$RefreshReg$: () => void
|
||||
$RefreshSig$$: () => void
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user