(t *testing.T)
| 92 | } |
| 93 | |
| 94 | func TestSCRAMVerifier(t *testing.T) { |
| 95 | t.Parallel() |
| 96 | |
| 97 | ctx := context.Background() |
| 98 | cluster := new(v1beta1.PostgresCluster) |
| 99 | service := new(corev1.Service) |
| 100 | existing := new(corev1.Secret) |
| 101 | intent := new(corev1.Secret) |
| 102 | |
| 103 | root, err := pki.NewRootCertificateAuthority() |
| 104 | assert.NilError(t, err) |
| 105 | |
| 106 | cluster.Spec.Proxy = new(v1beta1.PostgresProxySpec) |
| 107 | cluster.Spec.Proxy.PGBouncer = new(v1beta1.PGBouncerPodSpec) |
| 108 | cluster.Default() |
| 109 | |
| 110 | // Simulate the setting of a password only |
| 111 | existing.Data = map[string][]byte{ |
| 112 | "pgbouncer-password": []byte("password"), |
| 113 | } |
| 114 | |
| 115 | // Verify that a SCRAM verifier is set |
| 116 | assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent)) |
| 117 | assert.Assert(t, len(intent.Data["pgbouncer-verifier"]) != 0) |
| 118 | |
| 119 | // Simulate the setting of a password and a verifier |
| 120 | intent = new(corev1.Secret) |
| 121 | existing.Data = map[string][]byte{ |
| 122 | "pgbouncer-verifier": []byte("SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey"), |
| 123 | "pgbouncer-password": []byte("password"), |
| 124 | } |
| 125 | assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent)) |
| 126 | assert.Equal(t, string(intent.Data["pgbouncer-verifier"]), "SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey") |
| 127 | assert.Equal(t, string(intent.Data["pgbouncer-password"]), "password") |
| 128 | |
| 129 | // Simulate the setting of a verifier only |
| 130 | intent = new(corev1.Secret) |
| 131 | existing.Data = map[string][]byte{ |
| 132 | "pgbouncer-verifier": []byte("SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey"), |
| 133 | } |
| 134 | assert.NilError(t, Secret(ctx, cluster, root, existing, service, intent)) |
| 135 | assert.Assert(t, string(intent.Data["pgbouncer-verifier"]) != "SCRAM-SHA-256$4096:randomsalt:storedkey:serverkey") |
| 136 | assert.Assert(t, len(intent.Data["pgbouncer-password"]) != 0) |
| 137 | assert.Assert(t, len(intent.Data["pgbouncer-verifier"]) != 0) |
| 138 | |
| 139 | } |
| 140 | |
| 141 | func TestPod(t *testing.T) { |
| 142 | t.Parallel() |
nothing calls this directly
no test coverage detected