Fix user test
This commit is contained in:
parent
48ee427178
commit
bf0f7d5bab
|
@ -62,8 +62,8 @@ export async function getUser(
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function invalidateUser(userId: string) {
|
export async function invalidateUser(userId: string, tenantId?: string) {
|
||||||
const tenantId = getTenantId()
|
tenantId = tenantId || getTenantId()
|
||||||
const cacheKey = getCacheKey(tenantId, userId)
|
const cacheKey = getCacheKey(tenantId, userId)
|
||||||
const client = await redis.getUserClient()
|
const client = await redis.getUserClient()
|
||||||
await client.delete(cacheKey)
|
await client.delete(cacheKey)
|
||||||
|
|
|
@ -44,7 +44,6 @@ const config: Config = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...configSettings,
|
...configSettings,
|
||||||
displayName: "parallel test",
|
|
||||||
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
|
testMatch: ["<rootDir>/**/!(*.seq).spec.[jt]s"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -177,24 +177,24 @@ class TestConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// MODES
|
// MODES
|
||||||
setMultiTenancy = (value: boolean) => {
|
#setMultiTenancy = (value: boolean) => {
|
||||||
env._set("MULTI_TENANCY", value)
|
env._set("MULTI_TENANCY", value)
|
||||||
coreEnv._set("MULTI_TENANCY", value)
|
coreEnv._set("MULTI_TENANCY", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelfHosted = (value: boolean) => {
|
#setSelfHosted = (value: boolean) => {
|
||||||
env._set("SELF_HOSTED", value)
|
env._set("SELF_HOSTED", value)
|
||||||
coreEnv._set("SELF_HOSTED", value)
|
coreEnv._set("SELF_HOSTED", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
modeCloud = () => {
|
modeCloud = () => {
|
||||||
this.setSelfHosted(false)
|
this.#setSelfHosted(false)
|
||||||
this.setMultiTenancy(true)
|
this.#setMultiTenancy(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
modeSelf = () => {
|
modeSelf = () => {
|
||||||
this.setSelfHosted(true)
|
this.#setSelfHosted(true)
|
||||||
this.setMultiTenancy(false)
|
this.#setMultiTenancy(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UTILS
|
// UTILS
|
||||||
|
@ -288,7 +288,7 @@ class TestConfiguration {
|
||||||
admin,
|
admin,
|
||||||
roles,
|
roles,
|
||||||
})
|
})
|
||||||
await cache.user.invalidateUser(globalId)
|
await cache.user.invalidateUser(globalId, this.getTenantId())
|
||||||
return {
|
return {
|
||||||
...resp,
|
...resp,
|
||||||
globalId,
|
globalId,
|
||||||
|
@ -328,7 +328,7 @@ class TestConfiguration {
|
||||||
const appToken = auth.jwt.sign(app, env.JWT_SECRET)
|
const appToken = auth.jwt.sign(app, env.JWT_SECRET)
|
||||||
|
|
||||||
// returning necessary request headers
|
// returning necessary request headers
|
||||||
await cache.user.invalidateUser(userId)
|
await cache.user.invalidateUser(userId, this.getTenantId())
|
||||||
return {
|
return {
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
Cookie: [
|
Cookie: [
|
||||||
|
@ -384,6 +384,11 @@ class TestConfiguration {
|
||||||
if (appId) {
|
if (appId) {
|
||||||
headers[constants.Header.APP_ID] = appId
|
headers[constants.Header.APP_ID] = appId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.tenantId) {
|
||||||
|
headers[constants.Header.TENANT_ID] = this.tenantId
|
||||||
|
}
|
||||||
|
|
||||||
return headers
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue