[Sprint 02] test: Create test suite for wrapper functionality #17

Closed
opened 2026-02-03 21:02:45 +00:00 by lmiranda · 1 comment
Owner

Summary

Create a new test suite for the wrapper components (tool_filter, auth, server_http). Do NOT test marketplace tools (already tested upstream).

Tasks

Test Structure

  • Create tests/ directory
  • Create tests/__init__.py
  • Create tests/conftest.py with shared fixtures
  • Add pytest and pytest-asyncio to dev dependencies

test_tool_filter.py

  • Test allowlist filtering (only allowed tools returned)
  • Test denylist filtering (denied tools excluded)
  • Test precedence (allowlist beats denylist)
  • Test no filtering (all tools returned)
  • Test edge cases (empty lists, invalid tool names)
  • Mock tools with Tool objects from MCP

test_auth.py

  • Test Bearer token validation (valid token passes)
  • Test invalid token returns 401
  • Test missing Authorization header returns 401
  • Test no-auth mode (AUTH_TOKEN unset)
  • Test malformed Authorization header
  • Mock HTTP requests with proper headers

test_server_http.py

  • Test server initialization
  • Test config loading
  • Test marketplace tool import (mock the import)
  • Test tool filtering integration
  • Test auth middleware integration
  • Test HTTP endpoint responses
  • Mock GiteaClient from marketplace

Test Configuration

  • Create pytest.ini or pyproject.toml test config
  • Set up coverage reporting (pytest-cov)
  • Target >80% coverage for wrapper code
  • Add test running instructions to README

Acceptance Criteria

  • All three test files exist and pass
  • pytest runs without errors
  • Coverage report shows >80% for wrapper modules
  • Tests use proper mocking (no real API calls)
  • Tests are fast (no network I/O)
  • Tests are isolated (no shared state)
  • CI-ready (can run in Docker or GitHub Actions)

Dependencies

Blocked by: #14 (server must exist to test)

Context

These tests validate the wrapper logic only. The marketplace tools have their own tests upstream. Focus on: config, filtering, auth, and HTTP transport.

References:

  • Corrective Rebuild specification
  • Step 14 of 14-step rebuild plan

Size: M (4-5 hours)

## Summary Create a new test suite for the wrapper components (tool_filter, auth, server_http). Do NOT test marketplace tools (already tested upstream). ## Tasks ### Test Structure - [ ] Create `tests/` directory - [ ] Create `tests/__init__.py` - [ ] Create `tests/conftest.py` with shared fixtures - [ ] Add pytest and pytest-asyncio to dev dependencies ### test_tool_filter.py - [ ] Test allowlist filtering (only allowed tools returned) - [ ] Test denylist filtering (denied tools excluded) - [ ] Test precedence (allowlist beats denylist) - [ ] Test no filtering (all tools returned) - [ ] Test edge cases (empty lists, invalid tool names) - [ ] Mock tools with `Tool` objects from MCP ### test_auth.py - [ ] Test Bearer token validation (valid token passes) - [ ] Test invalid token returns 401 - [ ] Test missing Authorization header returns 401 - [ ] Test no-auth mode (AUTH_TOKEN unset) - [ ] Test malformed Authorization header - [ ] Mock HTTP requests with proper headers ### test_server_http.py - [ ] Test server initialization - [ ] Test config loading - [ ] Test marketplace tool import (mock the import) - [ ] Test tool filtering integration - [ ] Test auth middleware integration - [ ] Test HTTP endpoint responses - [ ] Mock GiteaClient from marketplace ### Test Configuration - [ ] Create `pytest.ini` or `pyproject.toml` test config - [ ] Set up coverage reporting (pytest-cov) - [ ] Target >80% coverage for wrapper code - [ ] Add test running instructions to README ## Acceptance Criteria - All three test files exist and pass - `pytest` runs without errors - Coverage report shows >80% for wrapper modules - Tests use proper mocking (no real API calls) - Tests are fast (no network I/O) - Tests are isolated (no shared state) - CI-ready (can run in Docker or GitHub Actions) ## Dependencies **Blocked by:** #14 (server must exist to test) ## Context These tests validate the wrapper logic only. The marketplace tools have their own tests upstream. Focus on: config, filtering, auth, and HTTP transport. **References:** - Corrective Rebuild specification - Step 14 of 14-step rebuild plan **Size:** M (4-5 hours)
lmiranda added this to the Sprint 02: Corrective Rebuild milestone 2026-02-03 21:02:45 +00:00
lmiranda added the Component/TestingType/TestTech/PythonSize/MPriority/High labels 2026-02-03 21:02:45 +00:00
Author
Owner

⚠️ Blocked By: #14

⚠️ **Blocked By:** #14
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: personal-projects/gitea-mcp-remote#17