Files
Investidor-V2/tools/opportunity-workflow-multirole-http-qa.py
T
nala 01405cbf8a
tests / ci (push) Canceled after 0s
oportunidades 5
2026-10-10 14:15:28 +02:00

32 lines
2.3 KiB
Python

"""Temporary synthetic QA role accumulation; revoke temporary grants and retain all history."""
import importlib.util
from pathlib import Path
import json
from datetime import datetime, timezone
spec=importlib.util.spec_from_file_location('workflow_support',Path(__file__).with_name('opportunity-workflow-http-qa.py'))
m=importlib.util.module_from_spec(spec);spec.loader.exec_module(m)
proof={'target':m.EXPECTED,'active_writes':0,'visual_pending':True,'started_at':datetime.now(timezone.utc).isoformat()}
previous=json.loads((m.PRIVATE/'opportunity-workflow-http-qa.json').read_text())
land=next(c for c in previous['cases'] if c['category']=='land_rights')
grants=[]
try:
for actor,role,types in [('promoter','validator',['land_rights']),('promoter','publisher',['land_rights']),('validator','publisher',['land_rights'])]:
g=m.superuser.call('POST','/perfis/atribuicoes',{'user_id':m.actors[actor]['id'],'role':role,'opportunity_types':types,
'responsibilities':[],'reason':'Acumulação temporária de papéis em conta sintética QA para verificar negações'},status=201)
grants.append(g['id'])
author=m.Session('promoter').login();approver=m.Session('validator').login()
m.transition(author,land['id'],'approve',status=403)
m.transition(author,land['id'],'publish',status=403)
m.transition(approver,land['id'],'publish',status=403)
m.transition(m.sessions['multiple'],land['id'],'approve',status=403)
proof['denials']={'author_with_promoter_validator_publisher':403,'approver_with_validator_publisher':403,'organization_contributor_with_auditor':403}
proof['result']='passed'
finally:
for id in grants:
m.superuser.call('POST','/perfis/atribuicoes/'+id+'/revogar',{'reason':'Conclusão do ensaio sintético de acumulação; histórico da atribuição preservado'})
fresh=m.Session('promoter').login();fresh.call('GET','/dashboard',inertia=True)
proof['temporary_grants_revoked']=len(grants);proof['promoter_new_mfa_session_after_revocation']=True;proof['events']=m.events;proof['completed_at']=datetime.now(timezone.utc).isoformat()
(m.PRIVATE/'opportunity-workflow-multirole-http-qa.json').write_text(json.dumps(proof,indent=2),encoding='utf-8')
print(json.dumps({'result':proof['result'],'target':m.EXPECTED,'temporary_grants_revoked':len(grants),'active_writes':0,'visual_pending':True}))