ЛР 7 — БВТ2302 — Макаренко — TLS и управление секретами

This commit is contained in:
2026-12-04 13:41:59 +03:00
parent 20afc2c790
commit 8a3cf7f2dd
55 changed files with 1991 additions and 24 deletions
+23
View File
@@ -0,0 +1,23 @@
import json
import os
import subprocess
import sys
import time
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/"tests"))
from client import Client
client=Client(os.getenv("BASE_URL","https://127.0.0.1:8443"),".local/ca.crt")
user=client.user("expiry")
issue="""import json,sys
from store import Store
body=json.load(sys.stdin)
print(json.dumps(Store().login(body['username'],body['password'])))"""
command=["docker","compose","exec","-T","-e","SESSION_TTL_SECONDS=2","api","python","boot.py","python","-c",issue]
result=subprocess.run(command,input=json.dumps(user["registration"]),text=True,capture_output=True,check=True)
user["token"]=json.loads(result.stdout)["token"]
client.call("GET","/api/v1/users/me",actor=user)
time.sleep(2.2)
client.call("GET","/api/v1/users/me",401,actor=user)
print("PASS: issuer TTL=2 s; same token gave 200 and then 401")