26 lines
645 B
Python
26 lines
645 B
Python
# co-gahusb/tests/test_server.py
|
|
import os
|
|
os.environ["CO_BUS_KEY"] = "test-key"
|
|
|
|
from starlette.testclient import TestClient
|
|
from app.server import app
|
|
|
|
|
|
def test_health_open_without_auth():
|
|
client = TestClient(app)
|
|
res = client.get("/health")
|
|
assert res.status_code == 200
|
|
assert res.json()["status"] == "ok"
|
|
|
|
|
|
def test_mcp_requires_bearer():
|
|
client = TestClient(app)
|
|
res = client.post("/mcp", json={})
|
|
assert res.status_code == 401
|
|
|
|
|
|
def test_mcp_wrong_key_rejected():
|
|
client = TestClient(app)
|
|
res = client.post("/mcp", json={}, headers={"Authorization": "Bearer wrong"})
|
|
assert res.status_code == 401
|