TorbatYar/backend/services/hospitality/app/tests/test_security.py
Mortezakoohjani 5c6a2e78cf feat(platform): seed service registry, deploy all modules, and fix homepage catalog.
Register all active platform services and base features in core DB so admin can manage them, add delivery/hospitality/sports-center backend phases, update apps catalog and production deploy tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 12:39:51 +03:30

26 lines
830 B
Python

"""Security validation — auth gate when AUTH_REQUIRED is true."""
from __future__ import annotations
import pytest
from httpx import ASGITransport, AsyncClient
from app.core.config import settings
from app.main import app
from app.tests.conftest import TENANT_A, tenant_headers
@pytest.mark.asyncio
async def test_auth_required_rejects_anonymous():
original = settings.auth_required
settings.auth_required = True
try:
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://testserver") as client:
resp = await client.get(
"/api/v1/venues",
headers=tenant_headers(TENANT_A),
)
assert resp.status_code == 401
finally:
settings.auth_required = original