From 8cdf6050066c869a03720e9db483ee023c12795f Mon Sep 17 00:00:00 2001 From: Sabir Hassan Date: Wed, 10 May 2023 17:02:13 +0500 Subject: [PATCH] chore: fix specs --- api/src/routes/api/spec/auth.spec.ts | 12 ++++++------ api/src/utils/verifyTokenInDB.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/src/routes/api/spec/auth.spec.ts b/api/src/routes/api/spec/auth.spec.ts index 0e35d89..c6a2444 100644 --- a/api/src/routes/api/spec/auth.spec.ts +++ b/api/src/routes/api/spec/auth.spec.ts @@ -1,3 +1,4 @@ +import { randomBytes } from 'crypto' import { Express } from 'express' import mongoose, { Mongoose } from 'mongoose' import { MongoMemoryServer } from 'mongodb-memory-server' @@ -20,7 +21,6 @@ import { const clientId = 'someclientID' const clientSecret = 'someclientSecret' const user = { - id: '1234', displayName: 'Test User', username: 'testUsername', password: '87654321', @@ -52,7 +52,7 @@ describe('auth', () => { describe('token', () => { const userInfo: InfoJWT = { clientId, - userId: user.id + userId: randomBytes(12).toString('hex') } beforeAll(async () => { await userController.createUser(user) @@ -151,10 +151,10 @@ describe('auth', () => { currentUser = await userController.createUser(user) refreshToken = generateRefreshToken({ clientId, - userId: currentUser.id + userId: currentUser.uid }) await saveTokensInDB( - currentUser.id, + currentUser.uid, clientId, 'accessToken', refreshToken @@ -202,11 +202,11 @@ describe('auth', () => { currentUser = await userController.createUser(user) accessToken = generateAccessToken({ clientId, - userId: currentUser.id + userId: currentUser.uid }) await saveTokensInDB( - currentUser.id, + currentUser.uid, clientId, accessToken, 'refreshToken' diff --git a/api/src/utils/verifyTokenInDB.ts b/api/src/utils/verifyTokenInDB.ts index 239abdc..d612db9 100644 --- a/api/src/utils/verifyTokenInDB.ts +++ b/api/src/utils/verifyTokenInDB.ts @@ -21,7 +21,7 @@ export const fetchLatestAutoExec = async ( } export const verifyTokenInDB = async ( - userId: number, + userId: string, clientId: string, token: string, tokenType: 'accessToken' | 'refreshToken'