"""Smoke test: the runnable enforcement example actually blocks an undeclared tool."""
import os
import subprocess
import sys
from pathlib import Path

EXAMPLE = Path(__file__).parents[2] / "examples" / "enforced-agent" / "agent.py"
SRC = Path(__file__).parents[1] / "src"


def test_enforced_example_blocks_undeclared_tool(tmp_path):
    env = {**os.environ, "ABOM_KEY": str(tmp_path / "k.pem"), "PYTHONPATH": str(SRC)}
    p = subprocess.run([sys.executable, str(EXAMPLE)], capture_output=True, text=True,
                       timeout=60, env=env)
    assert p.returncode == 0, p.stdout + p.stderr
    assert "DENIED" in p.stdout
    assert "tool_not_in_manifest" in p.stdout
    assert "log verifies = True" in p.stdout
