feat: rotate and revoke credentials on the running stand

Add operator commands for leaf and secret rotation, identity revocation
and CRL renewal without rebuilding images, and a drill under load.
A rejected PostgreSQL role password is now 503 instead of 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-01 06:46:55 +03:00
co-authored by Claude Opus 5.5
parent 21b8a08e46
commit c40fbef36a
40 changed files with 5804 additions and 127 deletions
+32
View File
@@ -0,0 +1,32 @@
"""Какие ошибки драйвера — недоступность PostgreSQL (change
`rotation-revocation`, design, решение 10; спек `data-storage`, «Пароль роли
отвергнут»): `src/infra/db/errors.py`.
Отказ входа роли (28P01) — недоступность зависимости (503), а отказ прав
(42501) и нарушение ограничения (23505) — дефект запроса (500).
"""
import asyncpg
import pytest
from sqlalchemy import exc as sa_exc
from src.infra.db.errors import is_db_unavailable
def _dbapi_error(sqlstate: str) -> sa_exc.DBAPIError:
"""Ошибка, как её отдаёт SQLAlchemy: `orig` несёт SQLSTATE asyncpg."""
original = asyncpg.PostgresError.new({"C": sqlstate, "M": "text"})
return sa_exc.DBAPIError("SELECT 1", {}, original)
@pytest.mark.parametrize(
"sqlstate",
["08006", "53300", "57014", "57P01", "28P01"],
)
def test_unavailable(sqlstate: str) -> None:
assert is_db_unavailable(_dbapi_error(sqlstate))
@pytest.mark.parametrize("sqlstate", ["42501", "23505", "42601", "28000"])
def test_not_unavailable(sqlstate: str) -> None:
assert not is_db_unavailable(_dbapi_error(sqlstate))