Skip to content

Commit dcd3ed8

Browse files
committed
WIP
1 parent c33f33a commit dcd3ed8

File tree

7 files changed

+17
-47
lines changed

7 files changed

+17
-47
lines changed

.env.example

-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ DATABASE_URL=
1313
# API URL
1414
NEXT_PUBLIC_API_URL=http://localhost:5000/api/
1515

16-
##########################################################################
17-
# Compulsory when running Playwright tests:
18-
##########################################################################
19-
# E2E test user credentials
20-
E2E_USER_USERNAME=
21-
E2E_USER_PASSWORD=
22-
2316
##########################################################################
2417
# Compulsory in production (aka when NODE_ENV=production):
2518
##########################################################################

.github/workflows/playwright.yml

-8
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ jobs:
1717
environment: test-environment
1818
env:
1919
DATABASE_URL: ${{ vars.DATABASE_URL }}
20-
E2E_USER_USERNAME: ${{ secrets.E2E_USER_USERNAME }}
21-
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
22-
KEYCLOAK_URL: ${{ vars.KEYCLOAK_URL }}
23-
KEYCLOAK_REALM: ${{ secrets.KEYCLOAK_REALM }}
24-
KEYCLOAK_CLIENT_ID_UI: ${{ secrets.KEYCLOAK_CLIENT_ID_UI }}
25-
KEYCLOAK_CLIENT_SECRET_UI: ${{ secrets.KEYCLOAK_CLIENT_SECRET_UI }}
26-
KEYCLOAK_CLIENT_ID_API: ${{ secrets.KEYCLOAK_CLIENT_ID_API }}
27-
KEYCLOAK_CLIENT_SECRET_API: ${{ secrets.KEYCLOAK_CLIENT_SECRET_API }}
2820
NEXTAUTH_URL: http://localhost:3000
2921
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
3022
NEXT_PUBLIC_API_URL: http://localhost:3001/api/

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ To run this project you will need Node.js, npm and Docker installed.
4242

4343
```shell
4444
DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres
45-
E2E_USER_USERNAME=
46-
E2E_USER_PASSWORD=
4745
```
4846

4947
See [.env.example](https://github.com/doubleopen-project/dos/blob/main/.env.example) file for other non-compulsory configurable variables.

apps/api/tests/e2e/api.spec.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,20 @@ import {
1111
import test, { expect } from "@playwright/test";
1212
import { Zodios, ZodiosInstance } from "@zodios/core";
1313
import AdmZip from "adm-zip";
14+
import { authConfig } from "common-helpers";
1415
import { getPresignedPutUrl, S3Client } from "s3-helpers";
1516
import { dosAPI, userAPI } from "validation-helpers";
1617

1718
/**
1819
* Construct Zodios callers for the API endpoints to easily call them in the tests.
1920
*/
2021

21-
const server = process.env.KEYCLOAK_URL;
22-
const realm = process.env.KEYCLOAK_REALM;
23-
const clientId = process.env.KEYCLOAK_CLIENT_ID_API;
24-
const clientSecret = process.env.KEYCLOAK_CLIENT_SECRET_API;
25-
const username = process.env.E2E_USER_USERNAME;
26-
const password = process.env.E2E_USER_PASSWORD;
27-
28-
if (!server || !realm || !clientId || !clientSecret || !username || !password) {
29-
throw new Error(
30-
"KEYCLOAK_URL, KEYCLOAK_REALM, KEYCLOAK_CLIENT_ID_API, KEYCLOAK_CLIENT_SECRET_API, E2E_USER_USERNAME and E2E_USER_PASSWORD environment variables must be set",
31-
);
32-
}
22+
const server = authConfig.url;
23+
const realm = authConfig.realm;
24+
const clientId = authConfig.clientIdAPI;
25+
const clientSecret = authConfig.clientSecretAPI;
26+
const username = "test-user";
27+
const password = "test-user";
3328

3429
const s3Client = S3Client(
3530
process.env.NODE_ENV !== "production",

apps/clearance_ui/tests/e2e/global.setup.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import { expect, test as setup } from "@playwright/test";
66
import { STORAGE_STATE } from "../../playwright.config";
77

88
setup("logs in", async ({ page }) => {
9-
if (!process.env.E2E_USER_USERNAME || !process.env.E2E_USER_PASSWORD) {
10-
throw new Error(
11-
"E2E_USER_USERNAME and E2E_USER_PASSWORD environment variables must be set",
12-
);
13-
}
149
// Clear old session cookie from the browser
1510
await page.goto("/api/auth/signout");
1611

@@ -24,8 +19,8 @@ setup("logs in", async ({ page }) => {
2419
await page.click("button:has-text('Sign in with Keycloak')");
2520

2621
// Fill the login form
27-
await page.fill("#username", process.env.E2E_USER_USERNAME);
28-
await page.fill("#password", process.env.E2E_USER_PASSWORD);
22+
await page.fill("#username", "test-user");
23+
await page.fill("#password", "test-user");
2924

3025
// Submit login form
3126
await page.click('button[type="submit"]');

docker-compose.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ services:
112112
- 3001:3001
113113
environment:
114114
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
115-
- KEYCLOAK_URL=$KEYCLOAK_URL
116-
- KEYCLOAK_REALM=$KEYCLOAK_REALM
117-
- KEYCLOAK_CLIENT_ID_API=$KEYCLOAK_CLIENT_ID_API
118-
- KEYCLOAK_CLIENT_SECRET_API=$KEYCLOAK_CLIENT_SECRET_API
115+
- KEYCLOAK_URL=http://keycloak:8080
119116
- ALLOWED_ORIGINS=http://localhost:3002,http://localhost:3000
120117
- SPACES_ENDPOINT=http://minio:9000
121118
- REDIS_URL=redis://redis:6379
@@ -138,6 +135,12 @@ services:
138135
minio:
139136
condition: service_healthy
140137
required: true
138+
keycloak:
139+
condition: service_healthy
140+
required: true
141+
terraform:
142+
condition: service_completed_successfully
143+
required: true
141144

142145
scanner-worker:
143146
build:
@@ -158,11 +161,7 @@ services:
158161
environment:
159162
- NEXTAUTH_URL=http://localhost:3002
160163
- NEXTAUTH_SECRET=$NEXTAUTH_SECRET
161-
- KEYCLOAK_URL=$KEYCLOAK_URL
162-
- KEYCLOAK_CLIENT_ID_UI=$KEYCLOAK_CLIENT_ID_UI
163-
- KEYCLOAK_CLIENT_ID_API=$KEYCLOAK_CLIENT_ID_API
164-
- KEYCLOAK_CLIENT_SECRET_UI=$KEYCLOAK_CLIENT_SECRET_UI
165-
- KEYCLOAK_REALM=dos-dev
164+
- KEYCLOAK_URL=http://keycloak:8080
166165
ports:
167166
- 3002:3000
168167

turbo.json

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
"DB_RETRY_INTERVAL",
1212
"DEBUG",
1313
"DL_CONCURRENCY",
14-
"E2E_USER_USERNAME",
15-
"E2E_USER_PASSWORD",
1614
"KEYCLOAK_CLIENT_ID_API",
1715
"KEYCLOAK_CLIENT_ID_UI",
1816
"KEYCLOAK_CLIENT_SECRET_API",

0 commit comments

Comments
 (0)