#!/usr/bin/env python3 """Test Agent: guard test — verify /api/cron/list health and /cron page guard presence.""" import json import subprocess import pytest BASE_URL = "http://127.0.0.1:5001" def _curl_html(path): r = subprocess.run( ["curl", "-s", f"{BASE_URL}{path}"], capture_output=True, text=True, timeout=10, ) return int(r.returncode), r.stdout def _curl_status_body(path): r = subprocess.run( ["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", f"{BASE_URL}{path}"], capture_output=True, text=True, timeout=10, ) status = int(r.stdout.strip() or 0) r2 = subprocess.run( ["curl", "-s", f"{BASE_URL}{path}"], capture_output=True, text=True, timeout=10, ) try: body = json.loads(r2.stdout) if r2.stdout.strip() else {} except Exception: body = {"_raw": r2.stdout[:200]} return status, body def test_cron_page_guard_reachable(): rc, html = _curl_html("/cron") assert rc == 0 assert "