42 lines
7.0 KiB
Python
42 lines
7.0 KiB
Python
from pathlib import Path
|
|
from datetime import datetime,timezone
|
|
import json,csv,hashlib,zipfile,shutil,re,collections
|
|
csv.field_size_limit(10000000)
|
|
OUT=Path(__file__).resolve().parent;ROOT=OUT.parents[1];DOC=ROOT/'docs/investmoz/v2/auditoria-portal';load=lambda p:json.loads(p.read_text(encoding='utf-8-sig'));sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
plan=load(OUT/'authoring-plan.json');expected={'AUD-COUNTRY-03','AUD-COUNTRY-04','AUD-STATS-01','AUD-FIELD-014','AUD-UI-01'}
|
|
for f in plan['files']:
|
|
rows=list(csv.reader(Path(f['path']).open(encoding='utf-8-sig',newline='')));assert rows==f['after'];ix=rows[0].index('ID');changed={a[ix]for a,b in zip(rows[1:],f['before'][1:])if a!=b};assert changed==expected;assert len(rows)==3402
|
|
assert all(a==b for a,b in zip(rows[1:],f['before'][1:])if a[ix]not in expected)
|
|
matrix=list(csv.DictReader((DOC/'matriz-requisitos.csv').open(encoding='utf-8-sig',newline='')));assert sum(int(r['Quantidade de linhas de origem'])for r in matrix)==7739
|
|
fixture=load(OUT/'business-country-fixture.json');QA=Path(fixture['QA_source']);backend=load(OUT/'country-filter-QA-delta.json');front=load(OUT/'business-feedback-QA-delta.json');build=load(OUT/'business-feedback-build-QA.json')
|
|
assert all(sha(ROOT/p)==h for p,h in backend['active_source_hashes'].items());assert sha(ROOT/front['file'])==front['active_sha256_preserved'];assert sha(ROOT/'config/inertia.php')=='80c68e12bf6cb64e39931e2467b43909893cea3eb6d04c3c1e68bdcb1236dfb7';assert sha(ROOT/'public/build/manifest.json')==load(OUT/'C132-preflight.json')['build_hash']
|
|
assert sha(QA/'public/build/manifest.json')==build['QA_build_manifest_sha256']
|
|
for p,v in backend['changed_QA_files'].items():assert sha(QA/p)==v['after_sha256']
|
|
assert sha(QA/front['file'])==front['after_sha256']
|
|
inputs={p:sha(QA/p)for p in [*backend['changed_QA_files'],front['file']]};revision=hashlib.sha256(json.dumps({'sources':inputs,'QA_build_manifest':build['QA_build_manifest_sha256']},sort_keys=True).encode()).hexdigest()
|
|
manifest={'at':datetime.now(timezone.utc).isoformat(),'QA_delta_revision':revision,'QA_target':fixture['target'],'QA_base':'https://portal-investidor.test:18445','source_files_sha256':inputs,'QA_build_manifest_sha256':build['QA_build_manifest_sha256'],'QA_assets':build['QA_assets'],
|
|
'scope':'C133 country filter for stored legacy values; C134 field-level feedback in existing business-interest form. No new product fields or workflows.','dependencies':['Existing ISO catalogue, Intl/mbstring as already present in QA','Existing interest API, receipts/consents/outbox, management authorization and stable QA MFA','Existing guarded consumers QA and production build dependencies'],
|
|
'no_new_migrations_accounts_roles_services_catalogues':True,'active_application_configuration_bundle_unchanged':True,'active_data_writes':0,'external_notifications_disabled':True,'queue_not_consumed':True,
|
|
'demonstrated_API_persistence':['Legacy country Moçambique preserved, MZ filter recovers same request','New ISO MZ and origin BR persisted distinctly','Origin absent remains unknown','Same key after422 accepts correction; replay reuses reference/event/consent','Changed payload409; anonymous401/promoter_without_scope403'],
|
|
'code_only_pending_visual':['Country search/select presentation','Field-level errors, first-error focus and keyboard/reader behaviour','All-category workflow publication; business fixture is not a publication proof'],
|
|
'excluded':['Active deployment and any installation','COUNTRY02 data changes','Full A/B or C37 repetition','C132 holder confirmations','Offer/modular/SLA decisions','New education journeys'],
|
|
'reversal':'QA only: restore CountryCatalogue.php and PortalManagementController.php from country-filter-20261012-before; restore business-interest.tsx from business-feedback-20261012-before.tsx and prior QA public/build from verified business-feedback-build-before.zip. Preserve synthetic request receipts/events/consents and history. No active restore or credential changes.'}
|
|
(OUT/'independent-QA-lot-manifest.json').write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf-8')
|
|
integrity={'at':datetime.now(timezone.utc).isoformat(),'result':'passed','requirements':3401,'source_occurrences':7739,'requirement_IDs_added':0,'updated_requirement_IDs':sorted(expected),'all_other_requirements_including_C132_AB_C37_unchanged':True,'states':dict(collections.Counter(r['Estado']for r in matrix)),'matrix_sha256':sha(DOC/'matriz-requisitos.csv'),'backlog_sha256':sha(DOC/'backlog-priorizado.csv'),'active_source_config_bundle_hashes_preserved':True,'QA_delta_revision':revision,'complete_global_requirement_closed':False}
|
|
(OUT/'independent-QA-lot-integrity.json').write_text(json.dumps(integrity,ensure_ascii=False,indent=2),encoding='utf-8')
|
|
review=OUT/'independent-QA-para-revisao';assert not review.exists();review.mkdir()
|
|
copies={DOC/n:n for n in ['relatorio-executivo.md','backlog.md','casos-reproducao.md','visao-consolidada-modulos.md','matriz-requisitos.csv','backlog-priorizado.csv']}
|
|
copies.update({QA/p:'delta-QA/'+p for p in inputs});copies[QA/'public/build/manifest.json']='delta-QA/public/build/manifest.json'
|
|
for name in ['business-country-before.json','business-country-after.json','business-country-variants.json','business-country-persistence.json','country-filter-QA-delta.json','business-feedback-QA-delta.json','business-feedback-build-QA.json','business-feedback-assets.json','business-country-fixture.json','independent-QA-lot-manifest.json','independent-QA-lot-integrity.json']:copies[OUT/name]='evidencias/'+name
|
|
filemanifest=[]
|
|
for source,target in copies.items():
|
|
dest=review/target;dest.parent.mkdir(parents=True,exist_ok=True);shutil.copyfile(source,dest);s=dest.read_text(encoding='utf-8-sig');assert 'otpauth://'not in s and not re.search(r'QA-[a-f0-9]{32,}',s);filemanifest.append({'file':target,'sha256':sha(dest),'bytes':dest.stat().st_size})
|
|
assert not any(Path(n).name in ['.env','onboarding-actors-local.json','profiles-v1-actors-private.json']for n in [r['file']for r in filemanifest])
|
|
archive=OUT/'investmoz-lote-QA-C133-C134-revisao-20261012.zip';assert not archive.exists()
|
|
with zipfile.ZipFile(archive,'w',zipfile.ZIP_DEFLATED,compresslevel=8)as z:
|
|
for r in filemanifest:z.write(review/r['file'],r['file'])
|
|
z.writestr('inventario-pacote.json',json.dumps(filemanifest,ensure_ascii=False,indent=2))
|
|
with zipfile.ZipFile(archive)as z:assert z.testzip()is None;assert all(hashlib.sha256(z.read(r['file'])).hexdigest()==r['sha256']for r in filemanifest)
|
|
for name in ['relatorio-executivo.md','backlog.md','casos-reproducao.md','visao-consolidada-modulos.md','matriz-requisitos.csv','backlog-priorizado.csv']:shutil.copyfile(DOC/name,OUT/'para-revisao'/name)
|
|
receipt={'result':'passed','file':str(archive),'sha256':sha(archive),'bytes':archive.stat().st_size,'entries':len(filemanifest)+1,'QA_revision':revision[:12],'active_changes':0,'visual_acceptance_pending':True,'C132_pending_confirmation_ids':[14,15,16]};(OUT/'independent-QA-delivery-proof.json').write_text(json.dumps(receipt,indent=2),encoding='utf-8');print(json.dumps(receipt))
|