Move permissions get into the config api
This commit is contained in:
parent
561fe3cbe9
commit
1283431b32
|
@ -42,14 +42,6 @@ describe("/permission", () => {
|
||||||
perms = await config.addPermission(STD_ROLE_ID, table._id)
|
perms = await config.addPermission(STD_ROLE_ID, table._id)
|
||||||
})
|
})
|
||||||
|
|
||||||
async function getTablePermissions() {
|
|
||||||
return request
|
|
||||||
.get(`/api/permission/${table._id}`)
|
|
||||||
.set(config.defaultHeaders())
|
|
||||||
.expect("Content-Type", /json/)
|
|
||||||
.expect(200)
|
|
||||||
}
|
|
||||||
|
|
||||||
describe("levels", () => {
|
describe("levels", () => {
|
||||||
it("should be able to get levels", async () => {
|
it("should be able to get levels", async () => {
|
||||||
const res = await request
|
const res = await request
|
||||||
|
@ -87,7 +79,7 @@ describe("/permission", () => {
|
||||||
table._id,
|
table._id,
|
||||||
PermissionLevel.WRITE
|
PermissionLevel.WRITE
|
||||||
)
|
)
|
||||||
const res = await getTablePermissions()
|
const res = await config.api.permission.get(table._id)
|
||||||
expect(res.body["read"]).toEqual(STD_ROLE_ID)
|
expect(res.body["read"]).toEqual(STD_ROLE_ID)
|
||||||
expect(res.body["write"]).toEqual(HIGHER_ROLE_ID)
|
expect(res.body["write"]).toEqual(HIGHER_ROLE_ID)
|
||||||
const allRes = await request
|
const allRes = await request
|
||||||
|
@ -128,7 +120,7 @@ describe("/permission", () => {
|
||||||
level: PermissionLevel.READ,
|
level: PermissionLevel.READ,
|
||||||
})
|
})
|
||||||
expect(res.body[0]._id).toEqual(STD_ROLE_ID)
|
expect(res.body[0]._id).toEqual(STD_ROLE_ID)
|
||||||
const permsRes = await getTablePermissions()
|
const permsRes = await config.api.permission.get(table._id)
|
||||||
expect(permsRes.body[STD_ROLE_ID]).toBeUndefined()
|
expect(permsRes.body[STD_ROLE_ID]).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,17 @@ export class PermissionAPI extends TestAPI {
|
||||||
super(config)
|
super(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get = async (
|
||||||
|
resourceId: string,
|
||||||
|
{ expectStatus } = { expectStatus: 200 }
|
||||||
|
) => {
|
||||||
|
return this.request
|
||||||
|
.get(`/api/permission/${resourceId}`)
|
||||||
|
.set(this.config.defaultHeaders())
|
||||||
|
.expect("Content-Type", /json/)
|
||||||
|
.expect(expectStatus)
|
||||||
|
}
|
||||||
|
|
||||||
create = async (
|
create = async (
|
||||||
{
|
{
|
||||||
roleId,
|
roleId,
|
||||||
|
|
Loading…
Reference in New Issue