feat(ai): add provider connection test (#38)
This commit is contained in:
28
backend/internal/api/ai_connection_ticket38_test.go
Normal file
28
backend/internal/api/ai_connection_ticket38_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user