35 lines
2.0 KiB
Python
35 lines
2.0 KiB
Python
"""Read-only documentary check; no application boot or database connection."""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import zipfile
|
|
|
|
d = Path(__file__).resolve().parent / 'para-revisao'
|
|
m = json.loads((d / 'MANIFESTO-CANDIDATA.json').read_text('utf-8'))
|
|
c = json.loads((d / 'MANIFESTO-COMPATIBILIDADE.json').read_text('utf-8'))
|
|
with zipfile.ZipFile(d / (m['candidate'] + '.zip')) as z:
|
|
def check(prefix, entries):
|
|
for path, digest in entries.items():
|
|
assert hashlib.sha256(z.read(prefix + path)).hexdigest() == digest, path
|
|
check('candidate/sources/', {x['path']: x['candidate_sha256'] for x in m['sources']})
|
|
check('candidate/build/', m['build'])
|
|
check('compatibility/sources/', c['application_files'])
|
|
check('compatibility/build/', c['build'])
|
|
for path, digest in c['retained_functional_sources'].items():
|
|
assert c['application_files'][path] == digest, path
|
|
base = {x['path']: x['before_sha256'] for x in m['sources'] if x['before_sha256']}
|
|
restored = {p: h for p, h in c['application_files'].items()
|
|
if p not in c['retained_functional_sources'] and p != c['migration_retained']}
|
|
assert len(restored) == 6 and all(base[p] == h for p, h in restored.items())
|
|
assert len(m['sources']) == 16 and len(base) == 11
|
|
assert len(c['retained_functional_sources']) == 7 and len(c['application_files']) == 14
|
|
assert len(m['build']) == len(c['build']) == 162
|
|
controller = z.read('compatibility/sources/app/Http/Controllers/InvestmentZoneController.php').decode('utf-8')
|
|
assert 'InvestmentZoneProfileInstallation::class' not in controller
|
|
assert 'InvestmentZoneOperationalProfile::class' in controller
|
|
print(json.dumps({'candidate': m['candidate'], 'manifest_to_ZIP_hashes': 'passed',
|
|
'candidate_artifacts': 16, 'previous_hashes': 11, 'absences': 5,
|
|
'retained_sources': 7, 'restored_base_sources': 6,
|
|
'compatibility_artifacts': 14, 'each_build_files': 162,
|
|
'application_boots': 0, 'database_connections': 0}))
|