Skip to content

Commit 5839f02

Browse files
committed
chore(rbac): bump test utils and remove auth and rbac apis
Signed-off-by: Patrick Knight <pknight@redhat.com>
1 parent 8c96554 commit 5839f02

6 files changed

Lines changed: 23 additions & 149 deletions

File tree

workspaces/rbac/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@backstage-community/plugin-rbac-common": "1.23.0",
2626
"@eslint/js": "^9.39.2",
2727
"@playwright/test": "1.57.0",
28-
"@red-hat-developer-hub/e2e-test-utils": "1.1.14",
28+
"@red-hat-developer-hub/e2e-test-utils": "1.1.15",
2929
"@types/node": "^24.10.1",
3030
"dotenv": "^16.4.7",
3131
"eslint": "^9.39.2",

workspaces/rbac/e2e-tests/support/api/rbac-api.ts

Lines changed: 0 additions & 98 deletions
This file was deleted.

workspaces/rbac/e2e-tests/support/api/rhdh-auth-api-hack.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

workspaces/rbac/e2e-tests/support/utils/cleanup.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import { APIResponse } from "@playwright/test";
2-
import RhdhRbacApi, { Policy, Response } from "../../support/api/rbac-api";
32
import { RbacRef } from "../constants/roles";
43
import {
54
PermissionAction,
65
RoleConditionalPolicyDecision,
76
} from "@backstage-community/plugin-rbac-common";
7+
import {
8+
RbacApiHelper,
9+
Policy,
10+
Response,
11+
} from "@red-hat-developer-hub/e2e-test-utils/helpers";
812

913
// Roles that cannot be deleted and will throw a 403 — skip to avoid noise
1014
const SKIPPABLE_ROLES: Set<string> = new Set(["rbac_admin", "guests"]);
1115

1216
async function deletePoliciesForRole(
13-
rbacApi: RhdhRbacApi,
17+
rbacApi: RbacApiHelper,
1418
roleName: string,
1519
policiesResponse: APIResponse,
1620
): Promise<void> {
@@ -22,7 +26,7 @@ async function deletePoliciesForRole(
2226
}
2327

2428
async function deleteConditionsForRole(
25-
rbacApi: RhdhRbacApi,
29+
rbacApi: RbacApiHelper,
2630
conditionResponse: APIResponse,
2731
remainingConditions: RoleConditionalPolicyDecision<PermissionAction>[],
2832
): Promise<void> {
@@ -32,7 +36,10 @@ async function deleteConditionsForRole(
3236
}
3337
}
3438

35-
async function cleanupRole(rbacApi: RhdhRbacApi, role: RbacRef): Promise<void> {
39+
async function cleanupRole(
40+
rbacApi: RbacApiHelper,
41+
role: RbacRef,
42+
): Promise<void> {
3643
const policiesResponse = await rbacApi.getPoliciesByRole(role.name);
3744
const conditionResponse = await rbacApi.getConditions();
3845
const remainingConditions = await rbacApi.getConditionsByRole(
@@ -63,7 +70,7 @@ export async function cleanupRoles(
6370
roles: Record<string, RbacRef>,
6471
apiToken: string,
6572
): Promise<void> {
66-
const rbacApi = await RhdhRbacApi.build(apiToken);
73+
const rbacApi = await RbacApiHelper.build(apiToken);
6774

6875
for (const role of Object.values(roles)) {
6976
if (SKIPPABLE_ROLES.has(role.name)) continue;

workspaces/rbac/e2e-tests/tests/specs/rbac.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
import { $ } from "@red-hat-developer-hub/e2e-test-utils/utils";
1111
import * as path from "node:path";
1212
import { createUsersAndGroups } from "../../support/utils/create-users";
13-
import { RhdhAuthApiHack } from "../../support/api/rhdh-auth-api-hack";
1413
import { cleanupRoles } from "../../support/utils/cleanup";
1514
import {
1615
RBAC_DESCRIPTIVE_USERS,
@@ -21,6 +20,7 @@ import {
2120
import { RBAC_ROLES } from "../../support/constants/roles";
2221
import { loginAs } from "../../support/utils/login";
2322
import {
23+
AuthApiHelper,
2424
LoginHelper,
2525
UIhelper,
2626
} from "@red-hat-developer-hub/e2e-test-utils/helpers";
@@ -77,7 +77,8 @@ test.describe("RBAC plugin", () => {
7777
const uiHelper = new UIhelper(page);
7878
const loginHelper = new LoginHelper(page);
7979
await setupAdminSession({ page, uiHelper, loginHelper });
80-
apiToken = await RhdhAuthApiHack.getToken(page);
80+
const authApiHelper = new AuthApiHelper(page);
81+
apiToken = await authApiHelper.getToken();
8182
await context.close();
8283
});
8384

@@ -569,6 +570,7 @@ test.describe("RBAC plugin", () => {
569570
await loginAs(loginHelper, RBAC_DESCRIPTIVE_USERS.rbacAdmin);
570571

571572
await rbacPO.navigateToRBACPage();
573+
572574
await rbacPO.deleteRole(RBAC_ROLES.rbacOwnership.ref);
573575
});
574576

workspaces/rbac/e2e-tests/yarn.lock

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,11 +296,12 @@ __metadata:
296296
languageName: node
297297
linkType: hard
298298

299-
"@red-hat-developer-hub/e2e-test-utils@npm:1.1.14":
300-
version: 1.1.14
301-
resolution: "@red-hat-developer-hub/e2e-test-utils@npm:1.1.14"
299+
"@red-hat-developer-hub/e2e-test-utils@npm:1.1.15":
300+
version: 1.1.15
301+
resolution: "@red-hat-developer-hub/e2e-test-utils@npm:1.1.15"
302302
dependencies:
303303
"@axe-core/playwright": ^4.11.0
304+
"@backstage-community/plugin-rbac-common": 1.23.0
304305
"@eslint/js": ^9.39.1
305306
"@keycloak/keycloak-admin-client": ^26.0.0
306307
"@kubernetes/client-node": ^1.4.0
@@ -319,7 +320,7 @@ __metadata:
319320
zx: ^8.8.5
320321
peerDependencies:
321322
"@playwright/test": ^1.57.0
322-
checksum: 22264a01c79284deaa18c455b6477b7ea304fca62f2517cf347c1fc51131003d58db383e04bfcc0e8ddbe231d819f9ae0b9ee5497b2b00a2cff56ed70c1a1339
323+
checksum: 9b92ffbec69b77f263c875a9f3edb672fbe165f3cee8f84c5e2e7b9dd2428b693a2eb9b3375f42c0706960dd7ea2d434e7917f2eb5b6a3762d8f80c18a936c70
323324
languageName: node
324325
linkType: hard
325326

@@ -2033,7 +2034,7 @@ __metadata:
20332034
"@backstage-community/plugin-rbac-common": 1.23.0
20342035
"@eslint/js": ^9.39.2
20352036
"@playwright/test": 1.57.0
2036-
"@red-hat-developer-hub/e2e-test-utils": 1.1.14
2037+
"@red-hat-developer-hub/e2e-test-utils": 1.1.15
20372038
"@types/node": ^24.10.1
20382039
dotenv: ^16.4.7
20392040
eslint: ^9.39.2

0 commit comments

Comments
 (0)