Files
serverAppConfigs/tests/homepage_caddy.bats
T
Frank 25af3d9fdf Caddyfile: fix the /admin/ rewrite (matcher follows the directive)
'@admin rewrite ...' is parsed as a one-liner matcher DEFINITION, so it
re-defined @admin and Caddy rejected the config ('matcher is defined more
than once'), crash-looping the container. Per the Caddyfile matcher docs the
matcher token is the first ARGUMENT after the directive: 'rewrite @admin
/admin.html'. The '*' disambiguator is only needed pre-2.8.0. Validated the
rendered config against the porkbun image: 'Valid configuration'.
2026-08-23 17:42:44 -07:00

34 lines
1.2 KiB
Bash

#!/usr/bin/env bats
# Seam: the homepage site block in dankclaw/Caddyfile. It must carry a root
# basicauth hash and a distinct /admin/-scoped admin hash (Q18/Q19), and serve
# /srv/homepage. caddy is not on the dev box, so the tests assert the
# structure statically; the deploy renders the two real hashes from the .env.
load helpers
setup() {
CADDY="$REPO_ROOT/dankclaw/Caddyfile"
}
@test "the homepage has a root hash and a distinct admin hash (Q18/Q38)" {
grep -q "REPLACE_WITH_HASH" "$CADDY"
grep -q "REPLACE_WITH_ADMIN_HASH" "$CADDY"
}
@test "the admin basicauth is scoped to /admin/ (Q19)" {
grep -qE "@admin[[:space:]]+path[[:space:]]+/admin/" "$CADDY"
grep -qE "basicauth[[:space:]]+@admin" "$CADDY"
}
@test "the homepage serves /srv/homepage" {
grep -q "root \* /srv/homepage" "$CADDY"
grep -q "file_server" "$CADDY"
}
@test "the /admin/ path is rewritten to admin.html" {
# The matcher token follows the directive (rewrite @admin ...), per the
# Caddyfile matcher docs. A leading '@admin rewrite' is parsed as a
# one-liner matcher DEFINITION and re-defines @admin (invalid).
grep -qE "rewrite[[:space:]]+@admin[[:space:]]+/admin.html" "$CADDY"
}