forked from mtusi2026/mtusi2026lab2
[+] Completed lab 2
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Run against an API with SESSION_TTL_SECONDS=2."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
from client import Client, arguments, run
|
||||
|
||||
|
||||
def main():
|
||||
args = arguments('Student check: two-second session TTL')
|
||||
client = Client(args.base_url, args.ca_file)
|
||||
actor = client.user('expiry')
|
||||
client.call('GET', '/api/v1/users/me', actor=actor, schema='User')
|
||||
sleep(2.2)
|
||||
client.call('GET', '/api/v1/users/me', 401, actor=actor)
|
||||
print('PASS: a valid token became unauthorized after the two-second TTL')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
Reference in New Issue
Block a user