test: add AgentDetection service unit tests #44

Merged
Snider merged 1 commit from test/agent-detection-service into main 2026-02-23 06:08:40 +00:00
Member

Summary

  • Adds tests/Unit/AgentDetectionTest.php with comprehensive coverage of Services/AgentDetection.php
  • Tests User-Agent pattern matching for all five AI providers: Anthropic/Claude, OpenAI/ChatGPT, Google/Gemini, Meta/LLaMA, and Mistral
  • Tests model detection (claude-opus, claude-sonnet, gpt-4, gemini-pro, llama-3, etc.)
  • Tests browser UA detection (not_agent) and non-agent bot detection (Googlebot, curl, Slackbot, etc.)
  • Tests edge cases: null, empty, and whitespace-only User-Agent strings
  • Tests structured MCP token parsing (provider:model:secret) and header priority
  • Tests isValidProvider(), getValidProviders(), and isAgentUserAgent() helpers
  • Each test documents the regex pattern with real-world UA examples

Closes #13

## Summary - Adds `tests/Unit/AgentDetectionTest.php` with comprehensive coverage of `Services/AgentDetection.php` - Tests User-Agent pattern matching for all five AI providers: Anthropic/Claude, OpenAI/ChatGPT, Google/Gemini, Meta/LLaMA, and Mistral - Tests model detection (claude-opus, claude-sonnet, gpt-4, gemini-pro, llama-3, etc.) - Tests browser UA detection (`not_agent`) and non-agent bot detection (Googlebot, curl, Slackbot, etc.) - Tests edge cases: null, empty, and whitespace-only User-Agent strings - Tests structured MCP token parsing (`provider:model:secret`) and header priority - Tests `isValidProvider()`, `getValidProviders()`, and `isAgentUserAgent()` helpers - Each test documents the regex pattern with real-world UA examples Closes #13
Clotho added 1 commit 2026-02-23 01:42:04 +00:00
test: add AgentDetection service unit tests
Some checks failed
CI / tests (pull_request) Failing after 1m1s
964d6cdeb3
Adds tests/Unit/AgentDetectionTest.php covering:
- User-Agent pattern matching for all AI providers (Anthropic, OpenAI,
  Google, Meta, Mistral) with model detection
- Browser UA detection returning notAnAgent (Chrome, Firefox, Safari, Edge)
- Non-agent bot detection (Googlebot, Bingbot, curl, python-requests, etc.)
- Edge cases: null, empty, whitespace-only, and generic programmatic UAs
- Structured MCP token parsing (provider:model:secret format)
- MCP header priority over User-Agent in HTTP requests
- Provider validation via isValidProvider() and getValidProviders()
- isAgentUserAgent() shorthand behaviour
- Each pattern documented with real-world UA examples

Closes #13

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snider merged commit 075aa05ee4 into main 2026-02-23 06:08:40 +00:00
Snider deleted branch test/agent-detection-service 2026-02-23 06:08:40 +00:00
Sign in to join this conversation.
No description provided.