feat(11-01): create stealth fingerprint masking module

- Add StealthConfig Pydantic model with all playwright-stealth options
- Add apply_stealth_sync/apply_stealth_async functions for browser context
- Add get_default_stealth_config convenience function
- Add 9 unit tests covering config defaults, stealth application, and disabled mode
- Update conftest.py with stealth_config and mock_browser_context fixtures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-18 23:47:50 +08:00
parent d6026660a9
commit e152b8ea05
4 changed files with 336 additions and 0 deletions
+15
View File
@@ -102,3 +102,18 @@ def sample_article_url():
def sample_invalid_url():
"""Sample invalid URL for testing error handling."""
return "https://www.example.com/some-page"
@pytest.fixture
def stealth_config():
"""Default StealthConfig for testing."""
from kb_workflow.crawler.stealth import StealthConfig
return StealthConfig()
@pytest.fixture
def mock_browser_context():
"""Mock Playwright BrowserContext for stealth testing."""
context = MagicMock()
context.add_init_script = MagicMock()
return context