MCPcopy Index your code
hub / github.com/zalando/postgres-operator / TestNewInfrastructureRoleFormat

Function TestNewInfrastructureRoleFormat

pkg/controller/util_test.go:158–235  ·  view source on GitHub ↗

Test functionality of getting infrastructure roles from their description in corresponding secrets. Here we test the new format.

(t *testing.T)

Source from the content-addressed store, hash-verified

156// Test functionality of getting infrastructure roles from their description in
157// corresponding secrets. Here we test the new format.
158func TestNewInfrastructureRoleFormat(t *testing.T) {
159 var testTable = []struct {
160 secrets []spec.NamespacedName
161 expectedRoles map[string]spec.PgUser
162 }{
163 // one secret with one configmap
164 {
165 []spec.NamespacedName{
166 {
167 Namespace: v1.NamespaceDefault,
168 Name: testInfrastructureRolesNewSecretName,
169 },
170 },
171 map[string]spec.PgUser{
172 "new-test-role": {
173 Name: "new-test-role",
174 Origin: spec.RoleOriginInfrastructure,
175 Password: "new-test-password",
176 MemberOf: []string{"new-test-inrole"},
177 },
178 "new-foobar": {
179 Name: "new-foobar",
180 Origin: spec.RoleOriginInfrastructure,
181 Password: b64.StdEncoding.EncodeToString([]byte("password")),
182 MemberOf: nil,
183 Flags: []string{"createdb"},
184 },
185 },
186 },
187 // multiple standalone secrets
188 {
189 []spec.NamespacedName{
190 {
191 Namespace: v1.NamespaceDefault,
192 Name: "infrastructureroles-new-test1",
193 },
194 {
195 Namespace: v1.NamespaceDefault,
196 Name: "infrastructureroles-new-test2",
197 },
198 },
199 map[string]spec.PgUser{
200 "new-test-role1": {
201 Name: "new-test-role1",
202 Origin: spec.RoleOriginInfrastructure,
203 Password: "new-test-password1",
204 MemberOf: []string{"new-test-inrole1"},
205 },
206 "new-test-role2": {
207 Name: "new-test-role2",
208 Origin: spec.RoleOriginInfrastructure,
209 Password: "new-test-password2",
210 MemberOf: []string{"new-test-inrole2"},
211 },
212 },
213 },
214 }
215 for _, test := range testTable {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected