-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cli_daily_driver.py
More file actions
58 lines (46 loc) · 1.85 KB
/
Copy pathtest_cli_daily_driver.py
File metadata and controls
58 lines (46 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""CLI --daily-driver emits the same envelope keys as MCP classification_bundle."""
import json
import subprocess
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
def _run_cli(*args: str) -> subprocess.CompletedProcess:
return subprocess.run(
[sys.executable, "-m", "src.cli", *args],
cwd=str(REPO_ROOT),
capture_output=True,
text=True,
check=False,
)
def test_daily_driver_single_has_mcp_envelope():
proc = _run_cli(
"--daily-driver",
"The attacker used prompt injection to exfiltrate the system prompt via markdown.",
)
assert proc.returncode == 0, proc.stderr
data = json.loads(proc.stdout)
assert data["source"] == "cli"
assert data["in_table"] is True
assert data["classifier_hit"] is True
assert data["response_contract"]["verdict_applicable"] is True
assert "fit_state" in data
assert "contributing_route" in data
assert "report_preparation" in data
assert "scientific_summary" in data
assert data["response_kind"] == "classification"
def test_daily_driver_lookup_has_envelope():
proc = _run_cli("--lookup", "ADV-INDIRECT-INJECT-122", "--daily-driver")
assert proc.returncode == 0, proc.stderr
data = json.loads(proc.stdout)
assert data["source"] == "cli"
assert data["response_kind"] == "class_lookup"
assert data["response_contract"]["verdict_applicable"] is False
def test_daily_driver_rejects_with_json():
proc = _run_cli("--json", "--daily-driver", "test")
assert proc.returncode != 0
def test_daily_driver_unknown_lookup_error_contract():
proc = _run_cli("--lookup", "NOT-A-REAL-ID-999", "--daily-driver")
assert proc.returncode == 1
data = json.loads(proc.stdout)
assert data["error"] == "unknown class id"
assert data["response_contract"]["error_response"] is True