(t *testing.T)
| 504 | } |
| 505 | |
| 506 | func TestHTTPClient_AuthenticationError(t *testing.T) { |
| 507 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 508 | w.WriteHeader(http.StatusOK) |
| 509 | _ = json.NewEncoder(w).Encode(map[string]interface{}{"success": true}) |
| 510 | })) |
| 511 | defer server.Close() |
| 512 | |
| 513 | client := NewHTTPClient(server.Client(), server.URL, testutils.NewTestLogger()) |
| 514 | |
| 515 | // Create auth manager that will fail authentication |
| 516 | authManager := NewAuthManagerWithPassword( |
| 517 | NewHTTPClient(&http.Client{}, "http://invalid-auth-server.local", testutils.NewTestLogger()), |
| 518 | "user", "pass", testutils.NewTestLogger(), |
| 519 | ) |
| 520 | client.SetAuthManager(authManager) |
| 521 | |
| 522 | var result map[string]interface{} |
| 523 | err := client.Get(context.Background(), "/test", &result) |
| 524 | |
| 525 | require.Error(t, err) |
| 526 | assert.Contains(t, err.Error(), "authentication failed") |
| 527 | } |
| 528 | |
| 529 | func TestHTTPClient_MarshalError(t *testing.T) { |
| 530 | server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected