(t *testing.T)
| 291 | } |
| 292 | |
| 293 | func TestAuthManager_authenticate_InvalidJSON(t *testing.T) { |
| 294 | // Create a test server that returns invalid JSON |
| 295 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 296 | if r.URL.Path == testEndpoint { |
| 297 | w.Header().Set("Content-Type", "application/json") |
| 298 | _, _ = w.Write([]byte("invalid json")) |
| 299 | |
| 300 | return |
| 301 | } |
| 302 | |
| 303 | http.NotFound(w, r) |
| 304 | })) |
| 305 | defer server.Close() |
| 306 | |
| 307 | httpClient := &HTTPClient{ |
| 308 | baseURL: server.URL, |
| 309 | client: server.Client(), |
| 310 | } |
| 311 | logger := testutils.NewTestLogger() |
| 312 | |
| 313 | authManager := NewAuthManagerWithPassword(httpClient, "testuser", "testpass", logger) |
| 314 | |
| 315 | token, err := authManager.authenticate(context.Background()) |
| 316 | assert.Error(t, err) |
| 317 | assert.Nil(t, token) |
| 318 | assert.Contains(t, err.Error(), "failed to parse authentication response") |
| 319 | } |
| 320 | |
| 321 | func TestAuthManager_authenticate_NoTicket(t *testing.T) { |
| 322 | // Create a test server that returns response without ticket |
nothing calls this directly
no test coverage detected