35 lines
4.2 KiB
Python
35 lines
4.2 KiB
Python
from pathlib import Path
|
|
import json,hashlib,shutil,subprocess,zipfile,xml.etree.ElementTree as ET
|
|
root=Path(__file__).resolve().parents[2];out=Path(__file__).resolve().parent
|
|
private=Path('C:/Users/macbook/.config/investmoz/promotor-contexto-QA-20261015');qa=private/'source'
|
|
assert not private.exists(),'Inspect existing QA before continuing'
|
|
sha=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
|
|
baseline={p.relative_to(root).as_posix():sha(p) for folder in ['app','config','routes','database','resources','public/build'] for p in (root/folder).rglob('*') if p.is_file()}
|
|
protected={n:sha(root/n) for n in ['.env','composer.lock','package-lock.json']}
|
|
private.mkdir(parents=True);qa.mkdir()
|
|
(out/'ATIVO-ANTES.json').write_text(json.dumps({'files':baseline,'protected':protected},indent=2),'utf-8')
|
|
for folder in ['app','config','routes','database','resources','bootstrap','public/build']:
|
|
shutil.copytree(root/folder,qa/folder)
|
|
for n in ['artisan','composer.json','composer.lock']:shutil.copy2(root/n,qa/n)
|
|
for n in ['storage/framework/cache/data','storage/framework/views','storage/framework/sessions','storage/logs','storage/app/private','storage/app/public']:(qa/n).mkdir(parents=True,exist_ok=True)
|
|
for n in ['config.php','routes-v7.php']:
|
|
assert not (qa/'bootstrap/cache'/n).exists(),'Unexpected destination cache'
|
|
subprocess.run(['powershell','-NoProfile','-Command',f"New-Item -ItemType Junction -Path '{qa/'vendor'}' -Target '{root/'vendor'}' | Out-Null"],check=True,capture_output=True)
|
|
(qa/'.env').write_text('APP_NAME="InvesteMoz QA contexto Promotor"\nAPP_ENV=testing\nAPP_KEY=base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\nAPP_DEBUG=false\nAPP_URL=http://127.0.0.1:18520\nDB_CONNECTION=pgsql\nDB_HOST=127.0.0.1\nDB_PORT=55441\nDB_DATABASE=promoter_context_20261015_test\nDB_USERNAME=postgres\nDB_PASSWORD=\nSESSION_DRIVER=file\nCACHE_STORE=array\nQUEUE_CONNECTION=sync\nMAIL_MAILER=log\nINERTIA_SSR_ENABLED=false\nINVESTOR_PATH_ENABLED=true\nPORTAL_LEGACY_CONTENT_ENABLED=false\nPORTAL_LEGACY_CONTENT_QA_ENABLED=true\n','utf-8')
|
|
backup=json.loads((root/'outputs/investmoz-classificacao-ativacao-20261015/FRESH-BACKUP.json').read_text('utf-8'))
|
|
dump=Path(backup['private_directory'])/'destination.dump';assert sha(dump)==backup['dump_sha256']
|
|
pg=Path('C:/Program Files/PostgreSQL/17/bin');common=['-h','127.0.0.1','-p','55441','-U','postgres'];db='promoter_context_20261015_test'
|
|
subprocess.run([str(pg/'createdb.exe'),*common,db],check=True,capture_output=True)
|
|
subprocess.run([str(pg/'pg_restore.exe'),*common,'-d',db,'--exit-on-error','--no-owner','--no-privileges',str(dump)],check=True,capture_output=True)
|
|
# The original Tempo specification is read as policy evidence, without changing it.
|
|
doc=Path('C:/Mac/Home/Documents/TEMPO/Portal Tempo/Servicos Tempo/prompt/novos/Gestao de perfis investeMOZ v1.docx')
|
|
with zipfile.ZipFile(doc) as z:xml=ET.fromstring(z.read('word/document.xml'))
|
|
ns={'w':'http://schemas.openxmlformats.org/wordprocessingml/2006/main'}
|
|
ps=[''.join(t.text or '' for t in p.findall('.//w:t',ns)) for p in xml.findall('.//w:p',ns)]
|
|
evidence={'source':str(doc),'sha256':sha(doc),'version':ps[1],'paragraphs':len(ps),'selected_paragraphs':[{'xml_paragraph':i,'text':ps[i-1]} for i in [32,66,70,106,107,109,113,114,116,344,345,348]],'interpretation':'The matrix distinguishes exercised roles. Blanket account-membership gating in operational/canCreate/scope also applies exceptional elevation to normal scoped Promotor actions; no express cumulative-role restriction found in the primary text. This QA delta applies the user clarification to the ordinary Promotor path only.'}
|
|
assert evidence['sha256']=='f9e0f6280566fed8b52d0b36bb814a82e11976fec9ea9f62d64611ff8c824b38'
|
|
(out/'FONTE-V1-E-CONDICAO.json').write_text(json.dumps(evidence,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
record={'source':str(qa),'database':db,'host':'127.0.0.1','port':55441,'url':'http://127.0.0.1:18520','active_database':'not used by QA boot or tests','APP_KEY':'isolated QA key; no active secret reused','roles':'existing restored assignments/pair retained unchanged; no grants inserted','dump_sha256':sha(dump),'protected_active_files':len(baseline),'active_changes':0}
|
|
(out/'QA-ISOLAMENTO.json').write_text(json.dumps(record,ensure_ascii=False,indent=2)+'\n','utf-8')
|
|
print(json.dumps(record,ensure_ascii=True))
|