Files
Investidor-V2/outputs/investmoz-editorial-QA-20261018/test-delta.py
T
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

28 lines
2.7 KiB
Python

from pathlib import Path
# Import only the helpers, without replaying the accepted first execution.
scope={};text=(Path(__file__).parent/'test-QA.py').read_text('utf8').split('try:\n a=login')[0]
scope['__file__']=str(Path(__file__).parent/'test-QA.py');exec(text,scope)
globals().update(scope)
try:
a=login('authorized');u=login('unprivileged');v=session();r=current(a,30);path='/management/portal-services/resources/30/article'
call(u,'/management/portal-services/upload',{},expected=403);call(u,'/management/portal-services/resources/30',{'published':True},expected=403);call(u,'/management/sectors',{},expected=403)
ck('Escritas de documento/publicação/sector recusadas sem permissão',True)
ck('Sector retirado também ausente dos filtros públicos','Sector sintético editorial QA' not in json.dumps(props(v,'/oportunidades'),ensure_ascii=False))
# Use an existing public image from the same cloned library, copying its original bytes only to isolated storage.
import shutil
php='C:/Users/macbook/.config/investmoz/php-8.5.11/php.exe'
result=subprocess.run([php,str(o/'image-QA.php')],check=True,capture_output=True,text=True);image=json.loads(result.stdout)
body='Corpo sintético QA com imagem reutilizada.\n\n<script>alert("QA")</script> é texto, nunca executado.'
call(a,path,{'body':body,'metadata_version':r['metadata_version'],'image_resource_id':999999999},method='PUT',expected=422)
call(a,path,{'body':body,'metadata_version':r['metadata_version'],'image_resource_id':image['id']},method='PUT',expected=(302,303))
call(a,'/management/portal-services/resources/30',{'published':True},expected=(302,303))
article=props(v,'/artigos/30')['article'];ck('Imagem existente reutilizada sem copiar cadastro',article['image_url']=='/documentos/'+str(image['id'])+'/view',{'resource_id':image['id']})
call(v,article['image_url']);ck('Imagem pública consultável',True)
ck('Corpo entregue como texto, sem inserção HTML executável',article['body']==body)
# Preserve two previous body snapshots and actor attribution, with independent server read.
state=subprocess.run([php,str(o/'history-QA.php')],check=True,capture_output=True,text=True);proof=json.loads(state.stdout)
ck('Snapshots contêm corpos anteriores, relações e ator da sessão',proof['previous_bodies']>=3 and proof['actor_consistent'] and proof['original_unchanged'],proof)
except Exception as e:checks.append({'criterio':'Delta focado','resultado':'falhou','evidencia':str(e)})
finally:
(o/'PROVAS-DELTA-QA.json').write_text(json.dumps({'checks':checks,'events':events,'active_changes':0},ensure_ascii=False,indent=2),'utf8');print(json.dumps({'checks':len(checks),'failed':[c for c in checks if c['resultado']=='falhou']},ensure_ascii=True))