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 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)

View File

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

View File

@ -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
} }