"""Проверка сессии, нового подключения и отзыва старого пароля.""" import importlib.util import sys from pathlib import Path root = Path(__file__).resolve().parents[1] sys.path[:0] = [str(root / "tests"), str(root / "scripts")] from client import Client from rotation_common import CA, compose spec = importlib.util.spec_from_file_location("rotate_redis", root / "scripts/rotate-redis.py") rotation = importlib.util.module_from_spec(spec) spec.loader.exec_module(rotation) if rotation.journal.exists(): raise SystemExit("Завершите прерванную ротацию через scripts/rotate-redis.py.") client = Client("https://localhost:8443", str(CA)) actor = client.user("rotation") old = rotation.url_file.read_text().strip() rotation.main() new = rotation.url_file.read_text().strip() compose("restart", "redis") compose("up", "-d", "--no-deps", "--no-recreate", "--wait", "--wait-timeout", "90", "redis") if old == new or not rotation.redis_ping(new) or rotation.redis_ping(old): raise SystemExit("После перезапуска Redis не подтверждён отзыв старого пароля.") me = client.call("GET", "/api/v1/users/me", actor=actor, schema="User")["json"] if me["id"] != actor["id"]: raise SystemExit("Исходная сессия не подтверждена.") print("PASS: прежняя сессия работает, новый пароль принят, старый отклонён после перезапуска.")