Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
test: Add invalid user format tests for NewClient
rcourtman618fc084f18e
diff --git a/pkg/proxmox/client_test.go b/pkg/proxmox/client_test.goindex 130b5736de..65a2f3de43 100644--- a/pkg/proxmox/client_test.go+++ b/pkg/proxmox/client_test.go@@ -7,6 +7,7 @@ import ("math""net/http""net/http/httptest"+ "strings""testing""time")@@ -1384,3 +1385,53 @@ func TestGetNodes_InvalidJSON(t *testing.T) {t.Fatal("expected JSON decode error, got nil")}}++func TestNewClient_InvalidUserFormat(t *testing.T) {+ tests := []struct {+ name string+ user string+ wantErr bool+ errContains string+ }{+ {+ name: "missing realm separator",+ user: "userwithoutrealm",+ wantErr: true,+ errContains: "invalid user format",+ },+ {+ name: "empty user",+ user: "",+ wantErr: true,+ errContains: "invalid user format",+ },+ {+ name: "multiple @ symbols",+ user: "user@realm@extra",+ wantErr: true,+ errContains: "invalid user format",+ },+ }++ for _, tc := range tests {+ t.Run(tc.name, func(t *testing.T) {+ cfg := ClientConfig{+ Host: "https://localhost:8006",+ User: tc.user,+ Password: "testpass",+ }++ _, err := NewClient(cfg)+ if tc.wantErr {+ if err == nil {+ t.Errorf("expected error for user %q, got nil", tc.user)+ } else if !strings.Contains(err.Error(), tc.errContains) {+ t.Errorf("expected error containing %q, got: %v", tc.errContains, err)+ }+ }+ if !tc.wantErr && err != nil {+ t.Errorf("unexpected error for user %q: %v", tc.user, err)+ }+ })+ }+}