Skip to content

Commit 9b2d675

Browse files
committed
feat(orchestrator): Add orchestrator helpers
1 parent 0d3e851 commit 9b2d675

6 files changed

Lines changed: 396 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@red-hat-developer-hub/e2e-test-utils",
3-
"version": "1.1.17",
3+
"version": "1.1.19",
44
"description": "Test utilities for RHDH E2E tests",
55
"license": "Apache-2.0",
66
"repository": {

src/playwright/helpers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export { GITHUB_API_ENDPOINTS } from "./api-endpoints.js";
22
export { APIHelper } from "./api-helper.js";
33
export { LoginHelper, setupBrowser } from "./common.js";
44
export { UIhelper } from "./ui-helper.js";
5-
export { RbacApiHelper, Policy, Response } from "./rbac-api-helper.js";
5+
export { RbacApiHelper, Policy, Role, Response } from "./rbac-api-helper.js";
66
export { AuthApiHelper } from "./auth-api-helper.js";

src/playwright/helpers/rbac-api-helper.ts

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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}`);

src/playwright/pages/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export { CatalogPage } from "./catalog.js";
33
export { ExtensionsPage } from "./extensions.js";
44
export { HomePage } from "./home-page.js";
55
export { NotificationPage } from "./notifications.js";
6+
export { OrchestratorPage } from "./orchestrator.js";

0 commit comments

Comments
 (0)