forked from mtusi2026/mtusi2026lab7
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:
@@ -280,6 +280,39 @@ def test_connection_limit_reached(tight_api: Api, stand: Stand) -> None:
|
||||
assert_ok(tight_api.request("GET", ME, actor=fresh), 200, "User")
|
||||
|
||||
|
||||
@pytest.mark.spec("data-storage", "Пароль роли отвергнут")
|
||||
def test_role_password_rejected(
|
||||
api: Api,
|
||||
stand: Stand,
|
||||
alice: Actor,
|
||||
chat: dict[str, Any],
|
||||
) -> None:
|
||||
# hook сменил пароль роли и оборвал её соединения: при выдаче
|
||||
# pool_pre_ping переподключается и получает отказ входа (SQLSTATE 28P01)
|
||||
key = new_key()
|
||||
body = {"text": "пароль роли сменён"}
|
||||
stand("role-password", "break")
|
||||
try:
|
||||
resp, took = timed(
|
||||
lambda: api.post_message(alice, chat["id"], json=body, key=key),
|
||||
)
|
||||
error = assert_error(resp, 503)
|
||||
assert took < POOL_TIMEOUT_S + 0.5, f"503 took {took:.2f}s"
|
||||
# недоступность хранилища — не отказ в аутентификации клиента
|
||||
assert "WWW-Authenticate" not in resp.headers
|
||||
for word in ("postgres", "sql", "password", "role", "connect"):
|
||||
assert word not in error["message"].lower()
|
||||
assert_error(api.request("GET", "/health/ready"), 503)
|
||||
assert api.request("GET", "/health/live").status_code == 200
|
||||
finally:
|
||||
stand("role-password", "restore")
|
||||
# пароль возвращён: тот же ключ проходит без перезапуска сервиса
|
||||
resp = api.post_message(alice, chat["id"], json=body, key=key)
|
||||
message = assert_ok(resp, 201, "Message")
|
||||
assert api.all_messages(alice, chat["id"]) == [message]
|
||||
assert api.request("GET", "/health/ready").status_code == 200
|
||||
|
||||
|
||||
# пачка одновременных запросов больше пула обычного API (10)
|
||||
BURST_THREADS = 48
|
||||
BURST_AFTER_BARRIER = 4
|
||||
|
||||
Reference in New Issue
Block a user