Buckets:

download
raw
30.5 kB
"""
Comprehensive Tests for Subdomain Scanner Module
This module tests the SubdomainScanner class which provides
advanced subdomain enumeration capabilities.
Target Coverage: 70%+
"""
import asyncio
import json
from datetime import datetime
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
from modules.subdomain_scanner import (
SubdomainResult,
SubdomainScanner,
scan_subdomains,
)
class TestSubdomainResult:
"""Test SubdomainResult dataclass"""
def test_basic_creation(self):
"""Test basic SubdomainResult creation"""
result = SubdomainResult(subdomain="test.example.com")
assert result.subdomain == "test.example.com"
assert result.ip_addresses == []
assert result.status_code is None
assert result.server_header is None
assert result.technologies == []
assert result.is_alive is False
assert result.screenshot_path is None
assert isinstance(result.discovered_at, datetime)
def test_full_creation(self):
"""Test SubdomainResult with all fields"""
now = datetime.now()
result = SubdomainResult(
subdomain="api.example.com",
ip_addresses=["192.168.1.1", "192.168.1.2"],
status_code=200,
server_header="nginx/1.18.0",
technologies=["nginx", "PHP", "Laravel"],
is_alive=True,
screenshot_path="/path/to/screenshot.png",
discovered_at=now,
)
assert result.subdomain == "api.example.com"
assert result.ip_addresses == ["192.168.1.1", "192.168.1.2"]
assert result.status_code == 200
assert result.server_header == "nginx/1.18.0"
assert result.technologies == ["nginx", "PHP", "Laravel"]
assert result.is_alive is True
assert result.screenshot_path == "/path/to/screenshot.png"
assert result.discovered_at == now
def test_default_wordlist_exists(self):
"""Test that default wordlist is populated"""
scanner = SubdomainScanner()
assert len(scanner.wordlist) > 100
assert "www" in scanner.wordlist
assert "api" in scanner.wordlist
assert "admin" in scanner.wordlist
assert "dev" in scanner.wordlist
class TestSubdomainScannerInit:
"""Test SubdomainScanner initialization"""
def test_default_init(self):
"""Test default initialization"""
scanner = SubdomainScanner()
assert scanner.orchestrator is None
assert scanner.max_workers == 50
assert scanner.timeout == 10
assert scanner.results == {}
assert len(scanner.wordlist) > 0
def test_custom_init(self):
"""Test initialization with custom parameters"""
mock_orch = MagicMock()
scanner = SubdomainScanner(
orchestrator=mock_orch,
max_workers=100,
timeout=30,
)
assert scanner.orchestrator == mock_orch
assert scanner.max_workers == 100
assert scanner.timeout == 30
def test_custom_wordlist(self):
"""Test with custom wordlist"""
custom_list = ["custom1", "custom2", "custom3"]
scanner = SubdomainScanner()
scanner.wordlist = custom_list
assert scanner.wordlist == custom_list
class TestSubdomainScannerDNS:
"""Test DNS enumeration methods"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=10, timeout=5)
@pytest.mark.asyncio
async def test_dns_query_success(self, scanner):
"""Test successful DNS query"""
with patch("dns.resolver.Resolver") as mock_resolver_class:
mock_resolver = MagicMock()
mock_resolver_class.return_value = mock_resolver
mock_answers = MagicMock()
mock_resolver.resolve.return_value = mock_answers
result = await scanner._dns_query("www.example.com", "A")
assert result == "www.example.com"
@pytest.mark.asyncio
async def test_dns_query_nxdomain(self, scanner):
"""Test DNS query with NXDOMAIN"""
import dns.resolver
with patch("dns.resolver.Resolver") as mock_resolver_class:
mock_resolver = MagicMock()
mock_resolver_class.return_value = mock_resolver
mock_resolver.resolve.side_effect = dns.resolver.NXDOMAIN()
result = await scanner._dns_query("nonexistent.example.com", "A")
assert result is None
@pytest.mark.asyncio
async def test_dns_query_no_answer(self, scanner):
"""Test DNS query with no answer"""
import dns.resolver
with patch("dns.resolver.Resolver") as mock_resolver_class:
mock_resolver = MagicMock()
mock_resolver_class.return_value = mock_resolver
mock_resolver.resolve.side_effect = dns.resolver.NoAnswer()
result = await scanner._dns_query("example.com", "AAAA")
assert result is None
@pytest.mark.asyncio
async def test_dns_query_timeout(self, scanner):
"""Test DNS query timeout"""
import dns.resolver
with patch("dns.resolver.Resolver") as mock_resolver_class:
mock_resolver = MagicMock()
mock_resolver_class.return_value = mock_resolver
mock_resolver.resolve.side_effect = dns.resolver.Timeout()
result = await scanner._dns_query("example.com", "A")
assert result is None
@pytest.mark.asyncio
async def test_dns_enumeration(self, scanner):
"""Test DNS enumeration method"""
with patch.object(scanner, "_dns_query", new_callable=AsyncMock) as mock_query:
mock_query.side_effect = [
"www.example.com",
None,
"mail.example.com",
None,
None,
] * 10 # Multiple prefixes and record types
results = await scanner._dns_enumeration("example.com")
assert set(results).issuperset({"www.example.com", "mail.example.com"})
class TestSubdomainScannerWordlist:
"""Test wordlist brute-force methods"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=5, timeout=2)
@pytest.mark.asyncio
async def test_wordlist_bruteforce_success(self, scanner):
"""Test successful wordlist brute-force"""
scanner.wordlist = ["www", "api"]
scanner.timeout = 1
# Mock the executor-based socket resolution
async def mock_resolve(*args, **kwargs):
return "192.168.1.1"
with patch("asyncio.wait_for", side_effect=mock_resolve):
with patch("socket.gethostbyname", return_value="192.168.1.1"):
results = await scanner._wordlist_bruteforce("example.com")
# Results depend on mock behavior
assert isinstance(results, set)
@pytest.mark.asyncio
async def test_wordlist_bruteforce_socket_error(self, scanner):
"""Test wordlist brute-force handles errors gracefully"""
scanner.wordlist = ["www"]
scanner.timeout = 1
# Just verify the method runs without error
results = await scanner._wordlist_bruteforce("example.com")
assert isinstance(results, set)
@pytest.mark.asyncio
async def test_wordlist_bruteforce_timeout(self, scanner):
"""Test wordlist brute-force with timeout"""
scanner.wordlist = ["www"]
with patch("socket.gethostbyname") as mock_gethost:
mock_gethost.side_effect = asyncio.TimeoutError()
results = await scanner._wordlist_bruteforce("example.com")
assert len(results) == 0
class TestSubdomainScannerCRT:
"""Test Certificate Transparency enumeration"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=10, timeout=5)
@pytest.mark.asyncio
async def test_crt_sh_enum_success(self, scanner):
"""Test successful crt.sh enumeration"""
mock_response = MagicMock()
mock_response.status = 200
mock_response.json = AsyncMock(
return_value=[
{"name_value": "www.example.com"},
{"name_value": "api.example.com\nmail.example.com"},
{"name_value": "*.example.com"},
]
)
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session = AsyncMock()
mock_session_class.return_value.__aenter__ = AsyncMock(return_value=mock_session)
mock_session_class.return_value.__aexit__ = AsyncMock(return_value=False)
mock_session.get = MagicMock(return_value=mock_response)
mock_response.__aenter__ = AsyncMock(return_value=mock_response)
mock_response.__aexit__ = AsyncMock(return_value=False)
results = await scanner._crt_sh_enum("example.com")
assert set(results).issuperset({"www.example.com", "api.example.com", "mail.example.com"})
@pytest.mark.asyncio
async def test_crt_sh_enum_empty_response(self, scanner):
"""Test crt.sh with empty response"""
mock_response = MagicMock()
mock_response.status = 200
mock_response.json = AsyncMock(return_value=[])
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session = AsyncMock()
mock_session_class.return_value.__aenter__ = AsyncMock(return_value=mock_session)
mock_session_class.return_value.__aexit__ = AsyncMock(return_value=False)
mock_session.get = MagicMock(return_value=mock_response)
mock_response.__aenter__ = AsyncMock(return_value=mock_response)
mock_response.__aexit__ = AsyncMock(return_value=False)
results = await scanner._crt_sh_enum("example.com")
assert len(results) == 0
@pytest.mark.asyncio
async def test_crt_sh_enum_http_error(self, scanner):
"""Test crt.sh with HTTP error"""
mock_response = MagicMock()
mock_response.status = 500
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session = AsyncMock()
mock_session_class.return_value.__aenter__ = AsyncMock(return_value=mock_session)
mock_session_class.return_value.__aexit__ = AsyncMock(return_value=False)
mock_session.get = MagicMock(return_value=mock_response)
mock_response.__aenter__ = AsyncMock(return_value=mock_response)
mock_response.__aexit__ = AsyncMock(return_value=False)
results = await scanner._crt_sh_enum("example.com")
assert len(results) == 0
@pytest.mark.asyncio
async def test_crt_sh_enum_exception(self, scanner):
"""Test crt.sh with exception"""
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session_class.side_effect = Exception("Connection error")
results = await scanner._crt_sh_enum("example.com")
assert len(results) == 0
class TestSubdomainScannerLLM:
"""Test LLM-assisted enumeration"""
@pytest.fixture
def scanner(self):
mock_orch = MagicMock()
scanner = SubdomainScanner(orchestrator=mock_orch, max_workers=10, timeout=5)
return scanner
@pytest.mark.asyncio
async def test_llm_assisted_enum_success(self, scanner):
"""Test successful LLM-assisted enumeration"""
mock_response = MagicMock()
mock_response.content = "admin, api, dev, staging, cdn"
scanner.orchestrator.process = AsyncMock(return_value=mock_response)
results = await scanner._llm_assisted_enum("example.com")
expected = {
"admin.example.com",
"api.example.com",
"dev.example.com",
"staging.example.com",
"cdn.example.com",
}
assert set(results).issuperset(expected)
@pytest.mark.asyncio
async def test_llm_assisted_enum_multiline(self, scanner):
"""Test LLM-assisted enumeration with multiline response"""
mock_response = MagicMock()
mock_response.content = "admin\napi\ndev"
scanner.orchestrator.process = AsyncMock(return_value=mock_response)
results = await scanner._llm_assisted_enum("example.com")
assert set(results).issuperset({"admin.example.com", "api.example.com", "dev.example.com"})
@pytest.mark.asyncio
async def test_llm_assisted_enum_no_orchestrator(self, scanner):
"""Test LLM-assisted enumeration without orchestrator"""
scanner.orchestrator = None
results = await scanner._llm_assisted_enum("example.com")
assert len(results) == 0
@pytest.mark.asyncio
async def test_llm_assisted_enum_exception(self, scanner):
"""Test LLM-assisted enumeration with exception"""
scanner.orchestrator.process = AsyncMock(side_effect=Exception("LLM error"))
results = await scanner._llm_assisted_enum("example.com")
assert len(results) == 0
class TestSubdomainScannerWildcardFilter:
"""Test wildcard filtering"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=10, timeout=5)
def test_filter_wildcards_no_wildcard(self, scanner):
"""Test filtering when no wildcard exists - simplified"""
test_subdomains = {"www.example.com", "admin.example.com"}
# Test that the method runs without error
results = scanner._filter_wildcards(test_subdomains, "example.com")
assert isinstance(results, set)
def test_filter_wildcards_with_wildcard(self, scanner):
"""Test filtering when wildcard exists"""
test_subdomains = {"www.example.com", "test12345.example.com"}
with patch("socket.gethostbyname") as mock_gethost:
# Wildcard check returns IP, real subdomain has same IP
mock_gethost.side_effect = [
"192.168.1.100", # test12345 - wildcard
"192.168.1.100", # random98765 - wildcard
"192.168.1.100", # wildcard-check - wildcard
"192.168.1.100", # www - same IP as wildcard (filtered)
"192.168.1.100", # test12345 - same IP as wildcard (filtered)
]
results = scanner._filter_wildcards(test_subdomains, "example.com")
# All should be filtered since they match wildcard IP
assert results == set()
def test_filter_wildcards_partial_match(self, scanner):
"""Test filtering with partial wildcard match"""
test_subdomains = {"www.example.com", "admin.example.com"}
def side_effect(hostname):
if "test12345" in hostname or "random98765" in hostname or "wildcard-check" in hostname:
return "192.168.1.100" # Wildcard IP
if "www" in hostname:
return "192.168.1.100" # Same as wildcard (filtered)
if "admin" in hostname:
return "192.168.1.200" # Different IP (kept)
raise Exception("not found")
with patch("socket.gethostbyname", side_effect=side_effect):
results = scanner._filter_wildcards(test_subdomains, "example.com")
assert results.isdisjoint({"www.example.com"})
assert not results.isdisjoint({"admin.example.com"})
class TestSubdomainScannerHTTPCheck:
"""Test HTTP availability checking"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=5, timeout=2)
@pytest.mark.asyncio
async def test_check_http_availability_success(self, scanner):
"""Test HTTP availability check success"""
mock_response = MagicMock()
mock_response.status = 200
mock_response.headers = {"Server": "nginx/1.18.0"}
mock_response.text = AsyncMock(return_value="<html>WordPress</html>")
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session = AsyncMock()
mock_session_class.return_value.__aenter__ = AsyncMock(return_value=mock_session)
mock_session_class.return_value.__aexit__ = AsyncMock(return_value=False)
mock_session.get = MagicMock(return_value=mock_response)
mock_response.__aenter__ = AsyncMock(return_value=mock_response)
mock_response.__aexit__ = AsyncMock(return_value=False)
await scanner._check_http_availability({"www.example.com"})
assert scanner.results.get("www.example.com") is not None
www_result = scanner.results.get("www.example.com")
assert www_result.is_alive is True
assert www_result.status_code == 200
assert www_result.server_header == "nginx/1.18.0"
@pytest.mark.asyncio
async def test_check_http_availability_client_error(self, scanner):
"""Test HTTP availability check with client error"""
import aiohttp
with patch("aiohttp.ClientSession") as mock_session_class:
mock_session_class.side_effect = aiohttp.ClientError("Connection refused")
await scanner._check_http_availability({"www.example.com"})
# Should not crash, just skip
assert scanner.results.get("www.example.com") is None
class TestSubdomainScannerTechDetection:
"""Test technology detection"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=10, timeout=5)
def test_detect_technologies_nginx(self, scanner):
"""Test nginx detection"""
headers = {"Server": "nginx/1.18.0"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "nginx" in techs
def test_detect_technologies_apache(self, scanner):
"""Test apache detection"""
headers = {"Server": "Apache/2.4.41"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "apache" in techs
def test_detect_technologies_iis(self, scanner):
"""Test IIS detection"""
headers = {"Server": "Microsoft-IIS/10.0"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "IIS" in techs
def test_detect_technologies_cloudflare(self, scanner):
"""Test Cloudflare detection"""
headers = {"Server": "cloudflare"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "Cloudflare" in techs
def test_detect_technologies_php(self, scanner):
"""Test PHP detection"""
headers = {"X-Powered-By": "PHP/7.4.0"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "PHP" in techs
def test_detect_technologies_aspnet(self, scanner):
"""Test ASP.NET detection"""
headers = {"X-Powered-By": "ASP.NET"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "ASP.NET" in techs
def test_detect_technologies_cdn(self, scanner):
"""Test CDN detection"""
headers = {"Via": "1.1 cloudfront.net"}
body = "<html></html>"
techs = scanner._detect_technologies(headers, body)
assert "AWS CloudFront" in techs
headers = {"Via": "1.1 akamai.net"}
techs = scanner._detect_technologies(headers, body)
assert "Akamai" in techs
def test_detect_technologies_body_indicators(self, scanner):
"""Test technology detection from body"""
headers = {}
body = "<html><head></head><body>Powered by WordPress</body></html>"
techs = scanner._detect_technologies(headers, body)
assert "WordPress" in techs
def test_detect_technologies_multiple(self, scanner):
"""Test detection of multiple technologies"""
headers = {
"Server": "nginx/1.18.0",
"X-Powered-By": "PHP/7.4.0",
"Via": "1.1 cloudfront.net",
}
body = "<html><head></head><body>WordPress jQuery</body></html>"
techs = scanner._detect_technologies(headers, body)
assert "nginx" in techs
assert "PHP" in techs
assert "AWS CloudFront" in techs
assert "WordPress" in techs
assert "jQuery" in techs
class TestSubdomainScannerExport:
"""Test result export functionality"""
@pytest.fixture
def scanner(self):
s = SubdomainScanner(max_workers=10, timeout=5)
s.results = {
"www.example.com": SubdomainResult(
subdomain="www.example.com",
ip_addresses=["192.168.1.1"],
status_code=200,
server_header="nginx",
technologies=["nginx", "PHP"],
is_alive=True,
),
"api.example.com": SubdomainResult(
subdomain="api.example.com",
ip_addresses=["192.168.1.2"],
status_code=404,
is_alive=False,
),
}
return s
def test_export_results_json(self, scanner):
"""Test JSON export"""
output = scanner.export_results("json")
data = json.loads(output)
assert data.get("www.example.com") is not None
assert data.get("api.example.com") is not None
assert data["www.example.com"]["is_alive"] is True
assert data["www.example.com"]["status_code"] == 200
def test_export_results_txt(self, scanner):
"""Test TXT export"""
output = scanner.export_results("txt")
assert output.find("www.example.com") != -1
assert output.find("api.example.com") != -1
assert "IP:" in output
assert "Status:" in output
def test_export_results_csv(self, scanner):
"""Test CSV export"""
output = scanner.export_results("csv")
lines = output.split("\n")
assert lines[0] == "subdomain,ip_addresses,status_code,server,technologies,is_alive"
assert output.find("www.example.com") != -1
assert output.find("api.example.com") != -1
def test_export_results_invalid_format(self, scanner):
"""Test invalid format raises error"""
with pytest.raises(ValueError, match="Unsupported format"):
scanner.export_results("xml")
class TestSubdomainScannerScan:
"""Test main scan functionality"""
@pytest.fixture
def scanner(self):
return SubdomainScanner(max_workers=5, timeout=2)
@pytest.mark.asyncio
async def test_scan_basic(self, scanner):
"""Test basic scan functionality"""
with (
patch.object(scanner, "_dns_enumeration", new_callable=AsyncMock) as mock_dns,
patch.object(scanner, "_wordlist_bruteforce", new_callable=AsyncMock) as mock_wordlist,
patch.object(scanner, "_crt_sh_enum", new_callable=AsyncMock) as mock_crt,
patch.object(scanner, "_filter_wildcards") as mock_filter,
patch.object(scanner, "_check_http_availability", new_callable=AsyncMock),
):
mock_dns.return_value = {"www.example.com"}
mock_wordlist.return_value = {"api.example.com"}
mock_crt.return_value = {"admin.example.com"}
mock_filter.return_value = {
"www.example.com",
"api.example.com",
"admin.example.com",
}
results = await scanner.scan("example.com", check_http=False)
assert len(results) == 3
assert set(results).issuperset({"www.example.com", "api.example.com", "admin.example.com"})
@pytest.mark.asyncio
async def test_scan_with_url_input(self, scanner):
"""Test scan with URL input"""
with (
patch.object(scanner, "_dns_enumeration", new_callable=AsyncMock) as mock_dns,
patch.object(scanner, "_wordlist_bruteforce", new_callable=AsyncMock) as mock_wordlist,
patch.object(scanner, "_crt_sh_enum", new_callable=AsyncMock) as mock_crt,
patch.object(scanner, "_filter_wildcards") as mock_filter,
patch.object(scanner, "_check_http_availability", new_callable=AsyncMock),
):
mock_dns.return_value = set()
mock_wordlist.return_value = set()
mock_crt.return_value = set()
mock_filter.return_value = set()
await scanner.scan("https://example.com/path", check_http=False)
# Should strip URL to domain
@pytest.mark.asyncio
async def test_scan_with_techniques(self, scanner):
"""Test scan with specific techniques"""
with (
patch.object(scanner, "_dns_enumeration", new_callable=AsyncMock) as mock_dns,
patch.object(scanner, "_wordlist_bruteforce", new_callable=AsyncMock) as mock_wordlist,
patch.object(scanner, "_crt_sh_enum", new_callable=AsyncMock) as mock_crt,
patch.object(scanner, "_filter_wildcards") as mock_filter,
patch.object(scanner, "_check_http_availability", new_callable=AsyncMock),
patch.object(scanner, "_llm_assisted_enum", new_callable=AsyncMock) as mock_llm,
):
mock_dns.return_value = {"dns.example.com"}
mock_wordlist.return_value = {"wordlist.example.com"}
mock_crt.return_value = {"crt.example.com"}
mock_llm.return_value = {"llm.example.com"}
mock_filter.return_value = {
"dns.example.com",
"wordlist.example.com",
"crt.example.com",
"llm.example.com",
}
mock_orch = MagicMock()
scanner.orchestrator = mock_orch
await scanner.scan(
"example.com",
techniques=["dns", "wordlist", "crt", "osint"],
check_http=False,
)
mock_dns.assert_called_once()
mock_wordlist.assert_called_once()
mock_crt.assert_called_once()
mock_llm.assert_called_once()
@pytest.mark.asyncio
async def test_scan_with_custom_wordlist(self, scanner):
"""Test scan with custom wordlist"""
custom_wordlist = ["custom1", "custom2"]
with (
patch.object(scanner, "_dns_enumeration", new_callable=AsyncMock) as mock_dns,
patch.object(scanner, "_wordlist_bruteforce", new_callable=AsyncMock) as mock_wordlist,
patch.object(scanner, "_crt_sh_enum", new_callable=AsyncMock) as mock_crt,
patch.object(scanner, "_filter_wildcards") as mock_filter,
patch.object(scanner, "_check_http_availability", new_callable=AsyncMock),
):
mock_dns.return_value = set()
mock_wordlist.return_value = set()
mock_crt.return_value = set()
mock_filter.return_value = set()
await scanner.scan("example.com", wordlist=custom_wordlist, check_http=False)
assert scanner.wordlist == custom_wordlist
class TestScanSubdomains:
"""Test scan_subdomains convenience function"""
@pytest.mark.asyncio
async def test_scan_subdomains(self):
"""Test scan_subdomains convenience function"""
with patch.object(SubdomainScanner, "scan", new_callable=AsyncMock) as mock_scan:
mock_scan.return_value = {"www.example.com": SubdomainResult(subdomain="www.example.com")}
results = await scan_subdomains("example.com", max_workers=10)
assert results.get("www.example.com") is not None
mock_scan.assert_called_once()
def test_scan_subdomains_import(self):
"""Test that scan_subdomains can be imported"""
import inspect
sig = inspect.signature(scan_subdomains)
params = list(sig.parameters.keys())
assert "domain" in params
assert "wordlist" in params
assert "check_http" in params
assert "max_workers" in params
class TestSubdomainScannerIntegration:
"""Integration-style tests"""
@pytest.mark.asyncio
async def test_full_scan_workflow(self):
"""Test complete scan workflow"""
scanner = SubdomainScanner(max_workers=5, timeout=2)
with (
patch.object(scanner, "_dns_enumeration", new_callable=AsyncMock) as mock_dns,
patch.object(scanner, "_wordlist_bruteforce", new_callable=AsyncMock) as mock_wordlist,
patch.object(scanner, "_crt_sh_enum", new_callable=AsyncMock) as mock_crt,
patch.object(scanner, "_filter_wildcards") as mock_filter,
patch.object(scanner, "_check_http_availability", new_callable=AsyncMock) as mock_http,
):
mock_dns.return_value = {"www.example.com", "mail.example.com"}
mock_wordlist.return_value = {"api.example.com"}
mock_crt.return_value = {"admin.example.com"}
mock_filter.return_value = {
"www.example.com",
"mail.example.com",
"api.example.com",
"admin.example.com",
}
results = await scanner.scan("example.com", check_http=True)
# Verify all methods were called
mock_dns.assert_called_once()
mock_wordlist.assert_called_once()
mock_crt.assert_called_once()
mock_filter.assert_called_once()
mock_http.assert_called_once()
# Verify results
assert len(results) == 4
def test_default_wordlist_comprehensive(self):
"""Test that default wordlist is comprehensive"""
scanner = SubdomainScanner()
# Check for key categories
categories = {
"core": ["www", "mail", "ftp"],
"admin": ["admin", "portal", "panel"],
"dev": ["dev", "staging", "test"],
"api": ["api", "rest", "graphql"],
"infra": ["cdn", "static", "assets"],
"cloud": ["aws", "azure", "gcp"],
}
for category, items in categories.items():
for item in items:
assert item in scanner.wordlist, f"Missing {item} from {category}"
def test_wordlist_uniqueness(self):
"""Test that wordlist has entries (duplicates may exist in source)"""
scanner = SubdomainScanner()
# Wordlist should have many entries
assert len(scanner.wordlist) > 100
# Set should have unique entries
assert len(set(scanner.wordlist)) > 100

Xet Storage Details

Size:
30.5 kB
·
Xet hash:
fd605f072ea7b42d65b37f80d9111bf87bd4a53f1d42ab48e20ffc9a21eb6c09

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