Sync shared snapshot from 78067cc
Docker / Docker Build & Push (push) Successful in 2m5s

This commit is contained in:
Gabriel20xx committed 2026-09-17 00:00:32 +02:00
1 parent 08a6d7bd1d
commit b3d27ff37e
5 files changed
+165 -114

No files matched your search

@@ -33,7 +33,12 @@ class _FakeStore(ap.ProxyStore):
self.claimed = False
def _build_app(store: ap.ProxyStore, client: AuthClient | None = None) -> FastAPI:
def _build_app(
store: ap.ProxyStore,
client: AuthClient | None = None,
*,
internal_secret: str | None = None,
) -> FastAPI:
def get_client(request: Request) -> AuthClient | None:
return client
@@ -41,7 +46,10 @@ def _build_app(store: ap.ProxyStore, client: AuthClient | None = None) -> FastAP
return store
app = FastAPI()
app.include_router(ap.build_auth_router(get_client, get_store), prefix="/api/auth")
app.include_router(
ap.build_auth_router(get_client, get_store, internal_secret=internal_secret),
prefix="/api/auth",
)
return app
@@ -68,7 +76,7 @@ class AuthDisabledModeTests(unittest.TestCase):
def test_me_reports_local_superadmin(self) -> None:
body = self.client.get("/api/auth/me").json()
self.assertEqual(body["user"]["username"], "local")
self.assertEqual(body["user"]["username"], "Admin")
def test_setup_succeeds_as_a_no_op(self) -> None:
response = self.client.post(
@@ -113,6 +121,22 @@ class AccessSettingsTests(unittest.TestCase):
self.assertEqual(response.json(), {"loginRequired": False})
self.assertEqual(client.get("/api/auth/access").json(), {"loginRequired": False})
def test_internal_update_disables_login_and_uses_admin_identity(self) -> None:
store = _FakeStore(login_required=True)
client = TestClient(_build_app(store, _FakeClient(setup_required=False), internal_secret="secret"))
response = client.put(
"/api/auth/access/internal",
headers={"X-Internal-Auth": "secret"},
json={"loginRequired": False},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {"loginRequired": False})
body = client.get("/api/auth/me").json()
self.assertFalse(body["authRequired"])
self.assertEqual(body["user"]["username"], "Admin")
class _FakeClient(AuthClient):
"""Overrides just the methods build_auth_router calls, bypassing real