MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestValidateUsers

Function TestValidateUsers

controlplane/validation_test.go:25–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23}
24
25func TestValidateUsers(t *testing.T) {
26 tests := []struct {
27 name string
28 users map[string]string
29 wantErr bool
30 }{
31 {
32 name: "valid single user",
33 users: map[string]string{
34 "postgres": "postgres",
35 },
36 wantErr: false,
37 },
38 {
39 name: "empty users",
40 users: map[string]string{},
41 wantErr: true,
42 },
43 {
44 name: "empty username",
45 users: map[string]string{
46 "": "secret",
47 },
48 wantErr: true,
49 },
50 {
51 name: "whitespace username",
52 users: map[string]string{
53 " ": "secret",
54 },
55 wantErr: true,
56 },
57 {
58 name: "empty password",
59 users: map[string]string{
60 "postgres": "",
61 },
62 wantErr: true,
63 },
64 }
65
66 for _, tt := range tests {
67 t.Run(tt.name, func(t *testing.T) {
68 err := validateUsers(tt.users)
69 if tt.wantErr && err == nil {
70 t.Fatalf("expected error, got nil")
71 }
72 if !tt.wantErr && err != nil {
73 t.Fatalf("expected no error, got: %v", err)
74 }
75 })
76 }
77}
78
79func TestValidateControlPlaneSecurity(t *testing.T) {
80 baseCfg := ControlPlaneConfig{}

Callers

nothing calls this directly

Calls 2

validateUsersFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected