Get test passing.
This commit is contained in:
parent
aa124524d4
commit
f1decee010
|
@ -25,6 +25,8 @@ import {
|
|||
} from "@budibase/types"
|
||||
import tk from "timekeeper"
|
||||
|
||||
jest.setTimeout(99999999)
|
||||
|
||||
describe("/applications", () => {
|
||||
let config = setup.getConfig()
|
||||
let app: App
|
||||
|
@ -257,7 +259,7 @@ describe("/applications", () => {
|
|||
|
||||
describe("permissions", () => {
|
||||
it.only("should only return apps a user has access to", async () => {
|
||||
const user = await config.createUser({
|
||||
let user = await config.createUser({
|
||||
builder: { global: false },
|
||||
admin: { global: false },
|
||||
})
|
||||
|
@ -280,10 +282,10 @@ describe("/applications", () => {
|
|||
expect(apps).toHaveLength(0)
|
||||
})
|
||||
|
||||
await config.api.user.update({
|
||||
user = await config.globalUser({
|
||||
...user,
|
||||
builder: {
|
||||
[config.getAppId()]: true,
|
||||
apps: [config.getProdAppId()],
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
@ -363,6 +363,7 @@ export default class TestConfiguration {
|
|||
_id,
|
||||
...existing,
|
||||
...config,
|
||||
_rev: existing._rev,
|
||||
email,
|
||||
roles,
|
||||
tenantId,
|
||||
|
@ -372,11 +373,12 @@ export default class TestConfiguration {
|
|||
admin,
|
||||
}
|
||||
await sessions.createASession(_id, {
|
||||
sessionId: "sessionid",
|
||||
sessionId: this.sessionIdForUser(_id),
|
||||
tenantId: this.getTenantId(),
|
||||
csrfToken: this.csrfToken,
|
||||
})
|
||||
const resp = await db.put(user)
|
||||
await cache.user.invalidateUser(_id)
|
||||
return {
|
||||
_rev: resp.rev,
|
||||
...user,
|
||||
|
@ -384,9 +386,7 @@ export default class TestConfiguration {
|
|||
}
|
||||
|
||||
async createUser(user: Partial<User> = {}): Promise<User> {
|
||||
const resp = await this.globalUser(user)
|
||||
await cache.user.invalidateUser(resp._id!)
|
||||
return resp
|
||||
return await this.globalUser(user)
|
||||
}
|
||||
|
||||
async createGroup(roleId: string = roles.BUILTIN_ROLE_IDS.BASIC) {
|
||||
|
@ -416,6 +416,10 @@ export default class TestConfiguration {
|
|||
})
|
||||
}
|
||||
|
||||
sessionIdForUser(userId: string): string {
|
||||
return `sessionid-${userId}`
|
||||
}
|
||||
|
||||
async login({
|
||||
roleId,
|
||||
userId,
|
||||
|
@ -442,13 +446,13 @@ export default class TestConfiguration {
|
|||
})
|
||||
}
|
||||
await sessions.createASession(userId, {
|
||||
sessionId: "sessionid",
|
||||
sessionId: this.sessionIdForUser(userId),
|
||||
tenantId: this.getTenantId(),
|
||||
})
|
||||
// have to fake this
|
||||
const authObj = {
|
||||
userId,
|
||||
sessionId: "sessionid",
|
||||
sessionId: this.sessionIdForUser(userId),
|
||||
tenantId: this.getTenantId(),
|
||||
}
|
||||
const authToken = jwt.sign(authObj, coreEnv.JWT_SECRET as Secret)
|
||||
|
@ -470,7 +474,7 @@ export default class TestConfiguration {
|
|||
const user = this.getUser()
|
||||
const authObj: AuthToken = {
|
||||
userId: user._id!,
|
||||
sessionId: "sessionid",
|
||||
sessionId: this.sessionIdForUser(user._id!),
|
||||
tenantId,
|
||||
}
|
||||
const authToken = jwt.sign(authObj, coreEnv.JWT_SECRET as Secret)
|
||||
|
|
Loading…
Reference in New Issue