forked from mtusi2026/mtusi2026lab2
2 lab
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Login against an API started with a short SESSION_TTL_SECONDS and wait it out."""
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT / "tests"))
|
||||
|
||||
from client import Client, arguments, check, run
|
||||
|
||||
|
||||
def main():
|
||||
def configure(parser):
|
||||
parser.add_argument("--wait", type=float, default=3)
|
||||
|
||||
args = arguments("Session expiry", configure)
|
||||
client = Client(args.base_url, args.ca_file, timeout=15)
|
||||
actor = client.user("ttl")
|
||||
client.call("GET", "/api/v1/users/me", actor=actor, schema="User")
|
||||
time.sleep(args.wait)
|
||||
client.call("GET", "/api/v1/users/me", 401, actor=actor)
|
||||
check(True, "")
|
||||
print("PASS: session expired after %.1f s" % args.wait)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(main)
|
||||
Reference in New Issue
Block a user