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

Function TestAuthManager_authenticate_InvalidJSON

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

Source from the content-addressed store, hash-verified

291}
292
293func 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
321func TestAuthManager_authenticate_NoTicket(t *testing.T) {
322 // Create a test server that returns response without ticket

Callers

nothing calls this directly

Calls 8

NewTestLoggerFunction · 0.92
HeaderMethod · 0.80
ClientMethod · 0.80
authenticateMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected