Buckets:

download
raw
27.5 kB
"""Comprehensive smoke/unit tests for project module coverage."""
from __future__ import annotations
import inspect
import pytest
class TestAPIModules:
"""Smoke tests for API modules."""
def test_import_api_main(self):
"""Import api.main module symbols."""
try:
from api.main import app # noqa: F401
except Exception as exc:
pytest.skip(f"api.main import unavailable: {exc}")
def test_import_api_auth(self):
"""Import api.auth module symbols."""
try:
from api.auth import create_access_token # noqa: F401
except Exception as exc:
pytest.skip(f"api.auth import unavailable: {exc}")
def test_import_api_schemas(self):
"""Import api.schemas module symbols."""
try:
from api.schemas import UserLogin # noqa: F401
except Exception as exc:
pytest.skip(f"api.schemas import unavailable: {exc}")
def test_api_app_exists(self):
"""Validate FastAPI app object exists."""
try:
from api.main import app
except Exception as exc:
pytest.skip(f"api.main app unavailable: {exc}")
assert app is not None
def test_api_auth_functions_exist(self):
"""Validate key auth functions are callable."""
try:
from api.auth import create_access_token, verify_password
except Exception as exc:
pytest.skip(f"api.auth functions unavailable: {exc}")
assert callable(create_access_token)
assert callable(verify_password)
def test_api_schema_class_instantiation(self):
"""Instantiate a simple API schema."""
try:
from api.schemas import UserLogin
except Exception as exc:
pytest.skip(f"api.schemas UserLogin unavailable: {exc}")
model = UserLogin(username="user123", password="pass123")
assert model is not None
class TestCoreModules:
"""Smoke tests for core modules."""
def test_import_core_orchestrator(self):
"""Import core.orchestrator."""
try:
from core.orchestrator import ZenOrchestrator # noqa: F401
except Exception as exc:
pytest.skip(f"core.orchestrator import unavailable: {exc}")
def test_import_core_health_check(self):
"""Import core.health_check."""
try:
from core.health_check import HealthChecker # noqa: F401
except Exception as exc:
pytest.skip(f"core.health_check import unavailable: {exc}")
def test_import_core_cache(self):
"""Import core.cache."""
try:
from core.cache import MemoryCache # noqa: F401
except Exception as exc:
pytest.skip(f"core.cache import unavailable: {exc}")
def test_import_core_input_validator(self):
"""Import core.input_validator."""
try:
from core.input_validator import InputValidator # noqa: F401
except Exception as exc:
pytest.skip(f"core.input_validator import unavailable: {exc}")
def test_import_core_models(self):
"""Import core.models."""
try:
from core.models import ScanConfig # noqa: F401
except Exception as exc:
pytest.skip(f"core.models import unavailable: {exc}")
def test_import_core_rate_limiter(self):
"""Import core.rate_limiter."""
try:
from core.rate_limiter import RateLimiter # noqa: F401
except Exception as exc:
pytest.skip(f"core.rate_limiter import unavailable: {exc}")
def test_import_core_secure_config(self):
"""Import core.secure_config."""
try:
from core.secure_config import get_settings # noqa: F401
except Exception as exc:
pytest.skip(f"core.secure_config import unavailable: {exc}")
def test_import_core_state_machine(self):
"""Import core.state_machine."""
try:
from core.state_machine import StateMachine # noqa: F401
except Exception as exc:
pytest.skip(f"core.state_machine import unavailable: {exc}")
def test_import_core_workflow_engine(self):
"""Import core.workflow_engine."""
try:
from core.workflow_engine import WorkflowEngine # noqa: F401
except Exception as exc:
pytest.skip(f"core.workflow_engine import unavailable: {exc}")
def test_zen_orchestrator_import(self):
"""Validate ZenOrchestrator import."""
try:
from core.orchestrator import ZenOrchestrator
except Exception as exc:
pytest.skip(f"ZenOrchestrator unavailable: {exc}")
assert inspect.isclass(ZenOrchestrator)
def test_quality_level_enum(self):
"""Validate QualityLevel enum values are present."""
try:
from core.orchestrator import QualityLevel
except Exception as exc:
pytest.skip(f"QualityLevel unavailable: {exc}")
members = {m.name for m in QualityLevel}
assert len(members) > 0
def test_llm_response_import(self):
"""Validate LLMResponse import."""
try:
from core.models import LLMResponse
except Exception as exc:
pytest.skip(f"LLMResponse unavailable: {exc}")
assert inspect.isclass(LLMResponse)
def test_core_scan_status_enum(self):
"""Validate core ScanStatus enum."""
try:
from core.models import ScanStatus
except Exception as exc:
pytest.skip(f"core ScanStatus unavailable: {exc}")
assert len(list(ScanStatus)) > 0
def test_core_severity_enum(self):
"""Validate core Severity enum."""
try:
from core.models import Severity
except Exception as exc:
pytest.skip(f"core Severity unavailable: {exc}")
assert len(list(Severity)) > 0
class TestAgentsModules:
"""Smoke tests for agent modules."""
def test_import_agent_base(self):
"""Import agents.agent_base."""
try:
from agents.agent_base import BaseAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.agent_base import unavailable: {exc}")
def test_import_research_agent(self):
"""Import agents.research_agent."""
try:
from agents.research_agent import ResearchAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.research_agent import unavailable: {exc}")
def test_import_analysis_agent(self):
"""Import agents.analysis_agent."""
try:
from agents.analysis_agent import AnalysisAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.analysis_agent import unavailable: {exc}")
def test_import_exploit_agent(self):
"""Import agents.exploit_agent."""
try:
from agents.exploit_agent import ExploitAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.exploit_agent import unavailable: {exc}")
def test_import_react_agent(self):
"""Import agents.react_agent."""
try:
from agents.react_agent import ReActAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.react_agent import unavailable: {exc}")
def test_import_post_scan_agent(self):
"""Import agents.post_scan_agent."""
try:
from agents.post_scan_agent import PostScanAgent # noqa: F401
except Exception as exc:
pytest.skip(f"agents.post_scan_agent import unavailable: {exc}")
def test_import_agent_orchestrator(self):
"""Import agents.agent_orchestrator."""
try:
from agents.agent_orchestrator import ( # noqa: F401
AgentOrchestrator,
)
except Exception as exc:
pytest.skip(f"agents.agent_orchestrator import unavailable: {exc}")
def test_base_agent_import(self):
"""Validate BaseAgent import."""
try:
from agents.agent_base import BaseAgent
except Exception as exc:
pytest.skip(f"BaseAgent unavailable: {exc}")
assert inspect.isclass(BaseAgent)
def test_agent_state_enum(self):
"""Validate AgentState enum."""
try:
from agents.agent_base import AgentState
except Exception as exc:
pytest.skip(f"AgentState unavailable: {exc}")
assert len(list(AgentState)) > 0
def test_agent_role_enum(self):
"""Validate AgentRole enum."""
try:
from agents.agent_base import AgentRole
except Exception as exc:
pytest.skip(f"AgentRole unavailable: {exc}")
assert len(list(AgentRole)) > 0
def test_agent_message_instantiation(self):
"""Instantiate AgentMessage dataclass."""
try:
from agents.agent_base import AgentMessage
except Exception as exc:
pytest.skip(f"AgentMessage unavailable: {exc}")
msg = AgentMessage(sender="a", recipient="b", content="c")
assert msg is not None
class TestDatabaseModules:
"""Smoke tests for database modules."""
def test_import_database_models(self):
"""Import database.models."""
try:
from database.models import Scan # noqa: F401
except Exception as exc:
pytest.skip(f"database.models import unavailable: {exc}")
def test_import_database_auth_models(self):
"""Import database.auth_models."""
try:
from database.auth_models import UserRole # noqa: F401
except Exception as exc:
pytest.skip(f"database.auth_models import unavailable: {exc}")
def test_import_database_crud(self):
"""Import database.crud."""
try:
from database.crud import create_scan # noqa: F401
except Exception as exc:
pytest.skip(f"database.crud import unavailable: {exc}")
def test_scan_status_enum(self):
"""Validate ScanStatus enum."""
try:
from database.models import ScanStatus
except Exception as exc:
pytest.skip(f"ScanStatus unavailable: {exc}")
assert len(list(ScanStatus)) > 0
def test_severity_enum(self):
"""Validate Severity enum."""
try:
from database.models import Severity
except Exception as exc:
pytest.skip(f"Severity unavailable: {exc}")
assert len(list(Severity)) > 0
def test_report_format_enum(self):
"""Validate ReportFormat enum."""
try:
from database.models import ReportFormat
except Exception as exc:
pytest.skip(f"ReportFormat unavailable: {exc}")
assert len(list(ReportFormat)) > 0
def test_user_role_enum(self):
"""Validate UserRole enum."""
try:
from database.auth_models import UserRole
except Exception as exc:
pytest.skip(f"UserRole unavailable: {exc}")
assert len(list(UserRole)) > 0
def test_token_type_enum(self):
"""Validate TokenType enum."""
try:
from database.auth_models import TokenType
except Exception as exc:
pytest.skip(f"TokenType unavailable: {exc}")
assert len(list(TokenType)) > 0
def test_mfa_type_enum(self):
"""Validate MFAType enum."""
try:
from database.auth_models import MFAType
except Exception as exc:
pytest.skip(f"MFAType unavailable: {exc}")
assert len(list(MFAType)) > 0
def test_scan_model_instantiation(self):
"""Instantiate Scan model with required fields."""
try:
from database.models import Scan
except Exception as exc:
pytest.skip(f"Scan model unavailable: {exc}")
scan = Scan(name="t", target="example.com", scan_type="network")
assert scan is not None
class TestToolsModules:
"""Smoke tests for tool modules."""
def test_import_nmap_integration(self):
"""Import tools.nmap_integration."""
try:
from tools.nmap_integration import NmapScanner # noqa: F401
except Exception as exc:
pytest.skip(f"nmap integration unavailable: {exc}")
def test_import_sqlmap_integration(self):
"""Import tools.sqlmap_integration."""
try:
from tools.sqlmap_integration import SQLMapScanner # noqa: F401
except Exception as exc:
pytest.skip(f"sqlmap integration unavailable: {exc}")
def test_import_nuclei_integration(self):
"""Import tools.nuclei_integration."""
try:
from tools.nuclei_integration import NucleiScanner # noqa: F401
except Exception as exc:
pytest.skip(f"nuclei integration unavailable: {exc}")
def test_import_nikto_integration(self):
"""Import tools.nikto_integration."""
try:
from tools.nikto_integration import NiktoIntegration # noqa: F401
except Exception as exc:
pytest.skip(f"nikto integration unavailable: {exc}")
def test_import_gobuster_integration(self):
"""Import tools.gobuster_integration."""
try:
from tools.gobuster_integration import ( # noqa: F401
GobusterScanner,
)
except Exception as exc:
pytest.skip(f"gobuster integration unavailable: {exc}")
def test_import_ffuf_integration(self):
"""Import tools.ffuf_integration."""
try:
from tools.ffuf_integration import FfufFuzzer # noqa: F401
except Exception as exc:
pytest.skip(f"ffuf integration unavailable: {exc}")
def test_import_subfinder_integration(self):
"""Import tools.subfinder_integration."""
try:
from tools.subfinder_integration import ( # noqa: F401
SubfinderIntegration,
)
except Exception as exc:
pytest.skip(f"subfinder integration unavailable: {exc}")
def test_import_whatweb_integration(self):
"""Import tools.whatweb_integration."""
try:
from tools.whatweb_integration import ( # noqa: F401
WhatWebIntegration,
)
except Exception as exc:
pytest.skip(f"whatweb integration unavailable: {exc}")
def test_import_wafw00f_integration(self):
"""Import tools.wafw00f_integration."""
try:
from tools.wafw00f_integration import ( # noqa: F401
WAFW00FIntegration,
)
except Exception as exc:
pytest.skip(f"wafw00f integration unavailable: {exc}")
def test_import_amass_integration(self):
"""Import tools.amass_integration."""
try:
from tools.amass_integration import AmassIntegration # noqa: F401
except Exception as exc:
pytest.skip(f"amass integration unavailable: {exc}")
def test_import_masscan_integration(self):
"""Import tools.masscan_integration."""
try:
from tools.masscan_integration import ( # noqa: F401
MasscanIntegration,
)
except Exception as exc:
pytest.skip(f"masscan integration unavailable: {exc}")
def test_import_hydra_integration(self):
"""Import tools.hydra_integration."""
try:
from tools.hydra_integration import HydraBruteForcer # noqa: F401
except Exception as exc:
pytest.skip(f"hydra integration unavailable: {exc}")
def test_import_sherlock_integration(self):
"""Import tools.sherlock_integration."""
try:
from tools.sherlock_integration import ( # noqa: F401
SherlockIntegration,
)
except Exception as exc:
pytest.skip(f"sherlock integration unavailable: {exc}")
def test_import_trufflehog_integration(self):
"""Import tools.trufflehog_integration."""
try:
from tools.trufflehog_integration import ( # noqa: F401
TruffleHogScanner,
)
except Exception as exc:
pytest.skip(f"trufflehog integration unavailable: {exc}")
def test_import_semgrep_integration(self):
"""Import tools.semgrep_integration."""
try:
from tools.semgrep_integration import SemgrepScanner # noqa: F401
except Exception as exc:
pytest.skip(f"semgrep integration unavailable: {exc}")
def test_import_trivy_integration(self):
"""Import tools.trivy_integration."""
try:
from tools.trivy_integration import TrivyIntegration # noqa: F401
except Exception as exc:
pytest.skip(f"trivy integration unavailable: {exc}")
def test_import_zap_integration(self):
"""Import tools.zap_integration."""
try:
from tools.zap_integration import ZAPIntegration # noqa: F401
except Exception as exc:
pytest.skip(f"zap integration unavailable: {exc}")
def test_import_burpsuite_integration(self):
"""Import tools.burpsuite_integration."""
try:
from tools.burpsuite_integration import BurpSuiteAPI # noqa: F401
except Exception as exc:
pytest.skip(f"burpsuite integration unavailable: {exc}")
def test_import_metasploit_integration(self):
"""Import tools.metasploit_integration."""
try:
from tools.metasploit_integration import ( # noqa: F401
MetasploitManager,
)
except Exception as exc:
pytest.skip(f"metasploit integration unavailable: {exc}")
def test_import_bloodhound_integration(self):
"""Import tools.bloodhound_integration."""
try:
from tools.bloodhound_integration import ( # noqa: F401
BloodHoundAnalyzer,
)
except Exception as exc:
pytest.skip(f"bloodhound integration unavailable: {exc}")
def test_import_cme_integration(self):
"""Import tools.crackmapexec_integration."""
try:
from tools.crackmapexec_integration import ( # noqa: F401
CrackMapExec,
)
except Exception as exc:
pytest.skip(f"cme integration unavailable: {exc}")
def test_import_responder_integration(self):
"""Import tools.responder_integration."""
try:
from tools.responder_integration import ( # noqa: F401
ResponderPoisoner,
)
except Exception as exc:
pytest.skip(f"responder integration unavailable: {exc}")
def test_import_aircrack_integration(self):
"""Import tools.aircrack_integration."""
try:
from tools.aircrack_integration import AircrackSuite # noqa: F401
except Exception as exc:
pytest.skip(f"aircrack integration unavailable: {exc}")
def test_import_scapy_integration(self):
"""Import tools.scapy_integration."""
try:
from tools.scapy_integration import ScapyScanner # noqa: F401
except Exception as exc:
pytest.skip(f"scapy integration unavailable: {exc}")
def test_import_tshark_integration(self):
"""Import tools.tshark_integration."""
try:
from tools.tshark_integration import ( # noqa: F401
TSharkIntegration,
)
except Exception as exc:
pytest.skip(f"tshark integration unavailable: {exc}")
def test_import_httpx_integration(self):
"""Import tools.httpx_integration."""
try:
from tools.httpx_integration import HTTPXIntegration # noqa: F401
except Exception as exc:
pytest.skip(f"httpx integration unavailable: {exc}")
def test_import_ignorant_integration(self):
"""Import tools.ignorant_integration."""
try:
from tools.ignorant_integration import ( # noqa: F401
IgnorantIntegration,
)
except Exception as exc:
pytest.skip(f"ignorant integration unavailable: {exc}")
def test_import_scout_integration(self):
"""Import tools.scout_integration."""
try:
from tools.scout_integration import ScoutSuiteScanner # noqa: F401
except Exception as exc:
pytest.skip(f"scout integration unavailable: {exc}")
def test_tool_registry_exists(self):
"""Validate TOOL_REGISTRY exists."""
try:
from tools import TOOL_REGISTRY
except Exception as exc:
pytest.skip(f"TOOL_REGISTRY unavailable: {exc}")
assert TOOL_REGISTRY is not None
def test_nmap_scanner_import(self):
"""Validate NmapScanner import."""
try:
from tools.nmap_integration import NmapScanner
except Exception as exc:
pytest.skip(f"NmapScanner unavailable: {exc}")
assert inspect.isclass(NmapScanner)
def test_sqlmap_scanner_import(self):
"""Validate SQLMapScanner import."""
try:
from tools.sqlmap_integration import SQLMapScanner
except Exception as exc:
pytest.skip(f"SQLMapScanner unavailable: {exc}")
assert inspect.isclass(SQLMapScanner)
def test_nuclei_scanner_import(self):
"""Validate NucleiScanner import."""
try:
from tools.nuclei_integration import NucleiScanner
except Exception as exc:
pytest.skip(f"NucleiScanner unavailable: {exc}")
assert inspect.isclass(NucleiScanner)
class TestAutonomousModules:
"""Smoke tests for autonomous modules."""
def test_import_agent_loop(self):
"""Import autonomous.agent_loop."""
try:
from autonomous.agent_loop import AutonomousAgentLoop # noqa: F401
except Exception as exc:
pytest.skip(f"agent_loop import unavailable: {exc}")
def test_import_exploit_validator(self):
"""Import autonomous.exploit_validator."""
try:
from autonomous.exploit_validator import ( # noqa: F401
ExploitValidator,
)
except Exception as exc:
pytest.skip(f"exploit_validator import unavailable: {exc}")
def test_agent_loop_import(self):
"""Validate AutonomousAgentLoop import."""
try:
from autonomous.agent_loop import AutonomousAgentLoop
except Exception as exc:
pytest.skip(f"AutonomousAgentLoop unavailable: {exc}")
assert inspect.isclass(AutonomousAgentLoop)
@pytest.mark.parametrize(
"module_name,symbol_name",
[
("api.main", "app"),
("api.auth", "create_access_token"),
("api.schemas", "UserLogin"),
("core.orchestrator", "ZenOrchestrator"),
("core.models", "LLMResponse"),
("agents.agent_base", "BaseAgent"),
("database.models", "Scan"),
("database.auth_models", "UserRole"),
("autonomous.agent_loop", "AutonomousAgentLoop"),
("autonomous.exploit_validator", "ExploitValidator"),
("tools.nmap_integration", "NmapScanner"),
("tools.sqlmap_integration", "SQLMapScanner"),
("tools.nuclei_integration", "NucleiScanner"),
("tools.nikto_integration", "NiktoIntegration"),
("tools.gobuster_integration", "GobusterScanner"),
("tools.ffuf_integration", "FfufFuzzer"),
("tools.subfinder_integration", "SubfinderIntegration"),
("tools.whatweb_integration", "WhatWebIntegration"),
("tools.wafw00f_integration", "WAFW00FIntegration"),
("tools.httpx_integration", "HTTPXIntegration"),
],
)
def test_symbol_smoke_imports(module_name, symbol_name):
"""Parametrized symbol existence smoke tests."""
try:
module = __import__(module_name, fromlist=[symbol_name])
except Exception as exc:
pytest.skip(f"{module_name} unavailable: {exc}")
symbol = getattr(module, symbol_name, None)
assert symbol is not None
@pytest.mark.parametrize(
"enum_module,enum_name",
[
("agents.agent_base", "AgentRole"),
("agents.agent_base", "AgentState"),
("core.models", "Severity"),
("core.models", "ScanStatus"),
("core.orchestrator", "QualityLevel"),
("database.models", "ScanStatus"),
("database.models", "Severity"),
("database.models", "ReportFormat"),
("database.auth_models", "UserRole"),
("database.auth_models", "TokenType"),
("database.auth_models", "MFAType"),
("autonomous.agent_loop", "AgentState"),
("autonomous.agent_loop", "ToolType"),
("tools.nmap_integration", "ScanType"),
("tools.nmap_integration", "TimingTemplate"),
("tools.semgrep_integration", "SemgrepSeverity"),
("tools.semgrep_integration", "SemgrepConfidence"),
("tools.scout_integration", "CloudProvider"),
("tools.trivy_integration", "TrivyScannerType"),
("tools.zap_integration", "ZAPAlertRisk"),
],
)
def test_enum_has_members(enum_module, enum_name):
"""Parametrized enum smoke tests."""
try:
module = __import__(enum_module, fromlist=[enum_name])
except Exception as exc:
pytest.skip(f"{enum_module} unavailable: {exc}")
enum_obj = getattr(module, enum_name, None)
if enum_obj is None:
pytest.skip(f"{enum_name} unavailable in {enum_module}")
assert len(list(enum_obj)) > 0
@pytest.mark.parametrize(
"module_name,class_name",
[
("tools.nmap_integration", "NmapScanner"),
("tools.sqlmap_integration", "SQLMapScanner"),
("tools.nuclei_integration", "NucleiScanner"),
("tools.nikto_integration", "NiktoIntegration"),
("tools.ffuf_integration", "FfufFuzzer"),
("tools.httpx_integration", "HTTPXIntegration"),
("tools.masscan_integration", "MasscanIntegration"),
("tools.sherlock_integration", "SherlockIntegration"),
("tools.semgrep_integration", "SemgrepScanner"),
("tools.trivy_integration", "TrivyIntegration"),
("tools.zap_integration", "ZAPIntegration"),
("tools.wafw00f_integration", "WAFW00FIntegration"),
("tools.scout_integration", "ScoutSuiteScanner"),
("tools.ignorant_integration", "IgnorantIntegration"),
("tools.scapy_integration", "ScapyScanner"),
("tools.responder_integration", "ResponderPoisoner"),
("tools.aircrack_integration", "AircrackSuite"),
("tools.crackmapexec_integration", "CrackMapExec"),
("tools.amass_integration", "AmassIntegration"),
("tools.tshark_integration", "TSharkIntegration"),
],
)
def test_class_instantiation_smoke(module_name, class_name):
"""Parametrized class instantiation smoke tests."""
try:
module = __import__(module_name, fromlist=[class_name])
except Exception as exc:
pytest.skip(f"{module_name} unavailable: {exc}")
cls = getattr(module, class_name, None)
if cls is None:
pytest.skip(f"{class_name} unavailable in {module_name}")
try:
obj = cls()
except Exception as exc:
pytest.skip(f"{class_name} could not instantiate with defaults: {exc}")
assert obj is not None

Xet Storage Details

Size:
27.5 kB
·
Xet hash:
fd375993b5f50f83e4b04284996f1be61e6237ab63033add9415311cbc28e291

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