@@ -0,0 +1,39 @@
|
||||
from pathlib import Path
|
||||
from hashlib import sha256
|
||||
from urllib.request import urlopen
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from datetime import datetime,timezone
|
||||
import json,importlib.util,sys
|
||||
|
||||
OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1]
|
||||
b2='--B2'in sys.argv
|
||||
destination=OUT/('option-B2-web-verification.json'if b2 else'option-B-web-verification.json')
|
||||
assert not destination.exists(),'Preserve earlier served-asset proof'
|
||||
QA=ROOT/'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742'
|
||||
spec=importlib.util.spec_from_file_location('transport',OUT/'consumer-lot-lib.py')
|
||||
lib=importlib.util.module_from_spec(spec);spec.loader.exec_module(lib)
|
||||
c=lib.Client();s,_,body=c.request('GET','/_qa/runtime',check_target=False)
|
||||
assert s==200 and json.loads(body)['target']['database']=='stability_consumers_20261011_084534_test'
|
||||
manifest=json.loads((QA/'public/build/manifest.json').read_text(encoding='utf-8'))
|
||||
assets=set()
|
||||
for entry in manifest.values():
|
||||
if entry.get('file'):assets.add(entry['file'])
|
||||
assets.update(entry.get('css',[]));assets.update(entry.get('assets',[]))
|
||||
def check(relative):
|
||||
assert '..'not in Path(relative).parts
|
||||
path=QA/'public/build'/relative
|
||||
with urlopen(lib.BASE+'/build/'+relative,timeout=30)as response:
|
||||
data=response.read();assert response.status==200
|
||||
assert sha256(data).hexdigest()==sha256(path.read_bytes()).hexdigest()
|
||||
return relative
|
||||
with ThreadPoolExecutor(max_workers=4)as pool:served=list(pool.map(check,sorted(assets)))
|
||||
page=c.call('GET','/oportunidades?maturity_level=8&opportunity_id=33&include_national=1',json_response=False)
|
||||
assert page['results']['total']==1 and page['results']['data'][0]['maturity_catalogue_version']=='spec-v2'
|
||||
assert len(page['references']['maturityCatalogue']['stages'])==8
|
||||
proof={'at':datetime.now(timezone.utc).isoformat(),'scope':'B','target':lib.TARGET,
|
||||
'served_assets':len(served),'all_asset_hashes_match':True,'TLS_verification_bypassed':False,
|
||||
'QA_manifest_sha256':sha256((QA/'public/build/manifest.json').read_bytes()).hexdigest(),
|
||||
'catalogue_HTML_payload_level8_record33_matches':True,'public_maturity_metadata_eight_stages':True,
|
||||
'browser_observed':False,'active_writes':0}
|
||||
destination.write_text(json.dumps(proof,indent=2)+'\n',encoding='utf-8')
|
||||
print(json.dumps(proof))
|
||||
Reference in New Issue
Block a user