forked from mtusi2026/mtusi2026lab6
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
import time
|
|
from client import Client, arguments, check, run
|
|
from stack import compose
|
|
|
|
|
|
def wait_valkey(timeout=60):
|
|
deadline = time.monotonic() + timeout
|
|
while '(healthy)' not in compose('ps', 'valkey', '--format', '{{.Status}}').stdout:
|
|
check(time.monotonic() < deadline, 'valkey did not recover')
|
|
time.sleep(1)
|
|
|
|
|
|
def main():
|
|
args = arguments('Session revocation must not depend on the cache')
|
|
c = Client(args.base_url, args.ca_file, timeout=15)
|
|
alice, bob, eve, chat = c.bootstrap()
|
|
c.call('GET', '/api/v1/chats', 200, actor=alice)
|
|
compose('stop', 'valkey')
|
|
try:
|
|
c.call('DELETE', '/api/v1/auth/sessions/current', 204, actor=alice)
|
|
finally:
|
|
compose('start', 'valkey')
|
|
wait_valkey()
|
|
c.call('GET', '/api/v1/chats', 401, actor=alice)
|
|
c.call('GET', '/api/v1/chats', 200, actor=bob)
|
|
print('PASS: token revoked while valkey was stopped stays revoked after valkey restart (401)')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
run(main)
|