- test(ui): avoid a literal em dash in the em dash check - fix(cli): accept any positive int64 audit count and share the last active admin rule - fix(api): limit audit before_id to 2^53-1 - fix(api): audit unmatched api requests, bound every request body and record audit write failures - fix(ui): recheck the account in the login transaction and require existing zones on zone pages - fix(api): recheck the acting admin and the stored password hash in change transactions - fix(db): keep committed outcomes on lock release failure, narrow the records contract and trace sql statements - fix(db): make the initial migration restartable and verify the application schema - fix(auth): never move last_seen_at backwards on concurrent session touches - test(api): cover lock release failure after commit and handler tracing without secrets - fix(test): redact credentials from mysql setup errors - fix(audit): retain addressed objects on admin refusals - test(db): cover migration restarts and records contract ranges in mysql - test(api): verify account races and audit rollback in mysql - fix(auth): reject password changes after account deletion - docs: document unknown api audit entries - fix(audit): bound failure retries and redact sensitive sql parameters - fix(test): isolate docker resources and cover image cli commands - test(auth): expect unauthorized after an account deletion race - fix(db): verify application column widths and foreign keys
84 lines
2.7 KiB
Bash
Executable File
84 lines
2.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
# Copyright (C) 2026 Bryan Joshua Pedini
|
|
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
. ./scripts/docker-test-lib.sh
|
|
IT_ID=${IT_ID:-$$}
|
|
IT_NAME=${IT_NAME:-cdwu-it-${IT_ID}}
|
|
MYSQL_IMAGE=${MYSQL_IMAGE:-mysql:8.4}
|
|
network="$IT_NAME"
|
|
mysql="${IT_NAME}-mysql"
|
|
mysql_data="${IT_NAME}-data"
|
|
tests="${IT_NAME}-tests"
|
|
image="${IT_NAME}:integration"
|
|
|
|
require_free_docker_name network "$network"
|
|
require_free_docker_name container "$mysql"
|
|
require_free_docker_name volume "$mysql_data"
|
|
require_free_docker_name container "$tests"
|
|
require_free_docker_name image "$image"
|
|
|
|
network_id=
|
|
mysql_id=
|
|
tests_id=
|
|
volume=
|
|
tmp=$(mktemp -d)
|
|
owner=${tmp##*/}
|
|
owns_volume() {
|
|
[ "$(docker volume inspect --format '{{index .Labels "cdwu.test.owner"}}' "$1")" = "$owner" ]
|
|
}
|
|
cleanup() {
|
|
status=$?
|
|
if [ "$status" -ne 0 ] && [ -n "$mysql_id" ]; then
|
|
docker logs --tail 80 "$mysql_id" >&2 2>&1 || true
|
|
fi
|
|
for container in "$tests_id" "$mysql_id"; do
|
|
if [ -n "$container" ]; then
|
|
docker rm --force --volumes "$container" >/dev/null 2>&1 || true
|
|
fi
|
|
done
|
|
if [ -n "$volume" ] && owns_volume "$volume" 2>/dev/null; then
|
|
docker volume rm "$volume" >/dev/null 2>&1 || true
|
|
fi
|
|
if [ -n "$network_id" ]; then
|
|
docker network rm "$network_id" >/dev/null 2>&1 || true
|
|
fi
|
|
if [ -s "$tmp/image-id" ] &&
|
|
[ "$(docker image inspect --format '{{.Id}}' "$image" 2>/dev/null)" = "$(cat "$tmp/image-id")" ]; then
|
|
docker image rm "$image" >/dev/null 2>&1 || true
|
|
fi
|
|
rm -rf "$tmp"
|
|
exit "$status"
|
|
}
|
|
trap cleanup EXIT
|
|
trap 'exit 130' INT TERM
|
|
|
|
root_password=$(od -An -tx1 -N16 /dev/urandom | tr -d ' \n')
|
|
volume=$(docker volume create --label "cdwu.test.owner=$owner" "$mysql_data")
|
|
if ! owns_volume "$volume"; then
|
|
echo "docker volume already exists: $mysql_data" >&2
|
|
exit 1
|
|
fi
|
|
network_id=$(docker network create --internal "$network")
|
|
require_free_docker_name image "$image"
|
|
docker build --target integration --file dockerfile --tag "$image" --iidfile "$tmp/image-id" .
|
|
mysql_id=$(docker create --name "$mysql" --network "$network_id" --network-alias mysql \
|
|
--volume "$volume:/var/lib/mysql" \
|
|
--env MYSQL_ROOT_PASSWORD="$root_password" "$MYSQL_IMAGE")
|
|
docker start "$mysql_id" >/dev/null
|
|
attempt=0
|
|
until docker exec --env MYSQL_PWD="$root_password" "$mysql_id" mysql --host=127.0.0.1 --user=root --execute 'SELECT 1' >/dev/null 2>&1; do
|
|
attempt=$((attempt + 1))
|
|
if [ "$attempt" -ge 120 ]; then
|
|
echo "mysql did not become ready" >&2
|
|
exit 1
|
|
fi
|
|
sleep 1
|
|
done
|
|
tests_id=$(docker create --name "$tests" --network "$network_id" \
|
|
--env IT_MYSQL_HOST=mysql --env IT_MYSQL_PORT=3306 --env IT_MYSQL_ROOT_PASSWORD="$root_password" \
|
|
"$(cat "$tmp/image-id")")
|
|
docker start --attach "$tests_id"
|