from fastapi.testclient import TestClient from src.backend.constants import Auth0 from src.backend.main import app from src.backend.routers.auth import ROUTE ROUTE = f"/api{ROUTE}" client = TestClient(app) def test_get_auth0_config(): """This test checks if the endpoint returns the Auth0 tenant configuration. It must pass without requiring authentication for the endpoint. """ response = client.get(f"{ROUTE}/config") data = response.json()["data"] expected_keys = { Auth0.CLIENT_ID_SPA, Auth0.DOMAIN, Auth0.AUDIENCE, Auth0.SCOPE, Auth0.REDIRECT_URI, Auth0.GRANT_TYPE, Auth0.ISSUER, Auth0.ALGORITHMS, } credentials = ( Auth0.CLIENT_ID, Auth0.CLIENT_SECRET, ) assert response.status_code == 200 assert not any( k in data for k in credentials ), "The client_id and client_secret should not be leaked in the response!" assert set(data.keys()) == expected_keys