"""Live private-entry acceptance. Keys are stable; never prints login secrets.""" import json,time from pathlib import Path import requests ROOT=Path(__file__).resolve().parents[1] ENV=dict(line.split('=',1) for line in (ROOT/'.env.server').read_text(encoding='utf-8-sig').splitlines() if line and not line.startswith('#') and '=' in line) BASE='http://127.0.0.1:8000/api' OUT=ROOT/'qa/v3-live.json' report={} def save():OUT.write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') def login(): client=requests.Session() response=client.post(BASE+'/auth/login',json={'username':ENV['ADMIN_USERNAME'],'password':ENV['ADMIN_PASSWORD']},timeout=15) assert response.status_code==200,('login',response.status_code) client.headers['X-CSRF-Token']=response.json()['csrf_token'];return client def accepted(client,route,body,key): r=client.post(BASE+route,json=body,headers={'Idempotency-Key':key},timeout=25) assert r.status_code==202,(route,r.status_code) return r.json() def wait_job(client,id,seconds=300): deadline=time.monotonic()+seconds while time.monotonic()