1
0
Fork 0
mirror of synced 2024-07-20 05:35:58 +12:00

Move permissions get into the config api

This commit is contained in:
Adria Navarro 2023-08-22 12:06:44 +03:00
parent 561fe3cbe9
commit 1283431b32
2 changed files with 13 additions and 10 deletions

View file

@ -42,14 +42,6 @@ describe("/permission", () => {
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", () => {
it("should be able to get levels", async () => {
const res = await request
@ -87,7 +79,7 @@ describe("/permission", () => {
table._id,
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["write"]).toEqual(HIGHER_ROLE_ID)
const allRes = await request
@ -128,7 +120,7 @@ describe("/permission", () => {
level: PermissionLevel.READ,
})
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()
})

View file

@ -7,6 +7,17 @@ export class PermissionAPI extends TestAPI {
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 (
{
roleId,