Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
vendor
GEMINI.md
docs
e2e
data
who
whoami
Expand Down
61 changes: 60 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,67 @@ jobs:
- name: Run Go tests
run: go test -race -v ./...

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Enable pnpm
env:
COREPACK_ENABLE_DOWNLOAD_PROMPT: "0"
run: corepack enable && corepack prepare pnpm@10.33.0 --activate

- name: Run UI checks
run: pnpm --dir ui install --frozen-lockfile && pnpm --dir ui run check

e2e:
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Enable pnpm
env:
COREPACK_ENABLE_DOWNLOAD_PROMPT: "0"
run: corepack enable && corepack prepare pnpm@10.33.0 --activate

- name: Install E2E dependencies
run: pnpm --dir e2e install --frozen-lockfile

- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('e2e/pnpm-lock.yaml') }}

- name: Install Playwright Chromium
run: pnpm --dir e2e exec playwright install --with-deps chromium

- name: Run E2E tests
run: bash e2e/scripts/run.sh

- name: Upload E2E diagnostics on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-diagnostics
path: |
e2e/playwright-report
e2e/test-results
e2e/.generated/compose-logs.txt
if-no-files-found: ignore

build-and-push:
needs: [test]
needs: [test, e2e]
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ config.json
*.db-wal
.claude
docs/
e2e/node_modules/
e2e/.generated/
e2e/.auth/
e2e/playwright-report/
e2e/test-results/
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: default ui check test build image
.PHONY: default ui check test build image e2e e2e-up e2e-down

IMAGE_NAME := ghcr.io/tracyhatemice/who

Expand All @@ -18,3 +18,12 @@ check:

image:
docker build -t $(IMAGE_NAME) .

e2e:
bash e2e/scripts/run.sh

e2e-up:
bash e2e/scripts/run.sh --up-only

e2e-down:
bash e2e/scripts/run.sh --down-only
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Every CLI flag has a matching `WHO_*` environment variable (CLI flags take prece
| `--data-dir` | `WHO_DATA_DIR` | `./data` (`/data` in Docker) | Directory holding the `who.db` SQLite database |
| `--config` | `WHO_CONFIG` | *(empty)* | Optional seed `config.json` imported once when `who.db` is empty |
| `--base-path` | `WHO_BASE_PATH` | `/` | Sub-path prefix for Admin UI, `/auth/*`, and `/api/v1/*` (e.g. `/admin`) |
| `--ddns-endpoint` | `WHO_DDNS_ENDPOINT` | *(empty)* | Optional DDNS provider endpoint override (defaults to AWS Route53; used for local/E2E mock endpoints) |
| `--oidc-issuer` | `WHO_OIDC_ISSUER` | *(empty)* | OIDC provider issuer URL (e.g. Pocket ID, Authelia, Authentik, Keycloak) |
| `--oidc-client-id` | `WHO_OIDC_CLIENT_ID` | *(empty)* | OIDC relying-party client ID |
| `--oidc-client-secret` | `WHO_OIDC_CLIENT_SECRET` | *(empty)* | OIDC client secret (optional for public PKCE clients) |
Expand Down Expand Up @@ -317,3 +318,29 @@ $ make
# Build container image locally
$ make image
```

## End-to-End Testing (`make e2e`)

The `e2e/` workspace runs full-stack browser and API verification with Playwright Chromium against a self-contained Docker Compose stack (`e2e/docker-compose.yml`):

- **Traefik (`traefik:v3.6`)**: TLS termination on `https://app.who.localhost:18443` and `https://auth.who.localhost:18443` using ephemerally generated CA and server certificates in `e2e/.generated/`.
- **GLAuth (`ghcr.io/glauth/glauth:v2.5.4`)**: Lightweight LDAP directory backing `admin@who.localhost` and `denied@who.localhost`.
- **Authelia (`authelia/authelia:4.39`)**: OIDC Identity Provider (Authorization Code + `S256` PKCE + `UserInfo`) backed by GLAuth and generated RSA JWKS.
- **`who` (built from root `Dockerfile`)**: Configured with `WHO_BASE_PATH=/who`, `WHO_OIDC_ALLOWED_EMAILS=admin@who.localhost`, and `WHO_DDNS_ENDPOINT=http://mock-sink:9999`.
- **`mock-sink` (`node:24-alpine`)**: HTTP sink capturing outbound Route53 XML `UPSERT` requests and webhook deliveries on `http://127.0.0.1:19999`.

```console
# One-time Playwright setup (installs e2e deps and Chromium browser binary)
$ pnpm --dir e2e install --frozen-lockfile
$ pnpm --dir e2e exec playwright install --with-deps chromium

# Cold-boot the full Compose stack, run all 5 Playwright projects, and tear down cleanly
$ make e2e

# Keep stack running while iterating on individual Playwright specs
$ make e2e-up
$ NODE_EXTRA_CA_CERTS="$PWD/e2e/.generated/certs/ca.crt" pnpm --dir e2e exec playwright test tests/mobile-layout.spec.mjs
$ make e2e-down
```

GitHub Actions (`.github/workflows/docker-build.yml`) runs both `test` (`go test -race -v ./...` and `pnpm --dir ui run check`) and `e2e` (`bash e2e/scripts/run.sh`, uploading `e2e/playwright-report`, `e2e/test-results`, and `e2e/.generated/compose-logs.txt` on failure) before `build-and-push`.
67 changes: 67 additions & 0 deletions e2e/authelia/configuration.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
theme: 'light'

server:
address: 'tcp://:9091'

log:
level: 'info'

identity_validation:
reset_password:
jwt_secret: 'e2e-reset-password-jwt-secret-0123456789abcdef'

authentication_backend:
password_reset:
disable: true
ldap:
implementation: 'glauth'
address: 'ldap://glauth:3893'
base_dn: 'dc=who,dc=localhost'
user: 'cn=authelia,ou=svcaccts,dc=who,dc=localhost'
password: 'BindPass123!'
users_filter: '(&(|({username_attribute}={input})({mail_attribute}={input}))(objectClass=posixAccount))'

session:
secret: 'e2e-session-secret-0123456789abcdef0123456789'
cookies:
- domain: 'who.localhost'
authelia_url: 'https://auth.who.localhost:18443'
default_redirection_url: 'https://app.who.localhost:18443/who/'

storage:
encryption_key: 'e2e-storage-encryption-key-0123456789abcdef01'
local:
path: '/tmp/authelia.sqlite3'

notifier:
disable_startup_check: true
filesystem:
filename: '/tmp/authelia-notification.txt'

access_control:
default_policy: 'one_factor'

identity_providers:
oidc:
hmac_secret: 'e2e-oidc-hmac-secret-0123456789abcdef0123456789'
jwks:
- algorithm: 'RS256'
use: 'sig'
key: |
{{JWKS_PEM_INDENTED}}
clients:
- client_id: 'who-e2e'
client_name: 'who E2E'
client_secret: '{{CLIENT_SECRET_HASH}}'
public: false
authorization_policy: 'one_factor'
consent_mode: 'implicit'
require_pkce: true
pkce_challenge_method: 'S256'
redirect_uris:
- 'https://app.who.localhost:18443/who/auth/oidc/callback'
scopes:
- 'openid'
- 'profile'
- 'email'
token_endpoint_auth_method: 'client_secret_basic'
94 changes: 94 additions & 0 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: who-e2e

networks:
e2e:
driver: bridge

services:
traefik:
image: traefik:v3.6
ports:
- "127.0.0.1:18443:18443"
volumes:
- ./traefik/traefik.yml:/etc/traefik/traefik.yml:ro
- ./traefik/dynamic.yml:/etc/traefik/dynamic.yml:ro
- ./.generated/certs:/certs:ro
networks:
e2e:
aliases:
- app.who.localhost
- auth.who.localhost
depends_on:
- who
- authelia

glauth:
image: ghcr.io/glauth/glauth:v2.5.4
command: ["/app/glauth", "-c", "/app/config/config.cfg"]
volumes:
- ./glauth/glauth.cfg:/app/config/config.cfg:ro
networks:
- e2e

authelia:
image: authelia/authelia:4.39
command: ["authelia", "--config", "/config/configuration.yml"]
environment:
X_AUTHELIA_HEALTHCHECK: "1"
volumes:
- ./.generated/authelia-config.yml:/config/configuration.yml:ro
depends_on:
- glauth
restart: on-failure:5
healthcheck:
test: ["CMD-SHELL", "/app/healthcheck.sh"]
interval: 2s
timeout: 3s
retries: 20
start_period: 3s
networks:
- e2e

mock-sink:
image: node:24-alpine
command: ["node", "/app/server.mjs"]
environment:
PORT: "9999"
ports:
- "127.0.0.1:19999:9999"
volumes:
- ./mock-sink/server.mjs:/app/server.mjs:ro
healthcheck:
test:
[
"CMD",
"node",
"-e",
"fetch('http://127.0.0.1:9999/healthz').then((r)=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))",
]
interval: 2s
timeout: 3s
retries: 15
networks:
- e2e

who:
build:
context: ..
dockerfile: Dockerfile
environment:
WHO_VERBOSE: "1"
WHO_BASE_PATH: /who
WHO_OIDC_ISSUER: https://auth.who.localhost:18443
WHO_OIDC_CLIENT_ID: who-e2e
WHO_OIDC_CLIENT_SECRET: who-e2e-client-secret-0123456789
WHO_OIDC_REDIRECT_URL: https://app.who.localhost:18443/who/auth/oidc/callback
WHO_OIDC_ALLOWED_EMAILS: admin@who.localhost
WHO_DDNS_ENDPOINT: http://mock-sink:9999
SSL_CERT_FILE: /certs/ca.crt
volumes:
- ./.generated/certs/ca.crt:/certs/ca.crt:ro
- ./.generated/who-data:/data
- ./.generated/touch:/touch
networks:
- e2e
58 changes: 58 additions & 0 deletions e2e/glauth/glauth.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
debug = false

[ldap]
enabled = true
listen = "0.0.0.0:3893"
tls = false

[ldaps]
enabled = false

[api]
enabled = false

[behaviors]
IgnoreCapabilities = false
LimitFailedBinds = false

[backend]
datastore = "config"
baseDN = "dc=who,dc=localhost"
nameformat = "cn"
groupformat = "ou"
anonymousdse = true

[[groups]]
name = "svcaccts"
gidnumber = 5501

[[groups]]
name = "users"
gidnumber = 5502

[[users]]
name = "authelia"
uidnumber = 5001
primarygroup = 5501
passsha256 = "1c47e1c50ce3ebe4d4b46a444229ab3b94743b08d5f5367e23db48d4474c1c29"
[[users.capabilities]]
action = "search"
object = "dc=who,dc=localhost"

[[users]]
name = "admin"
givenname = "Admin"
sn = "User"
mail = "admin@who.localhost"
uidnumber = 5002
primarygroup = 5502
passsha256 = "a44ca5d29f6dab4320ab986479fa985b2d584b11a7da934f7e80bb1449913a07"

[[users]]
name = "denied"
givenname = "Denied"
sn = "User"
mail = "denied@who.localhost"
uidnumber = 5003
primarygroup = 5502
passsha256 = "5dc5fc273b31346ca6edff628469eb9ba0e67e381b9237f1791364c0d356e5fb"
Loading
Loading