Skip to content

fix(tests): add X-Internal-Secret header to internal API test fixtures #754

Closed

Description

@vybe

Summary

5 tests in `tests/test_internal.py` fail with HTTP 403:
```json
{"detail": "Invalid or missing internal API secret"}
```

The tests call `POST /api/internal/...` endpoints without providing the `X-Internal-Secret` header required by architectural invariant C-003. The backend now enforces this header on all `/api/internal/` routes.

Context

Discovered via full test suite run on 2026-05-10. The internal secret enforcement (C-003) was added to `routers/internal.py` but the corresponding test fixtures were not updated to supply the header.

Acceptance Criteria

  • Add a fixture (or helper) in `tests/test_internal.py` that reads `INTERNAL_API_SECRET` (falling back to `SECRET_KEY`) from the environment and passes it as `X-Internal-Secret` on all internal API requests
  • `python -m pytest tests/test_internal.py -v` reports 5 passed, 0 failed
  • Fixture is reusable if other test files call internal endpoints

Technical Notes

```python
import os

INTERNAL_SECRET = os.environ.get("INTERNAL_API_SECRET", os.environ.get("SECRET_KEY", "test-secret"))
internal_headers = {"X-Internal-Secret": INTERNAL_SECRET}

Usage

response = client.post("/api/internal/...", headers=internal_headers, json={...})
```

Activity

  1. added
    priority-p1
    type-bug
    on May 10, 2026
  2. vybe commented on May 10, 2026

    @vybe
    ContributorAuthor

    /claim

  3. added
    status-in-progress
    on May 10, 2026
  4. github-actions commented on May 10, 2026

    @github-actions

    Claimed by @vybe. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/754-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #754
  5. vybe commented on May 10, 2026

    @vybe
    ContributorAuthor

    Fixed by #757 — merged to dev.

  6. added
    status-in-dev
    and removed
    status-in-progress
    on May 10, 2026
  7. added
    complexity-low
    theme-devex
    on Jun 3, 2026
  8. removed
    status-in-dev
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-lowpriority-p1theme-devextype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions