Skip to content

Commit bf41766

Browse files
author
Triona Doyle
committed
Add login via local credentials test
Signed-off-by: Triona Doyle <bot@example.com>
1 parent efde789 commit bf41766

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { test, expect } from '@playwright/test';
2+
import { execSync } from 'node:child_process';
3+
4+
test('Log into Argo CD as local admin', async ({ browser }) => {
5+
const rawOutput = execSync(
6+
'oc extract secret/openshift-gitops-cluster -n openshift-gitops --keys=admin.password --to=-'
7+
).toString();
8+
9+
//get credentials
10+
const password = rawOutput.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#'))[0];
11+
12+
const routeUrl = execSync(
13+
'oc get route openshift-gitops-server -n openshift-gitops -o jsonpath="{.spec.host}"'
14+
).toString().trim();
15+
16+
//Fresh context to avoid any cached state issues
17+
const context = await browser.newContext({
18+
storageState: { cookies: [], origins: [] },
19+
ignoreHTTPSErrors: true
20+
});
21+
22+
//Navigate and wait for the page to be loaded
23+
const page = await context.newPage();
24+
const loginUrl = `https://${routeUrl}/login?dex=none`;
25+
await page.goto(loginUrl, { waitUntil: 'load' });
26+
27+
const userField = page.getByRole('textbox').first();
28+
await userField.waitFor({ state: 'visible', timeout: 20000 });
29+
30+
//Fill and Sign In
31+
await userField.fill('admin');
32+
await page.locator('input[type="password"]').fill(password);
33+
await page.getByRole('button', { name: /sign in/i }).click();
34+
35+
//Verify we're logged in
36+
await expect(page.locator('.sidebar, [data-testid="sidebar"]').first()).toBeVisible({ timeout: 20000 });
37+
38+
await context.close();
39+
});

0 commit comments

Comments
 (0)