"""Verify provisioned dashboards using authenticated HTTPS without exporting credentials.""" from pathlib import Path import json,ssl,urllib.request,base64 ROOT=Path(__file__).resolve().parents[1] ctx=ssl.create_default_context(cafile=str(ROOT/'certs/ca.crt')) password=(ROOT/'secrets/grafana_password').read_text().strip() headers={'Authorization':'Basic '+base64.b64encode(('admin:'+password).encode()).decode()} def get(path): with urllib.request.urlopen(urllib.request.Request('https://localhost:3447'+path,headers=headers),context=ctx,timeout=20) as r:return json.load(r) dashboard=get('/api/dashboards/uid/messenger-lab7') assert len(dashboard['dashboard']['panels'])==9 result={'dashboard_uid':'messenger-lab7','panel_count':9,'datasources':{}} for name,path in [('prometheus','/api/v1/query?query=messenger_http_requests_total'),('loki','/loki/api/v1/labels'),('tempo','/api/search?limit=5')]: value=get('/api/datasources/proxy/uid/'+name+path) assert value result['datasources'][name]='verified HTTPS/mTLS query via Grafana' (ROOT/'evidence/grafana.json').write_text(json.dumps(result,indent=2)+'\n',encoding='utf8') print('PASS: authenticated Grafana HTTPS, nine provisioned panels, real queries through all three TLS/mTLS data sources.')