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

18 lines
2.1 KiB
Python

from pathlib import Path
scope={'__file__':str(Path(__file__).parent/'test-QA.py')};exec((Path(__file__).parent/'test-QA.py').read_text('utf8').split('try:\n a=login')[0],scope);globals().update(scope)
try:
path='/management/editorial-installation/mfa';v=session();u=login('unprivileged');a=login('authorized')
call(v,path,expected=401);call(u,path,expected=403);ck('Sem sessão e sem permissão recusados',True)
call(a,path,expected=302);ck('MFA recente regressa à instalação sem novo desafio',True)
subprocess.run(['C:/Users/macbook/.config/investmoz/php-8.5.11/php.exe',str(o/'expire-mfa-QA.php'),str(f['actors']['authorized']['id'])],check=True,capture_output=True)
plan=call(a,'/management/editorial-installation')['plan'];ck('MFA expirado mantém sessão e bloqueia instalação',not plan['ready'] and any('MFA' in r for r in plan['reasons']))
view=call(a,path);ck('Desafio disponível sem logout',b'Confirmar MFA' in view)
call(a,path,{'code':'000000'},expected=422);call(a,path,{'code':'000000','actor_user_id':999},expected=422)
ck('Código inválido e substituição de ator recusados',not call(a,'/management/editorial-installation')['plan']['ready'])
time.sleep(31-int(time.time())%30)
actor=f['actors']['authorized'];b=hmac.new(base64.b32decode(actor['secret']),struct.pack('>Q',int(time.time()/30)),hashlib.sha1).digest();i=b[-1]&15;code=str((struct.unpack('>I',b[i:i+4])[0]&0x7fffffff)%1000000).zfill(6)
call(a,path,{'code':code},expected=302);plan=call(a,'/management/editorial-installation')['plan'];ck('Código real QA renova MFA e regressa ao instalador na mesma conta',plan['ready'],{'target':plan['target'],'code_hash':plan['code_hash'],'schema_execution':False})
except Exception as e:checks.append({'criterio':'Delta MFA','resultado':'falhou','evidencia':str(e)})
finally:
(o/'PROVAS-DELTA-MFA-QA.json').write_text(json.dumps({'target':'editorial_20261018_test:55441','checks':checks,'events':events,'active_changes':0,'schema_executions':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))