free-claude-code/smoke/test_auth_live.py
Ali Khokhar 462a9430bb
Add local live smoke test suite (#148)
## Summary
- add an opt-in local `smoke/` pytest suite for API, auth, providers,
CLI, IDE-shaped requests, messaging, voice, tools, and thinking stream
contracts
- keep smoke tests out of normal CI collection with `testpaths =
["tests"]`
- write sanitized smoke artifacts under `.smoke-results/`

## Verification
- `uv run ruff format`
- `uv run ruff check`
- `uv run ty check`
- `uv run ty check smoke`
- `FCC_LIVE_SMOKE=1 FCC_SMOKE_TARGETS=all FCC_SMOKE_RUN_VOICE=1 uv run
pytest smoke -n 0 -m live -s --tb=short` -> 17 passed, 9 skipped
- `uv run pytest` -> 904 passed

## Notes
- Skipped live checks require local credentials/tools/services, such as
provider models, Telegram/Discord targets, voice backend, or Claude CLI.
- `claude-pick` smoke was intentionally removed.
2026-04-23 19:06:09 -07:00

43 lines
1.2 KiB
Python

from __future__ import annotations
import httpx
import pytest
from smoke.lib.config import SmokeConfig
from smoke.lib.server import start_server
pytestmark = [pytest.mark.live, pytest.mark.smoke_target("auth")]
def test_auth_token_is_enforced_for_all_supported_header_shapes(
smoke_config: SmokeConfig,
) -> None:
token = "fcc-smoke-token"
with start_server(
smoke_config,
env_overrides={"ANTHROPIC_AUTH_TOKEN": token, "MESSAGING_PLATFORM": "none"},
name="auth",
) as server:
assert httpx.get(f"{server.base_url}/").status_code == 401
assert (
httpx.get(f"{server.base_url}/", headers={"x-api-key": "wrong"}).status_code
== 401
)
assert (
httpx.get(f"{server.base_url}/", headers={"x-api-key": token}).status_code
== 200
)
assert (
httpx.get(
f"{server.base_url}/",
headers={"authorization": f"Bearer {token}"},
).status_code
== 200
)
assert (
httpx.get(
f"{server.base_url}/",
headers={"anthropic-auth-token": token},
).status_code
== 200
)