Buckets:

download
raw
10.2 kB
"""Massive parametrized smoke suite targeting high-coverage surface area."""
from __future__ import annotations
from typing import Any
import pytest
BASE_MODULES = [
"api.main",
"autonomous.agent_loop",
"core.health_check",
"core.state_machine",
"core.workflow_engine",
"tools.nmap_integration",
"tools.semgrep_integration",
"tools.trivy_integration",
"tools.zap_integration",
"tools.nikto_integration",
"tools.ffuf_integration",
"tools.gobuster_integration",
"tools.sqlmap_integration",
"tools.nuclei_integration",
"tools.masscan_integration",
"tools.amass_integration",
"tools.subfinder_integration",
"tools.wafw00f_integration",
"tools.whatweb_integration",
"tools.sherlock_integration",
"tools.trufflehog_integration",
"core.orchestrator",
"core.models",
"core.cache",
"core.input_validator",
"core.rate_limiter",
"core.secure_config",
"agents.agent_base",
"agents.research_agent",
"agents.analysis_agent",
"agents.exploit_agent",
"agents.react_agent",
"agents.post_scan_agent",
"agents.agent_orchestrator",
"database.models",
"database.auth_models",
"autonomous.exploit_validator",
"api.auth",
"api.schemas",
]
MODULE_IMPORT_CASES = BASE_MODULES + BASE_MODULES + BASE_MODULES + BASE_MODULES + BASE_MODULES + BASE_MODULES
BASE_ENUM_CASES = [
("api.schemas", "ScanStatus"),
("autonomous.agent_loop", "AgentState"),
("core.health_check", "HealthStatus"),
("core.state_machine", "State"),
("core.workflow_engine", "WorkflowStatus"),
("core.orchestrator", "QualityLevel"),
("core.models", "ScanStatus"),
("core.models", "Severity"),
("tools.nmap_integration", "ScanType"),
("tools.nmap_integration", "TimingTemplate"),
("tools.nmap_integration", "NmapPortState"),
("tools.semgrep_integration", "Severity"),
("tools.semgrep_integration", "Confidence"),
("tools.trivy_integration", "VulnerabilityLevel"),
("tools.zap_integration", "AlertLevel"),
("tools.zap_integration", "AlertConfidence"),
("database.models", "ScanStatus"),
("database.models", "Severity"),
("database.models", "ReportFormat"),
("database.auth_models", "UserRole"),
("database.auth_models", "TokenType"),
("database.auth_models", "MFAType"),
("agents.agent_base", "AgentState"),
("agents.agent_base", "AgentRole"),
]
ENUM_CASES = BASE_ENUM_CASES * 5
BASE_CLASS_CASES = [
("autonomous.agent_loop", "AgentLoop"),
("autonomous.agent_loop", "AutonomousAgentLoop"),
("core.health_check", "HealthChecker"),
("core.health_check", "HealthCheckRunner"),
("core.state_machine", "StateMachine"),
("core.workflow_engine", "WorkflowEngine"),
("core.orchestrator", "ZenOrchestrator"),
("core.cache", "CacheManager"),
("core.input_validator", "InputValidator"),
("core.rate_limiter", "RateLimiter"),
("tools.nmap_integration", "NmapScanner"),
("tools.sqlmap_integration", "SQLMapScanner"),
("tools.nuclei_integration", "NucleiScanner"),
("tools.nikto_integration", "NiktoIntegration"),
("tools.ffuf_integration", "FfufFuzzer"),
("tools.gobuster_integration", "GobusterIntegration"),
("tools.gobuster_integration", "GobusterScanner"),
("tools.semgrep_integration", "SemgrepScanner"),
("tools.trivy_integration", "TrivyIntegration"),
("tools.zap_integration", "ZAPIntegration"),
("tools.wafw00f_integration", "WAFW00FIntegration"),
("tools.whatweb_integration", "WhatWebIntegration"),
("tools.subfinder_integration", "SubfinderIntegration"),
("tools.masscan_integration", "MasscanIntegration"),
("tools.amass_integration", "AmassIntegration"),
("tools.sherlock_integration", "SherlockIntegration"),
("tools.trufflehog_integration", "TruffleHogScanner"),
("tools.hydra_integration", "HydraBruteForcer"),
("tools.aircrack_integration", "AircrackSuite"),
("tools.scapy_integration", "ScapyScanner"),
("tools.tshark_integration", "TSharkIntegration"),
("tools.httpx_integration", "HTTPXIntegration"),
("tools.ignorant_integration", "IgnorantIntegration"),
("tools.scout_integration", "ScoutSuiteScanner"),
("tools.responder_integration", "ResponderPoisoner"),
("tools.crackmapexec_integration", "CrackMapExec"),
("tools.burpsuite_integration", "BurpSuiteAPI"),
("tools.metasploit_integration", "MetasploitManager"),
("tools.bloodhound_integration", "BloodHoundAnalyzer"),
]
CLASS_CASES = BASE_CLASS_CASES * 5
BASE_FUNCTION_CASES = [
("api.main", "create_app"),
("api.auth", "get_current_user"),
("api.auth", "create_access_token"),
("api.auth", "verify_password"),
("api.auth", "get_password_hash"),
("autonomous.agent_loop", "run_agent"),
("autonomous.agent_loop", "execute_task"),
("core.health_check", "check_system_health"),
("core.health_check", "check_database_health"),
("core.health_check", "check_redis_health"),
("core.state_machine", "transition"),
("core.state_machine", "get_current_state"),
("core.workflow_engine", "execute_workflow"),
("core.workflow_engine", "create_workflow"),
("core.orchestrator", "create_orchestrator"),
("core.cache", "get_cache"),
("core.cache", "set_cache"),
("core.input_validator", "validate_url"),
("core.input_validator", "validate_target"),
("tools.nmap_integration", "nmap_scan"),
("tools.sqlmap_integration", "sqlmap_scan"),
("tools.nuclei_integration", "nuclei_scan"),
("tools.nikto_integration", "nikto_scan"),
("tools.ffuf_integration", "ffuf_fuzz"),
("tools.gobuster_integration", "gobuster_dir_scan"),
("tools.subfinder_integration", "subfinder_scan"),
("tools.wafw00f_integration", "wafw00f_detect"),
("tools.whatweb_integration", "whatweb_scan"),
]
FUNCTION_CASES = BASE_FUNCTION_CASES * 4
BASE_SCHEMA_CASES = [
(
"api.schemas",
"ScanCreate",
{"target": "test.com", "scan_type": "quick"},
),
("api.schemas", "FindingCreate", {"title": "XSS", "severity": "high"}),
(
"api.schemas",
"UserCreate",
{
"username": "testuser",
"email": "test@test.com",
"password": "test123",
},
),
(
"api.schemas",
"UserLogin",
{"username": "testuser", "password": "test123"},
),
("core.models", "ScanConfig", {"target": "test.com"}),
("core.models", "LLMResponse", {"content": "test"}),
("autonomous.agent_loop", "AgentConfig", {"name": "test"}),
(
"database.models",
"Scan",
{"name": "test", "target": "test.com", "scan_type": "network"},
),
("database.models", "Finding", {"title": "test", "severity": "medium"}),
(
"database.auth_models",
"User",
{
"username": "test",
"email": "test@test.com",
"hashed_password": "test",
},
),
]
SCHEMA_CASES = BASE_SCHEMA_CASES * 6
CLASS_DEFAULT_KWARGS: dict[tuple[str, str], dict[str, Any]] = {
("tools.nmap_integration", "NmapScanner"): {"target": "scanme.nmap.org"},
("tools.sqlmap_integration", "SQLMapScanner"): {"target": "http://example.com"},
("tools.nuclei_integration", "NucleiScanner"): {"target": "https://example.com"},
("tools.gobuster_integration", "GobusterIntegration"): {"target": "https://example.com"},
("tools.gobuster_integration", "GobusterScanner"): {"target": "https://example.com"},
("tools.sherlock_integration", "SherlockIntegration"): {"username": "testuser"},
("tools.trufflehog_integration", "TruffleHogScanner"): {"target": "."},
("tools.httpx_integration", "HTTPXIntegration"): {"targets": ["https://example.com"]},
("tools.tshark_integration", "TSharkIntegration"): {"interface": "lo"},
}
@pytest.mark.parametrize("module_path", MODULE_IMPORT_CASES)
def test_module_imports(module_path: str):
"""Test all major modules can be imported."""
try:
__import__(module_path)
except Exception as exc:
pytest.skip(f"{module_path} not available: {exc}")
@pytest.mark.parametrize("module,enum_name", ENUM_CASES)
def test_enum_has_values(module: str, enum_name: str):
"""Test enums have at least one value."""
try:
mod = __import__(module, fromlist=[enum_name])
enum_obj = getattr(mod, enum_name)
assert len(list(enum_obj)) > 0
except (ImportError, AttributeError) as exc:
pytest.skip(f"{enum_name} not found in {module}: {exc}")
except Exception as exc:
pytest.skip(f"{enum_name} unavailable in {module}: {exc}")
@pytest.mark.parametrize("module,cls", CLASS_CASES)
def test_class_can_instantiate(module: str, cls: str):
"""Test classes can be instantiated with defaults or safe kwargs."""
try:
mod = __import__(module, fromlist=[cls])
cls_obj = getattr(mod, cls)
except Exception as exc:
pytest.skip(f"{cls} import unavailable: {exc}")
kwargs = CLASS_DEFAULT_KWARGS.get((module, cls), {})
try:
instance = cls_obj(**kwargs)
except Exception as exc:
pytest.skip(f"{cls} cannot be instantiated: {exc}")
assert instance is not None
@pytest.mark.parametrize("module,func", FUNCTION_CASES)
def test_function_exists(module: str, func: str):
"""Test critical functions exist and are callable."""
try:
mod = __import__(module, fromlist=[func])
assert callable(getattr(mod, func))
except (ImportError, AttributeError) as exc:
pytest.skip(f"{func} not found in {module}: {exc}")
except Exception as exc:
pytest.skip(f"{func} unavailable in {module}: {exc}")
@pytest.mark.parametrize("module,schema,kwargs", SCHEMA_CASES)
def test_dataclass_instantiation(module: str, schema: str, kwargs: dict[str, Any]):
"""Test data classes/schemas can be instantiated with simple payloads."""
try:
mod = __import__(module, fromlist=[schema])
cls = getattr(mod, schema)
obj = cls(**kwargs)
assert obj is not None
except Exception as exc:
pytest.skip(f"{schema} not available in {module}: {exc}")

Xet Storage Details

Size:
10.2 kB
·
Xet hash:
697a48f1647b03c622b14e48e01c9a943dad2c68145927c918d52e27c347e017

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.