Files
Investidor-V2/outputs/investmoz-audit-current-20261012/verify-acceptance-396c-entry.py
T
nala ba1c0340ea
tests / ci (push) Canceled after 0s
oportunidades 8
2026-10-14 08:25:30 +02:00

45 lines
3.7 KiB
Python

from pathlib import Path
from hashlib import sha256
from datetime import datetime,timezone
from urllib.request import urlopen
from urllib.error import HTTPError
from html.parser import HTMLParser
import json,zipfile
OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1];QA=ROOT/'storage/app/private/investmoz-v2/portal-audit/portal-stability-source-20261011_083742';BASE='https://portal-investidor.test:18445';name='aceitacao-B-396c691930bc.html';page=QA/'public'/name
t=page.read_text(encoding='utf-8').replace('href="/dashboard"','href="'+BASE+'/dashboard"').replace('href="/login"','href="'+BASE+'/login"');page.write_text(t,encoding='utf-8');(OUT/name).write_text(t,encoding='utf-8')
class Links(HTMLParser):
def __init__(self):super().__init__();self.urls=[];self.cards=0
def handle_starttag(self,tag,attrs):
attrs=dict(attrs)
if tag=='a'and attrs.get('href','').startswith('https:'):self.urls.append(attrs['href'])
if tag=='article':self.cards+=1
p=Links();p.feed(t);assert p.cards==8 and all(u.startswith(BASE+'/')for u in p.urls)
with urlopen(BASE+'/'+name,timeout=30)as r:body=r.read();status=r.status
assert status==200 and sha256(body).hexdigest()==sha256(page.read_bytes()).hexdigest()
with urlopen(BASE+'/_qa/runtime',timeout=30)as r:runtime=json.loads(r.read());assert r.status==200
assert runtime['target']['database']=='stability_consumers_20261011_084534_test'and int(runtime['target']['port'])==55441
basezip=OUT/'investmoz-B-posicoes-tecnicas-QA-revisao-20261013.zip';assert sha256(basezip.read_bytes()).hexdigest()=='5b3676a25555e140b783350eb9379a6911dcf1ef62bf0d67271ded5244d288dc'
checked=0
with zipfile.ZipFile(basezip)as z:
manifest=json.loads(z.read('manifesto-revisao-QA.json'));assert manifest['review_revision']=='396c691930bc'
for f in manifest['files']:
n=f['file']
if n.startswith('delta-QA/'):actual=QA/n[len('delta-QA/'):]
elif n.startswith('compilacao-QA/'):actual=QA/'public/build-B8-land-consumers-prepared'/n[len('compilacao-QA/'):]
else:continue
assert sha256(actual.read_bytes()).hexdigest()==f['sha256'];checked+=1
assert checked==188
pres=json.loads((OUT/'option-B8-code-preservation.json').read_text(encoding='utf-8'))
for n,h in pres['checked_active_sha256'].items():assert sha256((ROOT/n).read_bytes()).hexdigest()==h
assert sha256((QA/'public/build/manifest.json').read_bytes()).hexdigest()==pres['QA_manifest_sha256']
# No private setup file has a public URL or exists under the QA web root.
local=json.loads((OUT/'acceptance-396c-local-access.json').read_text(encoding='utf-8'))['files']+json.loads((OUT/'acceptance-396c-local-extra-access.json').read_text(encoding='utf-8'))['files']
for a in local:
assert Path(a['file']).is_file()and not Path(a['file']).resolve().is_relative_to((QA/'public').resolve())
for root in ['acceptance-396c-local','acceptance-396c-local-extra']:
try:r=urlopen(BASE+'/'+root+'/'+Path(a['file']).name,timeout=30);code=r.status;r.close()
except HTTPError as e:code=e.code;e.close()
assert code==404,'Private access accidentally served'
result={'at':datetime.now(timezone.utc).isoformat(),'result':'ready_for_manual_observation_not_accepted','base_review':'396c691930bc','entry_url':BASE+'/'+name,'entry_HTTP':status,'entry_sha256':sha256(body).hexdigest(),'TLS_bypass':False,'QA_target':runtime['target'],'same_QA_runtime_confirmed':True,'scenario_cards':8,'all_route_links_same_QA_origin':True,'baseline_product_files_verified':checked,'base_code_and_bundle_unchanged':True,'active_code_configuration_preserved':True,'private_access_files_not_HTTP_served':True,'MFA_rotations':0,'new_visual_proofs':0,'new_technical_acceptance_tests':0,'active_writes':0,'final_candidate':False}
(OUT/'acceptance-396c-entry-verified.json').write_text(json.dumps(result,indent=2)+'\n',encoding='utf-8');print(json.dumps(result))