deploy: sed delimiter '|' for the Caddyfile hash render (bcrypt contains '/')
Plus a regression seam that reproduces the render with a slash-bearing hash.
This commit is contained in:
1 parent
4a679fce80
commit
6ea490d64c
2 files changed
+14
-1
No files matched your search
+2
-1
@@ -128,8 +128,9 @@ if [ '${COPY_SHARED[$TARGET]}' = '1' ]; then
|
|||||||
if [ -z \"\${CADDY_BASICAUTH_HASH:-}\" ]; then
|
if [ -z \"\${CADDY_BASICAUTH_HASH:-}\" ]; then
|
||||||
echo ' WARN: CADDY_BASICAUTH_HASH not set in .env; keeping placeholder'
|
echo ' WARN: CADDY_BASICAUTH_HASH not set in .env; keeping placeholder'
|
||||||
else
|
else
|
||||||
|
# '|' delimiter: the bcrypt hash contains '/' characters.
|
||||||
mkdir -p /home/dank/Containers/caddy
|
mkdir -p /home/dank/Containers/caddy
|
||||||
sed \"s/REPLACE_WITH_HASH/\${CADDY_BASICAUTH_HASH}/g\" dankclaw/Caddyfile \\
|
sed \"s|REPLACE_WITH_HASH|\${CADDY_BASICAUTH_HASH}|g\" dankclaw/Caddyfile \\
|
||||||
> /home/dank/Containers/caddy/Caddyfile
|
> /home/dank/Containers/caddy/Caddyfile
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -33,3 +33,15 @@ load helpers
|
|||||||
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankserver 'true' 2>/dev/null \
|
timeout 8 ssh -o BatchMode=yes -o ConnectTimeout=5 dank@dankserver 'true' 2>/dev/null \
|
||||||
|| skip "dankserver not reachable from this host"
|
|| 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"
|
||||||
|
}
|
||||||
Reference in new issue
Block a user