Files
serverAppConfigs/tests/deployment_flow.bats
T
Frank da68b5ce1a fix: basicauth double-prefix render; open-webui off slirp4netns
basicauth (2026-08-22 incident):
- the Caddyfile template carried its own $2a$14$ prefix and deploy.sh
  substituted the full hash (prefix included), rendering an invalid
  double-prefixed hash. Every basicauth vhost rejected every password
  with 401 and Caddy logged nothing.
- template is now a bare REPLACE_WITH_HASH token; tests pin the render
  contract (no prefix in template; rendered line is exactly 'dank <hash>').

open-webui (2026-08-22 incident):
- its slirp4netns helper process died, leaving the container running
  with only 'lo' in its netns: port 3005 accepted TCP and reset every
  request, so chat served empty responses for ~2 days, unlogged.
- move to a pinned bridge network (systemd-open-webui, 10.89.3.0/24,
  gw 10.89.3.1) — no per-container helper to die.
- LLM endpoint reached via the gateway (host.containers.internal is
  slirp-only): OPENAI_API_BASE_URL=http://10.89.3.1:52625.
- add a quadlet healthcheck: /health (app) + non-loopback interface
  (network liveness; the dead-tap state leaves only 'lo').
- deploy script now copies the .network file too.
- docs updated (OpenWebUI History section, Caddy basic-auth contract).
2026-08-22 13:07:43 -07:00

53 lines
2.2 KiB
Bash

#!/usr/bin/env bats
# Seam: target reachability and deployment flow integrity.
# These tests assert the deployment contract copied from vllmScripts:
# - a deploy.sh exists and accepts <dankclaw|dankserver> and --dry-run
# - every host referenced in the repo is reachable over SSH (dank@host)
# - the local git remote is configured before deploy is attempted
# Reachability tests are SKIPPED when the target is unreachable so the suite
# still runs during offline development.
load helpers
@test "deploy.sh exists and is executable" {
[ -x "$REPO_ROOT/scripts/deploy.sh" ]
}
@test "deploy.sh accepts the two known targets" {
run bash "$REPO_ROOT/scripts/deploy.sh" --help 2>&1
[ "$status" -eq 0 ] || true
grep -qE 'dankclaw|dankserver' "$REPO_ROOT/scripts/deploy.sh"
}
@test "git remote origin is configured" {
git -C "$REPO_ROOT" remote get-url origin >/dev/null 2>&1 \
|| skip "no origin remote configured yet"
}
@test "dankclaw is reachable over ssh" {
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankclaw 'true' 2>/dev/null \
|| skip "dankclaw not reachable from this host"
}
@test "dankserver is reachable over ssh" {
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankserver 'true' 2>/dev/null \
|| skip "dankserver not reachable from this host"
}
# Regression: the Caddyfile render step in deploy.sh must survive a bcrypt
# hash (which contains '/' characters). Reproduce the sed expression with a
# slash-bearing hash and confirm the placeholder is replaced.
@test "deploy.sh Caddyfile render survives a slash-bearing bcrypt hash" {
local hash='$2a$14$dndiQ9EaycJv0w3Gp2oAYO/xH6O9x2ZRhMLJdCxrgi9rMn1te9D/spy'
local rendered
rendered=$(sed "s|REPLACE_WITH_HASH|${hash}|g" "$REPO_ROOT/dankclaw/Caddyfile")
[ -n "$rendered" ]
[[ "$rendered" == *"${hash}"* ]]
! grep -q 'REPLACE_WITH_HASH' <<< "$rendered"
# The rendered line must be exactly "dank <hash>". A template that keeps
# its own $2a$14$ prefix renders an invalid double-prefixed hash and
# every basicauth vhost returns 401 (2026-08-22 incident).
grep -qF "dank ${hash}" <<< "$rendered"
! grep -qF '$2a$14$$2a$14$' <<< "$rendered"
}