Skip to content

Commit

Permalink
sync with main
Browse files Browse the repository at this point in the history
  • Loading branch information
nilgaar committed Nov 14, 2024
1 parent 5008c37 commit d91591b
Showing 1 changed file with 40 additions and 6 deletions.
46 changes: 40 additions & 6 deletions e2e-tests/playwright/e2e/plugins/rbac/rbac-plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,48 @@ test.describe
uiHelper = new UIhelper(page);
common = new Common(page);
await common.loginAsGithubUser();
await uiHelper.openSidebarButton("Administration");
await uiHelper.openSidebar("RBAC");
await uiHelper.verifyHeading("RBAC");
});

test.beforeEach(
async () => await new Common(page).checkAndClickOnGHloginPopup(),
);
test.beforeEach(async () => {
await page.goto("/rbac");
await new Common(page).checkAndClickOnGHloginPopup();
});

test("Should download the user list", async () => {
await page.locator('a:has-text("Download User List")').click();
const fileContent = await downloadAndReadFile(page);
const lines = fileContent.trim().split("\n");

const header = "userEntityRef,displayName,email,lastAuthTime";
if (lines[0] !== header) {
throw new Error("Header does not match");
}

// Check that each subsequent line starts with "user:default"
const allUsersValid = lines
.slice(1)
.every((line) => line.startsWith("user:default"));
if (!allUsersValid) {
throw new Error("Not all users info are valid");
}
});

async function downloadAndReadFile(page: Page): Promise<string | undefined> {
const [download] = await Promise.all([
page.waitForEvent("download"),
page.locator('a:has-text("Download User List")').click(),
]);

const filePath = await download.path();

if (filePath) {
const fileContent = await fs.readFile(filePath, "utf-8");
return fileContent;
} else {
console.error("Download failed or path is not available");
return undefined;
}
}

test("Check if permission policies defined in files are loaded and effective", async () => {
const testRole: string = "role:default/test2-role";
Expand Down

0 comments on commit d91591b

Please sign in to comment.