Не оживлять отозванный токен после недоступности Valkey
Skeleton contracts / contracts (pull_request) Failing after 26s
Application / stack (pull_request) Failing after 32s

This commit is contained in:
Pavel Grigorev
2026-10-31 10:31:35 +03:00
parent 90a0532809
commit 0c6b95cc53
10 changed files with 65 additions and 121 deletions
+13 -4
View File
@@ -48,13 +48,22 @@ def main():
started = time.monotonic()
other = new_user('nocache')
expect('регистрация и вход без кэша', (200, time.monotonic() - started), [200], 1)
expect('logout без кэша: отзыв не подтверждён', timed('DELETE', '/api/v1/auth/sessions/current', other['token']), [503], 1.5)
expect('токен после неудачного logout работает', timed('GET', '/api/v1/users/me', other['token']), [200], 1)
expect('logout без кэша', timed('DELETE', '/api/v1/auth/sessions/current', other['token']), [204], 1.5)
expect('отозванный токен', timed('GET', '/api/v1/users/me', other['token']), [401], 1)
finally:
compose('up', '-d', '--wait', 'valkey')
print('1б. Valkey на паузе: logout, затем unpause — отозванный токен не оживает из кэша')
revoked = new_user('paused')
call('GET', '/api/v1/users/me', token=revoked['token'])
compose('pause', 'valkey')
try:
expect('logout при паузе Valkey', timed('DELETE', '/api/v1/auth/sessions/current', revoked['token']), [204], 1.5)
finally:
compose('unpause', 'valkey')
time.sleep(6)
expect('logout после восстановления Valkey', timed('DELETE', '/api/v1/auth/sessions/current', other['token']), [204], 1)
expect('отозванный токен', timed('GET', '/api/v1/users/me', other['token']), [401], 1)
expect('через 6 с после unpause: /users/me', timed('GET', '/api/v1/users/me', revoked['token']), [401], 1)
expect('через 6 с после unpause: сообщение', timed('POST', history, revoked['token'], {'text': 'после logout'}), [401], 1)
print('2. PostgreSQL остановлен: ограниченная ошибка 503, анонимный запрос не проходит')
compose('stop', 'postgres')