MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestAuthManager_authenticate_NetworkError

Function TestAuthManager_authenticate_NetworkError

pkg/api/auth_test.go:356–371  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

354}
355
356func TestAuthManager_authenticate_NetworkError(t *testing.T) {
357 // Use an invalid URL to simulate network error
358 httpClient := &HTTPClient{
359 baseURL: "http://invalid-host-that-does-not-exist.local",
360 client: &http.Client{Timeout: 1 * time.Second},
361 }
362 logger := testutils.NewTestLogger()
363
364 authManager := NewAuthManagerWithPassword(httpClient, "testuser", "testpass", logger)
365
366 token, err := authManager.authenticate(context.Background())
367 assert.Error(t, err)
368 assert.Nil(t, token)
369 // Depending on network environment, the exact error may vary
370 assert.NotEmpty(t, err.Error())
371}
372
373func TestAuthManager_ClearToken(t *testing.T) {
374 httpClient := &HTTPClient{baseURL: "https://test.example.com"}

Callers

nothing calls this directly

Calls 4

NewTestLoggerFunction · 0.92
authenticateMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected