"""Smoke-тесты M0: health, защита API, redirect OAuth-флоу."""
from fastapi.testclient import TestClient
from app.main import app
client = TestClient(app)
def test_health() -> None:
assert client.get("/api/health").json() == {"status": "ok"}
def test_api_me_requires_auth() -> None:
assert client.get("/api/me").status_code == 401
def test_auth_me_requires_auth() -> None:
assert client.get("/auth/me").status_code == 401
def test_login_redirects_to_sso() -> None:
resp = client.get("/auth/login", follow_redirects=False)
assert resp.status_code in (302, 307)
location = resp.headers["location"]
assert "auth.gnexus.space" in location
assert "state=" in location and "code_challenge=" in location