Skip to content
MCP

Chapter 11 Β· Operate

Testing Strategy

Test the failure paths as carefully as the success paths. The reference build ships solid unit tests; here's what exists, what to add before production, and the smoke sequence to run after every deploy.

🎯 What you'll be able to do

  • Know which unit tests already exist and what they cover
  • Plan the integration tests to add before production
  • Run the deploy-time smoke sequence and read its decision points
  • Run the full local and remote validation commands safely

Existing tests in the reference build

FileCoverage
tests/test_auth.pyToken hashing, cache expiry, Jira resource selection.
tests/test_middleware.pyBearer extraction, origin checks, missing-token behavior.
tests/test_trim.pyIssue trimming, clipping, max-result clamp, byte-budget overflow, ADF shape.
tests/conftest.pyDeterministic test environment and token-context reset.

Tests to add before production

CategoryTests
MCP protocolinitialize, tools/list, tools/call.
Gateway integritymissing, wrong, and correct X-Gateway-Token.
OAuth behaviormissing, malformed, expired token; insufficient scopes.
Jira errors401, 403, 404, 429, 5xx.
Multi-site userspinned cloud id, pinned site URL, no matching site.
Connector schemavalidates the MCP extension and OAuth scopes.
Payload stresshuge custom fields, long summaries, many issues.
Deployment smokeAPIM endpoint responds and rejects direct app bypass.
Why this matters
Auth failures are where security bugs hide. A test that asserts a wrong gateway token is rejected is just as important as one that asserts the right one is accepted.

Suggested smoke sequence

Run this after every deploy. Each diamond is a go/no-go gate.

Commands

Local validation:

PowerShell
ruff check .
python -m compileall app
pytest -q
python scripts\smoke.py

Remote smoke against a deployed APIM endpoint:

PowerShell
$env:BASE = "https://<apim-host>/jira-mcp"
$env:TOKEN = "<short-lived-atlassian-access-token>"
python scripts\smoke.py

❓ Concept check

Your remote smoke run reaches tools/list but no Jira tools appear, even though the server is healthy. Where do you look first?

πŸ“Œ Chapter summary

  • Existing unit tests cover auth, middleware, and trimming with a deterministic environment.
  • Add MCP protocol, gateway integrity, OAuth, Jira error, multi-site, connector schema, and payload-stress tests.
  • The smoke sequence verifies the deployed path end-to-end, including the deliberate 401.

βœ… End-of-chapter review

0/4 done