Skip to content

feat: E2E testing, API key auth, and production deployment - #8

Merged
SPerekrestova merged 10 commits into
mainfrom
feature/e2e-and-deployment
Mar 7, 2026
Merged

SPerekrestova merged 10 commits into
mainfrom
feature/e2e-and-deployment

Conversation

@SPerekrestova

@SPerekrestova SPerekrestova commented Mar 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

End-to-end testing, API key authentication, and production deployment preparation.

Completed

  • E2E test script (scripts/e2e-test.sh) — validates full API contract (all DrugResult and InteractionResult fields the iOS app depends on), optional X-API-Key auth testing
  • API key middleware (app/middleware/api_key.py) — protects /analyze and /interactions with X-API-Key header; health endpoints remain public; auth disabled when API_KEY env var is unset
  • Bug fix — RxNorm fallback was returning phantom results with empty drug names for non-drug text (e.g. "hello world" matched brand "Hello Bello" at score 3.98); added score threshold ≥ 6.0 and empty-name filter

Pending (server tasks — to be done manually)

  • Task 5: DuckDNS subdomain setup
  • Task 6: Let's Encrypt SSL certificate
  • Task 7: nginx config update for SSL termination
  • Task 8: docker-compose production update
  • Task 9: Deploy + open firewall ports 80/443
  • Task 10: Run full E2E tests against live HTTPS
  • Task 11: Configure iOS app for production URL + API key
  • Task 12: Verify port 8000 is closed

Test plan

  • 65 backend unit tests passing (uv run pytest)
  • E2E script: 25/25 passing against live backend via SSH tunnel
  • E2E script with auth: run post-deploy (bash scripts/e2e-test.sh https://pillchecker.duckdns.org $API_KEY)

🤖 Generated with Claude Code

SPerekrestova and others added 4 commits March 7, 2026 14:18
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Validates every field the iOS app depends on across /health,
/analyze, and /interactions. Supports optional X-API-Key header
for auth testing post-middleware deployment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Protects /analyze and /interactions with X-API-Key header.
Health endpoints remain public. Auth disabled when API_KEY env
var is not set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
RxNorm's /approximateTerm always returns candidates for any input,
including common English words that fuzzy-match brand names
(e.g. "hello" → "Hello Bello" at score 3.98). This caused the
/analyze endpoint to return phantom results with empty drug names
for non-drug text.

Two fixes:
1. Add score field to DrugInfo (parsed from approximateTerm response)
2. Reject fallback candidates with score < 6.0 (real drug names score 10+)
3. Skip results where the resolved drug name is empty

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SPerekrestova SPerekrestova self-assigned this Mar 7, 2026
SPerekrestova and others added 6 commits March 7, 2026 19:40
nginx: HTTP→HTTPS redirect, SSL termination with Let's Encrypt,
API-only reverse proxy (no frontend). docker-compose: expose port
8000 internally only, mount Let's Encrypt certs into nginx,
pass API_KEY env var to API container.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Runs pytest on push/PR to main and feature branches.
Deploys to production server via SSH on push to main only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Base docker-compose.yml now uses expose instead of ports (production
security). CI override must explicitly publish 8000 so smoke tests
can reach the API from localhost.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove feature branch triggers — CI runs when a PR targets main
and on push to main (post-merge deploy).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove redundant ci-cd.yml. Add deploy job to existing ci-tests.yml,
running after integration tests pass, on push to main only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use event_name == 'push' instead of just checking ref, so the
intent is clear: deploy only fires on merge to main, never on PRs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SPerekrestova
SPerekrestova merged commit 78a9abe into main Mar 7, 2026
3 checks passed
@SPerekrestova
SPerekrestova deleted the feature/e2e-and-deployment branch March 7, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant