Add tests for app specific roles
This commit is contained in:
parent
d55172a9fb
commit
0fa1e7b97b
|
@ -27,6 +27,7 @@ export default class AuthApi {
|
|||
password: password,
|
||||
},
|
||||
})
|
||||
expect(response).toHaveStatusCode(200)
|
||||
const cookie = response.headers.get("set-cookie")
|
||||
this.api.cookie = cookie as any
|
||||
return [response, cookie]
|
||||
|
|
|
@ -115,4 +115,13 @@ export default class UserManagementApi {
|
|||
expect(response).toHaveStatusCode(200)
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async changeSelfPassword(body: Partial<User>): Promise<[Response, User]> {
|
||||
const response = await this.api.post(`/global/self`, { body })
|
||||
const json = await response.json()
|
||||
expect(response).toHaveStatusCode(200)
|
||||
expect(json._id).toEqual(body._id)
|
||||
expect(json._rev).not.toEqual(body._rev)
|
||||
return [response, json]
|
||||
}
|
||||
}
|
|
@ -226,8 +226,26 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
|||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("BASIC")
|
||||
|
||||
const [basicScreenResponse, basicScreenJson] = await config.screen.create(generateScreen("BASIC"))
|
||||
const [powerScreenResponse, powerScreenJson] = await config.screen.create(generateScreen("POWER"))
|
||||
const [adminScreenResponse, adminScreenJson] = await config.screen.create(generateScreen("ADMIN"))
|
||||
|
||||
await config.applications.publish(<string>app.url)
|
||||
const [firstappPackageResponse, firstappPackageJson] = await config.applications.getAppPackage(<string>app.appId)
|
||||
expect(firstappPackageJson.screens).toBeDefined()
|
||||
expect(firstappPackageJson.screens.length).toEqual(3)
|
||||
|
||||
await config.login(<string>appUser[0].email, <string>appUser[0].password)
|
||||
const [selfInfoResponse, selfInfoJson] = await config.users.getSelf()
|
||||
//Update password
|
||||
const userWithNewPassword = {
|
||||
...selfInfoJson,
|
||||
password: <string>appUser[0].password
|
||||
}
|
||||
await config.users.changeSelfPassword(userWithNewPassword)
|
||||
const [appPackageResponse, appPackageJson] = await config.applications.getAppPackage(<string>app.appId)
|
||||
expect(appPackageJson.screens).toBeDefined()
|
||||
expect(appPackageJson.screens.length).toEqual(1)
|
||||
expect(appPackageJson.screens[0].routing.roleId).toEqual("BASIC")
|
||||
})
|
||||
|
||||
it("Check Screen access for POWER role", async () => {
|
||||
|
@ -251,6 +269,21 @@ describe("Internal API - App Specific Roles & Permissions", () => {
|
|||
const [changedUserInfoResponse, changedUserInfoJson] = await config.users.getInfo(createUserJson.created.successful[0]._id)
|
||||
expect(changedUserInfoJson.roles[<string>app.appId]).toBeDefined()
|
||||
expect(changedUserInfoJson.roles[<string>app.appId]).toEqual("POWER")
|
||||
|
||||
const [basicScreenResponse, basicScreenJson] = await config.screen.create(generateScreen("BASIC"))
|
||||
const [powerScreenResponse, powerScreenJson] = await config.screen.create(generateScreen("POWER"))
|
||||
const [adminScreenResponse, adminScreenJson] = await config.screen.create(generateScreen("ADMIN"))
|
||||
|
||||
await config.applications.publish(<string>app.url)
|
||||
const [firstappPackageResponse, firstappPackageJson] = await config.applications.getAppPackage(<string>app.appId)
|
||||
expect(firstappPackageJson.screens).toBeDefined()
|
||||
expect(firstappPackageJson.screens.length).toEqual(3)
|
||||
|
||||
await config.login(<string>appUser[0].email, <string>appUser[0].password)
|
||||
const [appPackageResponse, appPackageJson] = await config.applications.getAppPackage(<string>app.appId)
|
||||
expect(appPackageJson.screens).toBeDefined()
|
||||
expect(appPackageJson.screens.length).toEqual(2)
|
||||
expect(appPackageJson.screens[0].routing.roleId).toEqual("BASIC")
|
||||
})
|
||||
|
||||
it("Check Screen access for ADMIN role", async () => {
|
||||
|
|
Loading…
Reference in New Issue