1
0
Fork 0
mirror of synced 2024-10-06 04:54:52 +13:00

Fix user test

This commit is contained in:
Adria Navarro Redo 2023-01-26 15:16:42 +00:00 committed by adrinr
parent 33f1628000
commit b94546b1a1
3 changed files with 15 additions and 11 deletions

View file

@ -62,8 +62,8 @@ export async function getUser(
return user
}
export async function invalidateUser(userId: string) {
const tenantId = getTenantId()
export async function invalidateUser(userId: string, tenantId?: string) {
tenantId = tenantId || getTenantId()
const cacheKey = getCacheKey(tenantId, userId)
const client = await redis.getUserClient()
await client.delete(cacheKey)

View file

@ -44,7 +44,6 @@ const config: Config = {
},
{
...configSettings,
displayName: "parallel test",
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
},
],

View file

@ -177,24 +177,24 @@ class TestConfiguration {
}
// MODES
setMultiTenancy = (value: boolean) => {
#setMultiTenancy = (value: boolean) => {
env._set("MULTI_TENANCY", value)
coreEnv._set("MULTI_TENANCY", value)
}
setSelfHosted = (value: boolean) => {
#setSelfHosted = (value: boolean) => {
env._set("SELF_HOSTED", value)
coreEnv._set("SELF_HOSTED", value)
}
modeCloud = () => {
this.setSelfHosted(false)
this.setMultiTenancy(true)
this.#setSelfHosted(false)
this.#setMultiTenancy(true)
}
modeSelf = () => {
this.setSelfHosted(true)
this.setMultiTenancy(false)
this.#setSelfHosted(true)
this.#setMultiTenancy(false)
}
// UTILS
@ -288,7 +288,7 @@ class TestConfiguration {
admin,
roles,
})
await cache.user.invalidateUser(globalId)
await cache.user.invalidateUser(globalId, this.getTenantId())
return {
...resp,
globalId,
@ -328,7 +328,7 @@ class TestConfiguration {
const appToken = auth.jwt.sign(app, env.JWT_SECRET)
// returning necessary request headers
await cache.user.invalidateUser(userId)
await cache.user.invalidateUser(userId, this.getTenantId())
return {
Accept: "application/json",
Cookie: [
@ -384,6 +384,11 @@ class TestConfiguration {
if (appId) {
headers[constants.Header.APP_ID] = appId
}
if (this.tenantId) {
headers[constants.Header.TENANT_ID] = this.tenantId
}
return headers
}