25 lines
2.5 KiB
Python
25 lines
2.5 KiB
Python
from pathlib import Path
|
|
from datetime import datetime,timezone
|
|
import importlib.util,json,hashlib
|
|
OUT=Path(__file__).resolve().parent;spec=importlib.util.spec_from_file_location('transport',OUT/'option-B8-transport.py');lib=importlib.util.module_from_spec(spec);spec.loader.exec_module(lib)
|
|
s=json.loads((OUT/'option-B8-documents-56-progress.json').read_text(encoding='utf-8'));prior=json.loads((OUT/'option-B8-formats-finish-HTTP.json').read_text(encoding='utf-8'));assert prior['roles']['publisher'];proof={'at':datetime.now(timezone.utc).isoformat(),'target':lib.TARGET,'active_writes':0,'browser_observed':False,'formats':prior['formats'],'roles':prior['roles'],'reused_owner_validator_publisher_evidence':['option-B8-formats-HTTP.json','option-B8-formats-finish-HTTP.json'],'execution_serialized_after_harness_MFA_replay_collision':True};clients=[];stage='login';code=1
|
|
try:
|
|
# QA22 has an independently valid global Validator grant. Lack of franchise coediting does not revoke that read role.
|
|
for role,expected in [('colleague',200),('outsider',403)]:
|
|
c=lib.Client().login(role);clients.append(c);checks={}
|
|
for label,r in s['resources'].items():
|
|
route=f'/minhas-oportunidades/56/resources/documents/{r["resource_id"]}/download';stage=role+'_'+label
|
|
if expected==200:
|
|
status,h,raw=c.request('GET',route);assert status==200 and hashlib.sha256(raw).hexdigest()==r['sha256'];checks[label]={'status':200,'sha256_matches':True,'MIME':h.get('Content-Type')};proof['formats'][label]={'MIME':h.get('Content-Type'),'sha256':r['sha256']}
|
|
else:c.call('GET',route,expected=expected);checks[label]={'status':expected}
|
|
proof['roles'][role]=checks;c.logout();clients.remove(c)
|
|
for label,r in s['resources'].items():lib.Client().call('GET',f'/minhas-oportunidades/56/resources/documents/{r["resource_id"]}/download',expected=401)
|
|
proof.update(result='passed',colleague_read_basis='existing global Validator; promoter grant limited to investment_project unchanged',original_bytes_recovered=True,Office_preview_or_derivative_claimed=False,new_session_evidence_reused='option-B8-documents-56-review-HTTP.json');code=0
|
|
except Exception as e:proof.update(result='stopped',stage=stage,error_type=type(e).__name__)
|
|
finally:
|
|
for c in clients:
|
|
try:c.logout()
|
|
except Exception:pass
|
|
proof['requests']=lib.events;dest=OUT/'option-B8-formats-remainder-HTTP.json';assert not dest.exists();dest.write_text(json.dumps(proof,ensure_ascii=False,indent=2)+'\n',encoding='utf-8');print(json.dumps({k:v for k,v in proof.items()if k!='requests'},ensure_ascii=False))
|
|
raise SystemExit(code)
|