@@ -11,6 +11,11 @@ export interface Policy {
1111 effect : string ;
1212}
1313
14+ export interface Role {
15+ memberReferences : string [ ] ;
16+ name : string ;
17+ }
18+
1419/**
1520 * Thin HTTP client for the RHDH RBAC permission API.
1621 * Uses a static factory (`build`) because the Playwright `APIRequestContext`
@@ -43,10 +48,48 @@ export class RbacApiHelper {
4348 return instance ;
4449 }
4550
51+ // Roles:
52+
53+ public async createRoles ( role : Role ) : Promise < APIResponse > {
54+ return await this . myContext . post ( "roles" , { data : role } ) ;
55+ }
56+
57+ public async getRoles ( ) : Promise < APIResponse > {
58+ return await this . myContext . get ( "roles" ) ;
59+ }
60+
61+ public async updateRole (
62+ role : string ,
63+ oldRole : Role ,
64+ newRole : Role ,
65+ ) : Promise < APIResponse > {
66+ return await this . myContext . put ( `roles/role/default/${ role } ` , {
67+ data : { oldRole, newRole } ,
68+ } ) ;
69+ }
70+
71+ public async deleteRole ( role : string ) : Promise < APIResponse > {
72+ return await this . myContext . delete ( `roles/role/default/${ role } ` ) ;
73+ }
74+
75+ // Policies:
76+
4677 public async getPoliciesByRole ( policy : string ) : Promise < APIResponse > {
4778 return await this . myContext . get ( `policies/role/default/${ policy } ` ) ;
4879 }
4980
81+ public async createPolicies ( policy : Policy [ ] ) : Promise < APIResponse > {
82+ return await this . myContext . post ( "policies" , { data : policy } ) ;
83+ }
84+
85+ public async deletePolicy ( policy : string , policies : Policy [ ] ) {
86+ return await this . myContext . delete ( `policies/role/default/${ policy } ` , {
87+ data : policies ,
88+ } ) ;
89+ }
90+
91+ // Conditions:
92+
5093 /** Fetches all conditional policies across all roles. */
5194 public async getConditions ( ) : Promise < APIResponse > {
5295 return await this . myContext . get ( `roles/conditions` ) ;
@@ -62,16 +105,6 @@ export class RbacApiHelper {
62105 ) ;
63106 }
64107
65- public async deleteRole ( role : string ) : Promise < APIResponse > {
66- return await this . myContext . delete ( `roles/role/default/${ role } ` ) ;
67- }
68-
69- public async deletePolicy ( policy : string , policies : Policy [ ] ) {
70- return await this . myContext . delete ( `policies/role/default/${ policy } ` , {
71- data : policies ,
72- } ) ;
73- }
74-
75108 /** `id` comes from the `RoleConditionalPolicyDecision.id` field returned by the API. */
76109 public async deleteCondition ( id : string ) : Promise < APIResponse > {
77110 return await this . myContext . delete ( `roles/conditions/${ id } ` ) ;
0 commit comments