Use extracted functions
This commit is contained in:
parent
d8473b4a23
commit
e4feb64fe5
|
@ -39,7 +39,11 @@ describe("/permission", () => {
|
||||||
|
|
||||||
table = (await config.createTable()) as typeof table
|
table = (await config.createTable()) as typeof table
|
||||||
row = await config.createRow()
|
row = await config.createRow()
|
||||||
perms = await config.addPermission(STD_ROLE_ID, table._id)
|
perms = await config.api.permission.set({
|
||||||
|
roleId: STD_ROLE_ID,
|
||||||
|
resourceId: table._id,
|
||||||
|
level: PermissionLevel.READ,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("levels", () => {
|
describe("levels", () => {
|
||||||
|
@ -74,11 +78,11 @@ describe("/permission", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should get resource permissions with multiple roles", async () => {
|
it("should get resource permissions with multiple roles", async () => {
|
||||||
perms = await config.addPermission(
|
perms = await config.api.permission.set({
|
||||||
HIGHER_ROLE_ID,
|
roleId: HIGHER_ROLE_ID,
|
||||||
table._id,
|
resourceId: table._id,
|
||||||
PermissionLevel.WRITE
|
level: PermissionLevel.WRITE,
|
||||||
)
|
})
|
||||||
const res = await config.api.permission.get(table._id)
|
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)
|
||||||
|
|
|
@ -50,7 +50,6 @@ import {
|
||||||
SearchFilters,
|
SearchFilters,
|
||||||
UserRoles,
|
UserRoles,
|
||||||
Automation,
|
Automation,
|
||||||
PermissionLevel,
|
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/src/security/roles"
|
import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/src/security/roles"
|
||||||
|
|
||||||
|
@ -621,22 +620,6 @@ class TestConfiguration {
|
||||||
return this._req(config, null, controllers.role.save)
|
return this._req(config, null, controllers.role.save)
|
||||||
}
|
}
|
||||||
|
|
||||||
async addPermission(
|
|
||||||
roleId: string,
|
|
||||||
resourceId: string,
|
|
||||||
level = PermissionLevel.READ
|
|
||||||
) {
|
|
||||||
return this._req(
|
|
||||||
null,
|
|
||||||
{
|
|
||||||
roleId,
|
|
||||||
resourceId,
|
|
||||||
level,
|
|
||||||
},
|
|
||||||
controllers.perms.addPermission
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// VIEW
|
// VIEW
|
||||||
|
|
||||||
async createView(config?: any) {
|
async createView(config?: any) {
|
||||||
|
|
Loading…
Reference in New Issue