Не оживлять отозванный токен после недоступности Valkey
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user