From 58bfdce774f5b811eb25655a25c4d9233b6063fb Mon Sep 17 00:00:00 2001 From: Nil Gallego Date: Tue, 3 Dec 2024 13:32:47 +0100 Subject: [PATCH] wip --- e2e-tests/playwright.config.ts | 2 +- .../e2e/plugins/rbac/rbac-api.spec.ts | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/e2e-tests/playwright.config.ts b/e2e-tests/playwright.config.ts index d44d24f9ea..6523712197 100644 --- a/e2e-tests/playwright.config.ts +++ b/e2e-tests/playwright.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ timeout: 90 * 1000, testDir: "./playwright", /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, + forbidOnly: false, /* Retry on CI only */ retries: process.env.CI ? 2 : 0, /* Opt out of parallel tests on CI. */ diff --git a/e2e-tests/playwright/e2e/plugins/rbac/rbac-api.spec.ts b/e2e-tests/playwright/e2e/plugins/rbac/rbac-api.spec.ts index 005c8ccc68..1a63152d8f 100644 --- a/e2e-tests/playwright/e2e/plugins/rbac/rbac-api.spec.ts +++ b/e2e-tests/playwright/e2e/plugins/rbac/rbac-api.spec.ts @@ -3,10 +3,9 @@ import { PolicyComplete, Response } from "../../../support/pages/rbac"; import { Common, setupBrowser } from "../../../utils/common"; import { UIhelper } from "../../../utils/ui-helper"; import { RbacConstants } from "../../../data/rbac-constants"; -import { RhdhAuthHack } from "../../../support/api/rhdh-auth-hack"; // TODO: reenable tests -test.describe.serial("Test RBAC plugin REST API", () => { +test.describe.serial.only("Test RBAC plugin REST API", () => { let common: Common; let uiHelper: UIhelper; let page: Page; @@ -23,7 +22,7 @@ test.describe.serial("Test RBAC plugin REST API", () => { common = new Common(page); await common.loginAsGithubUser(); - const apiToken = await RhdhAuthHack.getInstance().getApiToken(page); + const apiToken = process.env.BACKEND_SECRET; responseHelper = new Response(apiToken); }); @@ -46,6 +45,18 @@ test.describe.serial("Test RBAC plugin REST API", () => { responseHelper.getSimpleRequest(), ); + if (!rolesResponse.ok()) { + throw Error( + `RBAC rolesResponse API call failed with status code ${rolesResponse} and body: ${await rolesResponse.json()}`, + ); + } + + if (!policiesResponse.ok()) { + throw Error( + `RBAC rolesResponse API call failed with status code ${policiesResponse} and body: ${await policiesResponse.json()}`, + ); + } + await responseHelper.checkResponse( rolesResponse, RbacConstants.getExpectedRoles(),