Skip to content

Commit d086472

Browse files
author
Philip Hurst
committed
added test for SCRAM verifier
1 parent 0d815dd commit d086472

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

internal/pgbouncer/reconcile_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ func TestSecret(t *testing.T) {
9090
assert.DeepEqual(t, before, intent)
9191
}
9292

93+
func TestSCRAMVerifier(t *testing.T) {
94+
t.Parallel()
95+
96+
ctx := context.Background()
97+
cluster := new(v1beta1.PostgresCluster)
98+
service := new(corev1.Service)
99+
existing := new(corev1.Secret)
100+
intent := new(corev1.Secret)
101+
102+
root, err := pki.NewRootCertificateAuthority()
103+
assert.NilError(t, err)
104+
105+
cluster.Spec.Proxy = new(v1beta1.PostgresProxySpec)
106+
cluster.Spec.Proxy.PGBouncer = new(v1beta1.PGBouncerPodSpec)
107+
cluster.Default()
108+
109+
// Simulate the generation of SCRAM verifier
110+
existing.Data = map[string][]byte{
111+
"pgbouncer-verifier": []byte("SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey"),
112+
}
113+
114+
assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent))
115+
116+
// Verify that the SCRAM verifier is correctly set in the intent secret
117+
assert.Assert(t, len(intent.Data["pgbouncer-verifier"]) != 0)
118+
assert.Equal(t, string(intent.Data["pgbouncer-verifier"]), "SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey")
119+
}
120+
93121
func TestPod(t *testing.T) {
94122
t.Parallel()
95123

0 commit comments

Comments
 (0)