Repository navigation
Expand file tree
/
Copy pathtest_cli.py
More file actions
42 lines (34 loc) · 1.62 KB
/
Copy pathtest_cli.py
File metadata and controls
42 lines (34 loc) · 1.62 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
"""Integration test suite for MazAPI Unified CLI."""
import json
import os
import subprocess
import sys
import unittest
class TestCLI(unittest.TestCase):
def run_cli(self, args):
cmd = [sys.executable, "api-security-project/cli.py"] + args
result = subprocess.run(cmd, capture_output=True, text=True, encoding="utf-8", errors="replace", cwd=os.path.abspath("."))
return result
def test_app_surface_cli(self):
res = self.run_cli(["app-surface", "scan", "api-security-project", "--format", "json"])
self.assertEqual(res.returncode, 0, f"Error: {res.stderr}")
data = json.loads(res.stdout)
self.assertIn("endpoints", data)
self.assertIn("total_endpoints", data)
def test_agent_audit_cli(self):
res = self.run_cli(["agent-audit", "scan", "api-security-project", "--format", "json", "--governance"])
self.assertEqual(res.returncode, 0, f"Error: {res.stderr}")
data = json.loads(res.stdout)
self.assertIn("findings", data)
self.assertIn("critical_count", data)
def test_mcp_audit_registry_cli(self):
res = self.run_cli(["mcp-audit", "registry"])
self.assertEqual(res.returncode, 0, f"Error: {res.stderr}")
self.assertIn("Known Model Context Protocol", res.stdout)
self.assertIn("postgres", res.stdout)
def test_mcp_audit_explain_cli(self):
res = self.run_cli(["mcp-audit", "explain", "shell-injection-in-source"])
self.assertEqual(res.returncode, 0, f"Error: {res.stderr}")
self.assertIn("Shell Injection in MCP Server", res.stdout)
if __name__ == "__main__":
unittest.main()