Skip to content

Commit de808c5

Browse files
authored
Fix Playwright docker (#6206)
1 parent 1f73630 commit de808c5

File tree

8 files changed

+34
-41
lines changed

8 files changed

+34
-41
lines changed

playwright/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,25 @@ When creating new scenario use the recorder to more easily identify elements
9191
This does not start the server, you will need to start it manually.
9292

9393
```bash
94-
npx playwright codegen "http://127.0.0.1:8000"
94+
DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env up Vaultwarden
95+
npx playwright codegen "http://127.0.0.1:8003"
9596
```
9697

9798
## Override web-vault
9899

99100
It is possible to change the `web-vault` used by referencing a different `bw_web_builds` commit.
100101

102+
Simplest is to set and uncomment `PW_WV_REPO_URL` and `PW_WV_COMMIT_HASH` in the `test.env`.
103+
Ensure that the image is built with:
104+
105+
```bash
106+
DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env build Vaultwarden
107+
```
108+
109+
You can check the result running:
110+
101111
```bash
102-
export PW_WV_REPO_URL=https://github.com/Timshel/oidc_web_builds.git
103-
export PW_WV_COMMIT_HASH=8707dc76df3f0cceef2be5bfae37bb29bd17fae6
104-
DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env build Playwright
112+
DOCKER_BUILDKIT=1 docker compose --profile playwright --env-file test.env up Vaultwarden
105113
```
106114

107115
# OpenID Connect test setup

playwright/compose/warden/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM playwright_oidc_vaultwarden_prebuilt AS prebuilt
22

3-
FROM node:22-bookworm AS build
3+
FROM node:22-trixie AS build
44

55
ARG REPO_URL
66
ARG COMMIT_HASH
@@ -14,7 +14,7 @@ COPY build.sh /build.sh
1414
RUN /build.sh
1515

1616
######################## RUNTIME IMAGE ########################
17-
FROM docker.io/library/debian:bookworm-slim
17+
FROM docker.io/library/debian:trixie-slim
1818

1919
ENV DEBIAN_FRONTEND=noninteractive
2020

@@ -24,7 +24,7 @@ RUN mkdir /data && \
2424
--no-install-recommends \
2525
ca-certificates \
2626
curl \
27-
libmariadb-dev-compat \
27+
libmariadb-dev \
2828
libpq5 \
2929
openssl && \
3030
rm -rf /var/lib/apt/lists/*

playwright/compose/warden/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if [[ ! -z "$REPO_URL" ]] && [[ ! -z "$COMMIT_HASH" ]] ; then
1616

1717
export VAULT_VERSION=$(cat Dockerfile | grep "ARG VAULT_VERSION" | cut -d "=" -f2)
1818
./scripts/checkout_web_vault.sh
19-
./scripts/patch_web_vault.sh
2019
./scripts/build_web_vault.sh
2120
printf '{"version":"%s"}' "$COMMIT_HASH" > ./web-vault/apps/web/build/vw-version.json
2221

playwright/playwright.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export default defineConfig({
2626
* But short action/nav/expect timeouts to fail on specific step (raise locally if not enough).
2727
*/
2828
timeout: 120 * 1000,
29-
actionTimeout: 10 * 1000,
30-
navigationTimeout: 10 * 1000,
31-
expect: { timeout: 10 * 1000 },
29+
actionTimeout: 20 * 1000,
30+
navigationTimeout: 20 * 1000,
31+
expect: { timeout: 20 * 1000 },
3232

3333
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3434
use: {

playwright/test.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ SSO_CLIENT_SECRET=warden
6666
SSO_AUTHORITY=http://${KC_HTTP_HOST}:${KC_HTTP_PORT}/realms/${TEST_REALM}
6767
SSO_DEBUG_TOKENS=true
6868

69+
# Custom web-vault build
70+
# PW_WV_REPO_URL=https://github.com/dani-garcia/bw_web_builds.git
71+
# PW_WV_COMMIT_HASH=a5f5390895516bce2f48b7baadb6dc399e5fe75a
72+
6973
###########################
7074
# Docker MariaDb container#
7175
###########################

playwright/tests/setups/sso.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@ export async function logNewUser(
1212
test: Test,
1313
page: Page,
1414
user: { email: string, name: string, password: string },
15-
options: { mailBuffer?: MailBuffer, override?: boolean } = {}
15+
options: { mailBuffer?: MailBuffer } = {}
1616
) {
1717
await test.step(`Create user ${user.name}`, async () => {
1818
await page.context().clearCookies();
1919

2020
await test.step('Landing page', async () => {
2121
await utils.cleanLanding(page);
2222

23-
if( options.override ) {
24-
await page.getByRole('button', { name: 'Continue' }).click();
25-
} else {
26-
await page.getByLabel(/Email address/).fill(user.email);
27-
await page.getByRole('button', { name: /Use single sign-on/ }).click();
28-
}
23+
await page.locator("input[type=email].vw-email-sso").fill(user.email);
24+
await page.getByRole('button', { name: /Use single sign-on/ }).click();
2925
});
3026

3127
await test.step('Keycloak login', async () => {
@@ -69,7 +65,6 @@ export async function logUser(
6965
user: { email: string, password: string },
7066
options: {
7167
mailBuffer ?: MailBuffer,
72-
override?: boolean,
7368
totp?: OTPAuth.TOTP,
7469
mail2fa?: boolean,
7570
} = {}
@@ -82,12 +77,8 @@ export async function logUser(
8277
await test.step('Landing page', async () => {
8378
await utils.cleanLanding(page);
8479

85-
if( options.override ) {
86-
await page.getByRole('button', { name: 'Continue' }).click();
87-
} else {
88-
await page.getByLabel(/Email address/).fill(user.email);
89-
await page.getByRole('button', { name: /Use single sign-on/ }).click();
90-
}
80+
await page.locator("input[type=email].vw-email-sso").fill(user.email);
81+
await page.getByRole('button', { name: /Use single sign-on/ }).click();
9182
});
9283

9384
await test.step('Keycloak login', async () => {

playwright/tests/sso_login.spec.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ test('SSO login', async ({ page }) => {
2929
test('Non SSO login', async ({ page }) => {
3030
// Landing page
3131
await page.goto('/');
32-
await page.getByLabel(/Email address/).fill(users.user1.email);
33-
await page.getByRole('button', { name: 'Continue' }).click();
32+
await page.locator("input[type=email].vw-email-sso").fill(users.user1.email);
33+
await page.getByRole('button', { name: 'Other' }).click();
3434

3535
// Unlock page
3636
await page.getByLabel('Master password').fill(users.user1.password);
@@ -58,20 +58,12 @@ test('Non SSO login impossible', async ({ page, browser }, testInfo: TestInfo) =
5858

5959
// Landing page
6060
await page.goto('/');
61-
await page.getByLabel(/Email address/).fill(users.user1.email);
6261

6362
// Check that SSO login is available
6463
await expect(page.getByRole('button', { name: /Use single sign-on/ })).toHaveCount(1);
6564

66-
await page.getByLabel(/Email address/).fill(users.user1.email);
67-
await page.getByRole('button', { name: 'Continue' }).click();
68-
69-
// Unlock page
70-
await page.getByLabel('Master password').fill(users.user1.password);
71-
await page.getByRole('button', { name: 'Log in with master password' }).click();
72-
73-
// An error should appear
74-
await page.getByLabel('SSO sign-in is required')
65+
// No Continue/Other
66+
await expect(page.getByRole('button', { name: 'Other' })).toHaveCount(0);
7567
});
7668

7769

@@ -82,13 +74,12 @@ test('No SSO login', async ({ page }, testInfo: TestInfo) => {
8274

8375
// Landing page
8476
await page.goto('/');
85-
await page.getByLabel(/Email address/).fill(users.user1.email);
8677

8778
// No SSO button (rely on a correct selector checked in previous test)
88-
await page.getByLabel('Master password');
8979
await expect(page.getByRole('button', { name: /Use single sign-on/ })).toHaveCount(0);
9080

9181
// Can continue to Master password
82+
await page.getByLabel(/Email address/).fill(users.user1.email);
9283
await page.getByRole('button', { name: 'Continue' }).click();
93-
await expect(page.getByRole('button', { name: /Log in with master password/ })).toHaveCount(1);
84+
await expect(page.getByRole('button', { name: 'Log in with master password' })).toHaveCount(1);
9485
});

playwright/tests/sso_organization.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test('Enforce password policy', async ({ page }) => {
6565
await utils.logout(test, page, users.user1);
6666

6767
await test.step(`Unlock trigger policy`, async () => {
68-
await page.getByRole('textbox', { name: 'Email address (required)' }).fill(users.user1.email);
68+
await page.locator("input[type=email].vw-email-sso").fill(users.user1.email);
6969
await page.getByRole('button', { name: 'Use single sign-on' }).click();
7070

7171
await page.getByRole('textbox', { name: 'Master password (required)' }).fill(users.user1.password);

0 commit comments

Comments
 (0)