18 lines
2.3 KiB
Python
18 lines
2.3 KiB
Python
from pathlib import Path
|
|
scope={'__file__':str(Path(__file__).parent/'test-QA.py')}
|
|
helper=(Path(__file__).parent/'test-QA.py').read_text('utf8').split('try:\n a=login')[0].replace('fixture-private.json','fixture-install-private.json').replace('18548','18550').replace('editorial_20261018_test','editorial_install_20261018_test')
|
|
exec(helper,scope);globals().update(scope)
|
|
try:
|
|
v=session();u=login('unprivileged');a=login('authorized');path='/management/editorial-installation'
|
|
call(v,path,expected=401);call(u,path,expected=403);call(u,path,{},expected=403);ck('Instalação recusa anónimo e conta sem permissão',True)
|
|
no_mfa=session();actor=f['actors']['authorized'];call(no_mfa,'/login');call(no_mfa,'/login',{'email':actor['email'],'password':actor['password']},expected=(200,204,302));call(no_mfa,'/two-factor-challenge',{'code':'000000'},expected=422);call(no_mfa,path,{},expected=401);ck('MFA inválido não permite instalação',True)
|
|
plan=call(a,path)['plan'];ck('Prévia nominal com coluna e ledger ausentes',plan['ready'] and not plan['installed'] and plan['migration']=='2026_10_18_160000_add_portal_editorial_content',{'target':plan['target'],'code_hash':plan['code_hash']})
|
|
payload={'hash':plan['hash'],'idempotency_key':str(uuid.uuid4()),'confirm':True}
|
|
call(a,path,{**payload,'actor_user_id':999},expected=422);call(a,path,{**payload,'migration':'outra'},expected=422);ck('Ator e migration arbitrários recusados',True)
|
|
installed=call(a,path,payload)['receipt'];ck('Instalação autenticada apenas160000 sem fichas alteradas',installed['changed'] and installed['business_records_changed']==0,installed)
|
|
replay=call(a,path,payload)['receipt'];ck('Repetição não reinstala; recibo idempotente',replay['replayed'] and replay['receipt']==installed['receipt'])
|
|
after=call(a,path)['plan'];ck('Estado final instalado e consistente',after['installed'] and after['consistent'])
|
|
except Exception as e:checks.append({'criterio':'Instalação nominal QA','resultado':'falhou','evidencia':str(e)})
|
|
finally:
|
|
(o/'PROVAS-INSTALACAO-QA.json').write_text(json.dumps({'target':'editorial_install_20261018_test:55441','checks':checks,'events':events,'active_changes':0,'accepted_tests_repeated':False},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))
|