Add permission api to testconfig
This commit is contained in:
parent
63ffc81ffe
commit
f1232eac90
|
@ -50,6 +50,7 @@ import {
|
|||
SearchFilters,
|
||||
UserRoles,
|
||||
Automation,
|
||||
PermissionLevel,
|
||||
} from "@budibase/types"
|
||||
import { BUILTIN_ROLE_IDS } from "@budibase/backend-core/src/security/roles"
|
||||
|
||||
|
@ -620,7 +621,11 @@ class TestConfiguration {
|
|||
return this._req(config, null, controllers.role.save)
|
||||
}
|
||||
|
||||
async addPermission(roleId: string, resourceId: string, level = "read") {
|
||||
async addPermission(
|
||||
roleId: string,
|
||||
resourceId: string,
|
||||
level = PermissionLevel.READ
|
||||
) {
|
||||
return this._req(
|
||||
null,
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import TestConfiguration from "../TestConfiguration"
|
||||
import { PermissionAPI } from "./permission"
|
||||
import { RowAPI } from "./row"
|
||||
import { TableAPI } from "./table"
|
||||
import { ViewV2API } from "./viewV2"
|
||||
|
@ -7,10 +8,12 @@ export default class API {
|
|||
table: TableAPI
|
||||
viewV2: ViewV2API
|
||||
row: RowAPI
|
||||
permission: PermissionAPI
|
||||
|
||||
constructor(config: TestConfiguration) {
|
||||
this.table = new TableAPI(config)
|
||||
this.viewV2 = new ViewV2API(config)
|
||||
this.row = new RowAPI(config)
|
||||
this.permission = new PermissionAPI(config)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import { AnyDocument, PermissionLevel } from "@budibase/types"
|
||||
import TestConfiguration from "../TestConfiguration"
|
||||
import { TestAPI } from "./base"
|
||||
|
||||
export class PermissionAPI extends TestAPI {
|
||||
constructor(config: TestConfiguration) {
|
||||
super(config)
|
||||
}
|
||||
|
||||
create = async (
|
||||
{
|
||||
roleId,
|
||||
resourceId,
|
||||
level,
|
||||
}: { roleId: string; resourceId: string; level: PermissionLevel },
|
||||
{ expectStatus } = { expectStatus: 200 }
|
||||
): Promise<AnyDocument[]> => {
|
||||
const res = await this.request
|
||||
.post(`/api/permission/${roleId}/${resourceId}/${level}`)
|
||||
.set(this.config.defaultHeaders())
|
||||
.expect("Content-Type", /json/)
|
||||
.expect(expectStatus)
|
||||
return res.body
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue