feat(deploy): prepare.sh + config templates, migrate env to deploy/, gitignore rendered outputs
This commit is contained in:
+5
-3
@@ -3,7 +3,9 @@ set -euo pipefail
|
||||
BASE=${BASE:-http://localhost:8080}
|
||||
API=$BASE/api
|
||||
J=(-H 'content-type: application/json')
|
||||
[ -f .env ] && set -a && . ./.env && set +a
|
||||
ENV_FILE=${ENV_FILE:-deploy/.env}
|
||||
[ -f "$ENV_FILE" ] || ENV_FILE=.env
|
||||
[ -f "$ENV_FILE" ] && set -a && . "./$ENV_FILE" && set +a
|
||||
WORK=$(mktemp -d); trap 'rm -rf "$WORK"' EXIT
|
||||
|
||||
say(){ echo "smoke: $1"; }
|
||||
@@ -25,7 +27,7 @@ code=$(curl -s -o /dev/null -w '%{http_code}' -X POST "$API/users" "${J[@]}" -H
|
||||
[ "$code" = 403 ] || die "member write not blocked ($code)"
|
||||
|
||||
say "library + bad-ext upload rejected + good upload + scan"
|
||||
mkdir -p library/smoke-books
|
||||
mkdir -p deploy/api/storage/smoke-books
|
||||
LID=$(curl -fsS "$API/libraries" "${J[@]}" -H "$AUTH" -d '{"name":"smoke","root_path":"/data/books/smoke-books"}' | sed -E 's/.*"id":([0-9]+).*/\1/')
|
||||
printf 'x' > "$WORK/f"
|
||||
curl -fsS -o /dev/null "$API/libraries/$LID/upload" -H "$AUTH" -F "file=@$WORK/f;filename=virus.exe" && die "bad ext upload must fail" || true
|
||||
@@ -52,6 +54,6 @@ curl -fsS -o /dev/null -D - "$BASE$COVER" -H "$AUTH" | grep -qi 'cache-control:.
|
||||
|
||||
say "delete book → file gone from host dir"
|
||||
curl -fsS -o /dev/null -X DELETE "$API/books/$BID" -H "$AUTH" || die "delete"
|
||||
[ ! -f library/smoke-books/note.txt ] || die "file survived delete"
|
||||
[ ! -f deploy/api/storage/smoke-books/note.txt ] || die "file survived delete"
|
||||
|
||||
say "ALL SMOKE TESTS PASSED"
|
||||
|
||||
Reference in New Issue
Block a user