From 2aa8d661270cbeea946a0e5cfd774922e647a4e9 Mon Sep 17 00:00:00 2001 From: mnovak Date: Tue, 17 Nov 2026 21:35:34 +0100 Subject: [PATCH] [control] The admin host is accepted with any port (Docker or a router may publish 443 elsewhere); smoke scripts: Windows-readable paths, curl without Schannel's revocation check, logs on failure --- crates/control/src/api/mod.rs | 11 ++++++++--- scripts/smoke-docker.sh | 14 ++++++++------ scripts/smoke-linux.sh | 11 ++++++++--- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/crates/control/src/api/mod.rs b/crates/control/src/api/mod.rs index b532bc6..1ca33bb 100644 --- a/crates/control/src/api/mod.rs +++ b/crates/control/src/api/mod.rs @@ -357,11 +357,16 @@ pub(crate) fn host_allowed(ctl: &Control, headers: &HeaderMap) -> bool { format!("127.0.0.1:{port}"), format!("[::1]:{port}"), ]; - // The admin host edge forwards the UI on, with or without edge's HTTPS port. + // The admin host the engine forwards the UI on, with any port: behind Docker's or a + // router's port mapping the visitor's port is not the engine's (T4). The name is what + // keeps a rebound DNS name out. let ui = ctl.cfg.ui.as_ref().and_then(|u| u.hostname.as_deref()); let ui_ok = ui.is_some_and(|u| { - let edge_port = ctl.cfg.compile.https_listen.port(); - host.eq_ignore_ascii_case(u) || host.eq_ignore_ascii_case(&format!("{u}:{edge_port}")) + let name = match host.rsplit_once(':') { + Some((n, p)) if !p.is_empty() && p.bytes().all(|c| c.is_ascii_digit()) => n, + _ => host, + }; + name.eq_ignore_ascii_case(u) }); ui_ok || ok.iter().any(|o| o.eq_ignore_ascii_case(host)) diff --git a/scripts/smoke-docker.sh b/scripts/smoke-docker.sh index 01a276d..35649f1 100644 --- a/scripts/smoke-docker.sh +++ b/scripts/smoke-docker.sh @@ -15,7 +15,7 @@ set -euo pipefail export MSYS_NO_PATHCONV=1 MSYS2_ENV_CONV_EXCL='*' IMAGE=$1 CTL=$2 WORK=$3 -REPO=$(cd "$(dirname "$0")/.." && pwd) +REPO=$(cd "$(dirname "$0")/.." && (pwd -W 2>/dev/null || pwd)) P=ianitor-smoke export COMPOSE_PROJECT_NAME=$P IANITOR_IMAGE=$IMAGE IANITOR_HTTP_PORT=28080 IANITOR_HTTPS_PORT=28443 export IANITOR_ADMIN_HOST=ianitor.smoke.test IANITOR_TLS=domi IANITOR_DOMI_ROOT=/var/lib/ianitor/domi-root.crt @@ -23,7 +23,7 @@ export IANITOR_PREVIEW_DOMAIN=pv.smoke.test IANITOR_PREVIEW_UPSTREAMS=app:8080 DC=(docker compose -f "$REPO/deploy/docker/compose.yaml") step() { echo "== $*"; } ok() { echo " ok: $*"; } -fail() { echo "FAILED: $*" >&2; exit 1; } +fail() { echo "FAILED: $*" >&2; "${DC[@]}" logs --tail 40 control edge >&2 2>&1 || true; exit 1; } cleanup() { "${DC[@]}" down -v --remove-orphans >/dev/null 2>&1 || true docker rm -f $P-app >/dev/null 2>&1 || true @@ -32,6 +32,8 @@ cleanup() { trap cleanup EXIT [ ! -e "$WORK" ] || fail "$WORK exists; give a new folder" mkdir -p "$WORK" +# A drive path (F:/…) on Windows, which both Git Bash and the Windows ianitor-control read. +WORK=$(cd "$WORK" && (pwd -W 2>/dev/null || pwd)) # In edge's network namespace: the loopback API (curl and jq from a throw-away Alpine). inside() { docker run --rm -i --network container:$P-edge-1 alpine:3.20 sh -c "apk add -q curl jq >/dev/null && $1"; } @@ -43,7 +45,7 @@ docker run --rm -i -v ${P}_state:/v alpine:3.20 sh -c 'cat > /v/domi-root.crt && ok "root in the state volume" step "docker compose up" -"${DC[@]}" up -d >/dev/null 2>&1 || fail "compose up" +"${DC[@]}" up -d > "$WORK/compose-up.log" 2>&1 || { cat "$WORK/compose-up.log"; fail "compose up"; } for i in $(seq 60); do inside "curl -s -o /dev/null http://127.0.0.1:7878/" 2>/dev/null && break; sleep 2; done ADMIN=$("${DC[@]}" exec -T control ianitor-control token create --name smoke --config /var/lib/ianitor/control.toml 2>/dev/null | tail -n1) FABRICA=$("${DC[@]}" exec -T control ianitor-control token create --name fabrica --scope previews --config /var/lib/ianitor/control.toml 2>/dev/null | tail -n1) @@ -71,10 +73,10 @@ step "Fabrica opens the preview (scripts/preview.sh, previews-only token)" url=$(inside "IANITOR_URL=http://127.0.0.1:7878 IANITOR_PREVIEW_TOKEN=$FABRICA sh -s -- open shop fix-42 http://app:8080 3600" < "$REPO/scripts/preview.sh") [ "$url" = "https://fix-42--shop.pv.smoke.test/" ] || fail "preview URL: $url" ok "preview URL $url" -body=$(curl -sS --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:28443:127.0.0.1 https://fix-42--shop.pv.smoke.test:28443/ || true) +body=$(curl -sS --ssl-no-revoke --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:28443:127.0.0.1 https://fix-42--shop.pv.smoke.test:28443/ || true) [ "$body" = "hello from fix-42" ] || fail "the preview through edge: $body" ok "the preview answers through edge (Pingora) from the host, with a Domi certificate" -code=$(curl -s -o /dev/null -w '%{http_code}' --cacert "$WORK/root/domi-root.crt" --resolve ianitor.smoke.test:28443:127.0.0.1 https://ianitor.smoke.test:28443/api/v1/team || true) +code=$(curl -s -o /dev/null -w '%{http_code}' --ssl-no-revoke --cacert "$WORK/root/domi-root.crt" --resolve ianitor.smoke.test:28443:127.0.0.1 https://ianitor.smoke.test:28443/api/v1/team || true) [ "$code" = 401 ] || fail "admin host: $code" ok "the admin host reaches control and needs a sign-in (401)" code=$(inside "curl -s -o /dev/null -w '%{http_code}' -H 'Authorization: Bearer $FABRICA' http://127.0.0.1:7878/api/v1/hosts") @@ -84,7 +86,7 @@ ok "the preview token cannot read the hosts (403)" step "closed on merge" inside "IANITOR_URL=http://127.0.0.1:7878 IANITOR_PREVIEW_TOKEN=$FABRICA sh -s -- close shop fix-42" < "$REPO/scripts/preview.sh" >/dev/null for i in $(seq 45); do - code=$(curl -s -o /dev/null -w '%{http_code}' --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:28443:127.0.0.1 https://fix-42--shop.pv.smoke.test:28443/ || true) + code=$(curl -s -o /dev/null -w '%{http_code}' --ssl-no-revoke --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:28443:127.0.0.1 https://fix-42--shop.pv.smoke.test:28443/ || true) [ "$code" != 200 ] && break sleep 2 done diff --git a/scripts/smoke-linux.sh b/scripts/smoke-linux.sh index 79ebd37..5757bdd 100644 --- a/scripts/smoke-linux.sh +++ b/scripts/smoke-linux.sh @@ -12,9 +12,11 @@ # # scripts/smoke-linux.sh set -euo pipefail +# Git Bash on Windows rewrites /paths for Windows programs (docker.exe); the paths here are the container's. +export MSYS_NO_PATHCONV=1 MSYS2_ENV_CONV_EXCL='*' DIST=$1 CTL=$2 WORK=$3 -REPO=$(cd "$(dirname "$0")/.." && pwd) +REPO=$(cd "$(dirname "$0")/.." && (pwd -W 2>/dev/null || pwd)) C=ianitor-smoke-linux step() { echo "== $*"; } ok() { echo " ok: $*"; } @@ -23,6 +25,9 @@ cleanup() { docker rm -f $C >/dev/null 2>&1 || true; docker rmi -f $C:latest >/d trap cleanup EXIT [ ! -e "$WORK" ] || fail "$WORK exists; give a new folder" mkdir -p "$WORK" +# A drive path (F:/...) on Windows, which both Git Bash and the Windows ianitor-control read. +WORK=$(cd "$WORK" && (pwd -W 2>/dev/null || pwd)) +DIST=$(cd "$DIST" && (pwd -W 2>/dev/null || pwd)) tarball=$(ls "$DIST"/ianitor-*-linux-x86_64.tar.gz | head -n1) [ -f "$tarball" ] && [ -f "$DIST/install.sh" ] || fail "no tarball or install.sh in $DIST" version=$(basename "$tarball" | sed 's/^ianitor-\(.*\)-linux-x86_64.tar.gz$/\1/') @@ -81,7 +86,7 @@ docker cp "$REPO/scripts/preview.sh" $C:/tmp/preview.sh url=$(docker exec -e IANITOR_URL=http://127.0.0.1:7878 -e IANITOR_PREVIEW_TOKEN="$FABRICA" $C sh /tmp/preview.sh open shop fix-42 http://127.0.0.1:23456 3600) [ "$url" = "https://fix-42--shop.pv.smoke.test/" ] || fail "preview URL: $url" ok "preview URL $url" -body=$(curl -sS --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:38443:127.0.0.1 https://fix-42--shop.pv.smoke.test:38443/ || true) +body=$(curl -sS --ssl-no-revoke --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:38443:127.0.0.1 https://fix-42--shop.pv.smoke.test:38443/ || true) [ "$body" = "hello from fix-42" ] || fail "the preview through edge: $body" ok "the preview answers through edge (Pingora under systemd), with a Domi certificate" code=$(api "$FABRICA" -o /dev/null -w '%{http_code}' http://127.0.0.1:7878/api/v1/hosts) @@ -91,7 +96,7 @@ ok "the preview token cannot read the hosts (403)" step "closed on merge" docker exec -e IANITOR_URL=http://127.0.0.1:7878 -e IANITOR_PREVIEW_TOKEN="$FABRICA" $C sh /tmp/preview.sh close shop fix-42 >/dev/null for i in $(seq 45); do - code=$(curl -s -o /dev/null -w '%{http_code}' --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:38443:127.0.0.1 https://fix-42--shop.pv.smoke.test:38443/ || true) + code=$(curl -s -o /dev/null -w '%{http_code}' --ssl-no-revoke --cacert "$WORK/root/domi-root.crt" --resolve fix-42--shop.pv.smoke.test:38443:127.0.0.1 https://fix-42--shop.pv.smoke.test:38443/ || true) [ "$code" != 200 ] && break sleep 2 done