"""Verify lab6 minimum survived TLS; query all real stores over mTLS.""" import base64 import json from pathlib import Path import sys import time import urllib.request import urllib.parse ROOT=Path(__file__).resolve().parents[1] sys.path.insert(0,str(ROOT/'student-tests')) from security import context,Client,CA,BASE,check,save,value def get(host,port,path): with urllib.request.urlopen('https://'+host+':'+str(port)+path,context=context('operator'),timeout=10) as response: return json.load(response) def main(): c=Client(BASE,CA,timeout=10) a,b,e,chat=c.bootstrap() raw=(ROOT/'tests/fixtures/sample.png').read_bytes() r=c.call('POST','/api/v1/chats/'+chat['id']+'/attachments?filename=sample.png',202,actor=a,raw=raw,headers={'Content-Type':'image/png'},schema='Attachment') tid=r['headers']['X-Trace-Id'];c.wait_ready(a,r['json']) until=time.monotonic()+60 while True: try: trace=get('tempo',3443,'/api/traces/'+tid) found=[(batch['resource'],span) for batch in trace['batches'] for scope in batch['scopeSpans'] for span in scope['spans']] if any(span['kind']=='SPAN_KIND_CONSUMER' for _,span in found):break except Exception:pass check(time.monotonic()