Files
Investidor-V2/outputs/investmoz-staff-preparation-20261012/verify-opening-seal.py
T
nala 287e991486
tests / ci (push) Waiting to run
oportunidades 7
2026-10-13 11:40:29 +02:00

27 lines
1.8 KiB
Python

import hashlib
import json
import zipfile
from pathlib import Path
ROOT=Path(__file__).resolve().parents[2]
OUT=ROOT/'outputs/investmoz-staff-preparation-20261012'
receipt=json.loads((OUT/'abertura-workflow-final-link.json').read_text())
folder=Path(receipt['directory'])
manifest=json.loads((folder/'manifesto-final.json').read_text())
sha=lambda path:hashlib.sha256(path.read_bytes()).hexdigest()
archive=folder/('investmoz-abertura-'+receipt['delivery_revision']+'.zip')
assert sha(archive)==receipt['package_sha256']
assert sha(folder/'manifesto-final.json')==receipt['manifest_sha256']
with zipfile.ZipFile(archive) as stream:
for item in manifest['source_files']+manifest['compiled_resources']:
assert hashlib.sha256(stream.read('payload/'+item['path'])).hexdigest()==item.get('after_sha256',item.get('sha256'))
assert hashlib.sha256(stream.read('PROCEDIMENTO-UNICO.md')).hexdigest()==manifest['procedure_sha256']
assert hashlib.sha256(stream.read('manifesto-final.json')).hexdigest()==receipt['manifest_sha256']
for name,value in manifest['evidence'].items():
assert hashlib.sha256(stream.read('evidencias/'+name)).hexdigest()==value
assert not manifest['active_changes_applied'] and not manifest['activation_authorized']
assert set(manifest['flags'])=={'PORTAL_PROFILE_ACCESS_ENABLED','PORTAL_OPPORTUNITY_DASHBOARD_ACCESS_ENABLED','PORTAL_OPPORTUNITY_SPECIALIZED_DRAFTS_ENABLED'}
assert manifest['schema_changes']==0 and manifest['service_changes']==0 and not manifest['migrations']
proof={'result':'passed','delivery':receipt['delivery_revision'],'code':receipt['code_revision'],'all_payload_and_evidence_hashes_verified':True,'active_changes':0,'activation_authorized':False}
(folder/'verificacao-selo.json').write_text(json.dumps(proof,indent=2),encoding='utf-8')
print(json.dumps(proof))