62 lines
3.8 KiB
Python
62 lines
3.8 KiB
Python
"""Normal HTTP proof of the same four pilot choices, preserving context boundaries."""
|
|
import importlib.util
|
|
import hashlib
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
spec = importlib.util.spec_from_file_location('native', '/root/check-public-demonstration.py')
|
|
native = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(native)
|
|
credentials = json.loads(Path('/root/compras-demo-access.json').read_text())
|
|
origin = 'https://compras.tempo.co.mz'
|
|
admin = native.Client(credentials['admin'], origin)
|
|
expected = ['procurement.internal', 'procurement.sales', 'people.internal', 'people.third_party']
|
|
assert admin.work_context['enforced'] and admin.work_context['available'] == expected
|
|
admin.work_context = {} # This exercise selects every context explicitly, without helper selection.
|
|
checks = []
|
|
for option in expected:
|
|
area = option.split('.')[0]
|
|
selection = admin.request('/contexto', 'POST', {'area': area, 'option': option})
|
|
assert selection['status'] in [302, 303]
|
|
page = admin.request('/dashboard')
|
|
assert page['status'] == 200 and page['page']['component'] == 'work-context'
|
|
context = page['page']['props']['context']
|
|
assert context['active'] == option and context['available'] == expected
|
|
path = '/requisicoes' if area == 'procurement' else '/pessoas'
|
|
operational = option in ['procurement.internal', 'people.internal', 'people.third_party']
|
|
assert context['options'][option]['operational'] == operational
|
|
result = admin.request(path)
|
|
if operational:
|
|
assert result['status'] == 200
|
|
collection = 'requisitions' if area == 'procurement' else 'processes'
|
|
assert result['page']['props'][collection]['total'] > 0
|
|
opposite = admin.request('/pessoas' if area == 'procurement' else '/requisicoes')
|
|
assert opposite['status'] == 403
|
|
else:
|
|
assert result['status'] == 302 and result['location'].endswith('/dashboard')
|
|
assert admin.request(path, 'POST', {})['status'] == 409
|
|
checks.append({'context': option, 'selected_on_dashboard': True, 'operational': operational,
|
|
'records_visible_in_selected_context': operational, 'cross_context_or_unimplemented_operation_refused': True})
|
|
buyer = native.Client(credentials['procurement'], origin)
|
|
assert buyer.work_context['available'] == ['procurement.internal', 'procurement.sales']
|
|
assert buyer.request('/contexto', 'POST', {'area': 'people', 'option': 'people.internal'})['status'] == 403
|
|
pins = json.loads(subprocess.check_output(['/usr/bin/php', '/var/www/compras-deploy/current/scripts/private-audit-transition-pins.php']))['2']
|
|
auditor = native.Client(credentials['auditor'], origin)
|
|
requester = native.Client(credentials['requester'], origin)
|
|
exports = auditor.request('/auditoria/privada')['page']['props']['exports']['data']
|
|
visible = {str(export['id']): export for export in exports}
|
|
for identifier, digest in pins.items():
|
|
assert identifier in visible
|
|
url = visible[identifier]['download_url']
|
|
response = auditor.request(url, inertia=False)
|
|
assert response['status'] == 200 and hashlib.sha256(response['raw']).hexdigest() == digest
|
|
assert requester.request(url)['status'] == 403
|
|
proof = {'state': 'passed', 'release_id': json.loads(Path('/var/www/compras-deploy/current/compras-release.json').read_text())['release_id'],
|
|
'same_four_pilot_choices': True, 'normal_credential_login': True, 'checks': checks,
|
|
'buyer_people_context_refused': True, 'original_audit_archives_visible_and_download_hashes_verified': len(pins),
|
|
'unauthorized_archive_downloads_refused': len(pins), 'business_mutations_executed': False,
|
|
'third_party_options_claimed_complete': False}
|
|
Path('/var/www/compras-deploy/demonstration-20261129/pilot-contexts-http.json').write_text(json.dumps(proof, indent=2)+'\n')
|
|
print(json.dumps(proof, indent=2))
|