test(auth): lab7 verify rehash, shared limits and session expiry and measure login cost

This commit is contained in:
Голиков Maximillian Антон
2026-11-29 14:32:11 +03:00
parent a907161087
commit b34427c34f
4 changed files with 196 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
project=$PWD
export COMPOSE_FILE="$project/compose.yaml"
python=${PYTHON:-python3}
if [[ -z ${PYTHON:-} && -x "$project/.venv/bin/python" ]]; then
python="$project/.venv/bin/python"
elif [[ $python == */* && $python != /* ]]; then
python="$project/$python"
fi
cd /tmp
if ! command -v "$python" >/dev/null; then
echo "Интерпретатор не найден: $python. Укажите PYTHON для WSL." >&2
exit 1
fi
"$python" -c 'from argon2.low_level import hash_secret' || {
echo "Установите argon2-cffi в выбранный Python: $python" >&2
exit 1
}
# Короткий TTL только для новых сессий на время отдельного теста.
restore() { docker compose up -d --no-deps --no-build --wait --wait-timeout 120 api; }
trap restore EXIT
SESSION_TTL_SECONDS=20 docker compose up -d --no-deps --no-build --wait --wait-timeout 120 api
# Даём балансировщику обновить адреса после пересоздания реплик.
stable=0
for ((i=0;i<60;i++)); do
if curl -fsS --max-time 3 --cacert "$project/certs/private/ingress/ca.crt" https://localhost:8443/health/ready >/dev/null; then
stable=$((stable+1))
if ((stable >= 12)); then break; fi
else
stable=0
fi
sleep 1
done
((stable >= 12))
"$python" "$project/student-tests/auth-test.py"