Buckets:

download
raw
9.37 kB
"""
Simple Tests for tool integrations - Coverage Boost
"""
import asyncio
from unittest.mock import Mock
import pytest
class MockTool:
"""Mock tool for testing"""
def __init__(self, name, description=""):
self.name = name
self.description = description
self.execute = Mock(return_value={"result": "success"})
class TestToolRegistry:
"""Test Tool Registry functionality"""
def test_tool_registry_singleton(self):
"""Test ToolRegistry is singleton"""
from tools.tool_registry import ToolRegistry
reg1 = ToolRegistry()
reg2 = ToolRegistry()
# Should be same instance (singleton)
assert reg1 is reg2
def test_register_and_get_tool(self):
"""Test registering and getting a tool"""
from tools.tool_registry import ToolCategory, ToolRegistry
registry = ToolRegistry()
mock_tool = MockTool(name="test_tool", description="Test tool")
# Register with valid category
registry.register(mock_tool, category=ToolCategory.RECONNAISSANCE)
result = registry.get("test_tool")
assert result is not None
assert result.tool.name == "test_tool"
def test_get_nonexistent_tool(self):
"""Test getting non-existent tool"""
from tools.tool_registry import ToolRegistry
registry = ToolRegistry()
result = registry.get("nonexistent")
assert result is None
def test_list_tools(self):
"""Test listing registered tools"""
from tools.tool_registry import ToolRegistry
registry = ToolRegistry()
tools = registry.list_tools()
assert isinstance(tools, list)
class TestToolCaller:
"""Test Tool Caller functionality"""
def test_tool_caller_init(self):
"""Test ToolCaller initialization"""
from tools.tool_caller import ToolCaller
caller = ToolCaller()
assert caller is not None
def test_tool_caller_has_call_method(self):
"""Test ToolCaller has call method"""
from tools.tool_caller import ToolCaller
caller = ToolCaller()
assert hasattr(caller, "call_tool")
class TestNmapIntegration:
"""Test Nmap integration"""
def test_nmap_port_dataclass(self):
"""Test NmapPort dataclass"""
from tools.nmap_integration import NmapPort
port = NmapPort(port=80, protocol="tcp", state="open", service="http")
assert port.port == 80
assert port.protocol == "tcp"
assert port.state == "open"
assert port.service == "http"
def test_nmap_host_dataclass(self):
"""Test NmapHost dataclass"""
from tools.nmap_integration import NmapHost
host = NmapHost(ip="192.168.1.1", hostname="test.local", status="up")
assert host.ip == "192.168.1.1"
assert host.hostname == "test.local"
assert host.status == "up"
def test_nmap_result_dataclass(self):
"""Test NmapResult dataclass"""
from tools.nmap_integration import NmapHost, NmapResult
result = NmapResult(
success=True,
hosts=[NmapHost(ip="192.168.1.1")],
command="nmap 192.168.1.1",
)
assert result.success is True
assert len(result.hosts) == 1
def test_scan_type_enum(self):
"""Test ScanType enum"""
from tools.nmap_integration import ScanType
assert ScanType.SYN.value == "-sS"
assert ScanType.CONNECT.value == "-sT"
assert ScanType.UDP.value == "-sU"
def test_timing_template_enum(self):
"""Test TimingTemplate enum"""
from tools.nmap_integration import TimingTemplate
assert TimingTemplate.NORMAL.value == "-T3"
assert TimingTemplate.AGGRESSIVE.value == "-T4"
class TestAsyncOperations:
"""Test async operations"""
@pytest.mark.asyncio
async def test_async_execution(self):
"""Test basic async execution"""
async def async_func():
await asyncio.sleep(0.01)
return "completed"
result = await async_func()
assert result == "completed"
@pytest.mark.asyncio
async def test_concurrent_execution(self):
"""Test concurrent async execution"""
async def task(id):
await asyncio.sleep(0.01)
return f"task-{id}"
results = await asyncio.gather(task(1), task(2), task(3))
assert len(results) == 3
assert "task-1" in results
@pytest.mark.asyncio
async def test_async_with_timeout(self):
"""Test async with timeout"""
async def slow_task():
await asyncio.sleep(10)
return "done"
try:
await asyncio.wait_for(slow_task(), timeout=0.1)
assert False, "Should have timed out"
except asyncio.TimeoutError:
pass # Expected
class TestToolChecker:
"""Test Tool Checker"""
def test_tool_checker_import(self):
"""Test Tool Checker module import"""
try:
from tools.integrations import tool_checker
assert True
except ImportError:
pytest.skip("Tool checker not available")
class TestNucleiIntegration:
"""Test Nuclei integration"""
def test_nuclei_basic(self):
"""Test basic Nuclei import"""
try:
from tools import nuclei_integration
assert hasattr(nuclei_integration, "NucleiScanner")
except ImportError:
pytest.skip("Nuclei integration not available")
class TestSubfinderIntegration:
"""Test Subfinder integration"""
def test_subfinder_basic(self):
"""Test basic Subfinder import"""
try:
from tools import subfinder_integration
assert True
except ImportError:
pytest.skip("Subfinder integration not available")
class TestHttpxIntegration:
"""Test Httpx integration"""
def test_httpx_basic(self):
"""Test basic Httpx import"""
try:
from tools import httpx_integration
assert True
except ImportError:
pytest.skip("Httpx integration not available")
class TestNiktoIntegration:
"""Test Nikto integration"""
def test_nikto_basic(self):
"""Test basic Nikto import"""
try:
from tools import nikto_integration
assert True
except ImportError:
pytest.skip("Nikto integration not available")
class TestGobusterIntegration:
"""Test Gobuster integration"""
def test_gobuster_basic(self):
"""Test basic Gobuster import"""
try:
from tools import gobuster_integration
assert True
except ImportError:
pytest.skip("Gobuster integration not available")
class TestAmassIntegration:
"""Test Amass integration"""
def test_amass_basic(self):
"""Test basic Amass import"""
try:
from tools import amass_integration
assert True
except ImportError:
pytest.skip("Amass integration not available")
class TestSherlockIntegration:
"""Test Sherlock integration"""
def test_sherlock_basic(self):
"""Test basic Sherlock import"""
try:
from tools import sherlock_integration
assert True
except ImportError:
pytest.skip("Sherlock integration not available")
class TestFFUFIntegration:
"""Test FFUF integration"""
def test_ffuf_basic(self):
"""Test basic FFUF import"""
try:
from tools import ffuf_integration_enhanced
assert True
except ImportError:
pytest.skip("FFUF integration not available")
class TestWafw00fIntegration:
"""Test Wafw00f integration"""
def test_wafw00f_basic(self):
"""Test basic Wafw00f import"""
try:
from tools import wafw00f_integration
assert True
except ImportError:
pytest.skip("Wafw00f integration not available")
class TestWhatwebIntegration:
"""Test Whatweb integration"""
def test_whatweb_basic(self):
"""Test basic Whatweb import"""
try:
from tools import whatweb_integration
assert True
except ImportError:
pytest.skip("Whatweb integration not available")
class TestMasscanIntegration:
"""Test Masscan integration"""
def test_masscan_basic(self):
"""Test basic Masscan import"""
try:
from tools import masscan_integration
assert True
except ImportError:
pytest.skip("Masscan integration not available")
class TestTsharkIntegration:
"""Test Tshark integration"""
def test_tshark_basic(self):
"""Test basic Tshark import"""
try:
from tools import tshark_integration
assert True
except ImportError:
pytest.skip("Tshark integration not available")
class TestIgnorantIntegration:
"""Test Ignorant integration"""
def test_ignorant_basic(self):
"""Test basic Ignorant import"""
try:
from tools import ignorant_integration
assert True
except ImportError:
pytest.skip("Ignorant integration not available")

Xet Storage Details

Size:
9.37 kB
·
Xet hash:
fd6036bbd922b6d95615cb891b14657b629a073327379b586431ba8cd3f4416a

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