Use authenticated Gitea integration health check
All checks were successful
Container Image / build-and-push (push) Successful in 19s

This commit is contained in:
2026-07-08 11:56:56 +02:00
parent 2e0e1804de
commit 1bacc889ad
2 changed files with 32 additions and 2 deletions

View File

@@ -818,11 +818,13 @@ def setup_auth_routes(auth_manager: AuthManager) -> APIRouter:
except Exception as e:
return {"ok": False, "message": f"Request failed: {e}"[:400]}
# All other presets: GET against a known health endpoint.
# All other presets: GET against a known health endpoint. Prefer
# authenticated endpoints where available; public version endpoints
# can make a broken token look healthy.
# Fall back to detecting from name if preset is missing.
health_paths = {
"miniflux": "/v1/me",
"gitea": "/api/v1/version",
"gitea": "/api/v1/user",
"linkding": "/api/tags/",
"homeassistant": "/api/",
"home assistant": "/api/",

View File

@@ -1,6 +1,7 @@
import json
import asyncio
from types import SimpleNamespace
from unittest.mock import AsyncMock
import pytest
@@ -177,3 +178,30 @@ def test_update_integration_rejects_invalid_base_url_without_changing_existing(
assert exc.value.status_code == 400
assert exc.value.detail == message
assert integrations.load_integrations()[0]["base_url"] == "https://example.test"
def test_gitea_integration_test_uses_authenticated_endpoint(integrations_routes, monkeypatch):
endpoint, session_cookie, _http_exception = integrations_routes
test_integration = endpoint("/api/auth/integrations/{integration_id}/test", "POST")
integrations.save_integrations([
{
"id": "gitea-id",
"name": "Gitea",
"preset": "gitea",
"base_url": "https://git.example.test",
"auth_type": "header",
"auth_header": "Authorization",
"api_key": "token test",
}
])
execute = AsyncMock(return_value={"output": "HTTP 200\n{}", "exit_code": 0})
monkeypatch.setattr("routes.auth_routes.execute_api_call", execute)
result = asyncio.run(test_integration(
integration_id="gitea-id",
request=_JsonRequest({}, session_cookie),
))
assert result == {"ok": True, "message": "Connection successful"}
execute.assert_awaited_once_with("gitea-id", "GET", "/api/v1/user")