Files
mtusi2026lab7/scripts/prove-leaf.py
2026-11-18 11:36:21 +03:00

12 lines
1.0 KiB
Python

#!/usr/bin/env python3
import json,subprocess,sys
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1];sys.path.insert(0,str(ROOT/'scripts'));import security
before=json.loads(subprocess.check_output(['docker','inspect',security.compose('ps','-q','lb').stdout.strip()],text=True))[0]['Image']
subprocess.run([sys.executable,str(ROOT/'scripts/renew-leaf.py'),'lb'],check=True)
subprocess.run([sys.executable,str(ROOT/'scripts/wait-ready.py')],check=True)
security.probe('tls',target='https://api:8080/health/ready',material='lb-old',expect='deny')
security.probe('tls',target='https://api:8080/health/ready',material='lb')
after=json.loads(subprocess.check_output(['docker','inspect',security.compose('ps','-q','lb').stdout.strip()],text=True))[0]['Image'];assert before==after
(ROOT/'evidence/leaf-rotation.json').write_text(json.dumps({'image_unchanged':True,'old_leaf_rejected':True,'new_leaf_accepted':True,'verified_https_ready':True},indent=2)+'\n');print('PASS: leaf rotation without image rebuild and old-serial revocation')