package api_test import ( "github.com/tradarr/backend/internal/api" "github.com/tradarr/backend/internal/api/handlers" "github.com/tradarr/backend/internal/config" "net/http/httptest" "testing" ) func TestAIProviderConnectionRequiresAuthentication(t *testing.T) { h := handlers.New(nil, &config.Config{}, nil, nil, nil, nil) r := api.SetupRouter(h, "test-secret") found := false for _, route := range r.Routes() { if route.Method == "POST" && route.Path == "/api/admin/ai-providers/:id/test" { found = true } } if !found { t.Fatal("test route missing") } w := httptest.NewRecorder() r.ServeHTTP(w, httptest.NewRequest("POST", "/api/admin/ai-providers/saved/test", nil)) if w.Code != 401 { t.Fatalf("unauthenticated status=%d", w.Code) } }