@@ -57,7 +57,6 @@ var _ = Describe("DefaultUserSecret", func() {
57
57
var password []byte
58
58
var host []byte
59
59
var port []byte
60
- var connection_string []byte
61
60
var ok bool
62
61
63
62
obj , err := defaultUserSecretBuilder .Build ()
@@ -104,22 +103,12 @@ var _ = Describe("DefaultUserSecret", func() {
104
103
})
105
104
106
105
By ("Setting a connection string" , func () {
107
- connection_string , ok = secret .Data ["connection_string" ]
108
- Expect (ok ).To (BeTrue (), "Failed to find a key \" connection_string\" in the generated Secret" )
106
+ Expect (secret .Data ).To (HaveKey ("username" ), "Failed to find a key \" username\" in the generated Secret" )
107
+ Expect (secret .Data ).To (HaveKey ("password" ), "Failed to find a key \" password\" in the generated Secret" )
108
+ Expect (secret .Data ).To (HaveKey ("host" ), "Failed to find a key \" host\" in the generated Secret" )
109
+ Expect (secret .Data ).To (HaveKey ("port" ), "Failed to find a key \" port\" in the generated Secret" )
109
110
110
- username , ok = secret .Data ["username" ]
111
- Expect (ok ).To (BeTrue (), "Failed to find a key \" username\" in the generated Secret" )
112
-
113
- password , ok = secret .Data ["password" ]
114
- Expect (ok ).To (BeTrue (), "Failed to find a key \" password\" in the generated Secret" )
115
-
116
- host , ok = secret .Data ["host" ]
117
- Expect (ok ).To (BeTrue (), "Failed to find a key \" host\" in the generated Secret" )
118
-
119
- port , ok = secret .Data ["port" ]
120
- Expect (ok ).To (BeTrue (), "Failed to find a key \" port\" in the generated Secret" )
121
-
122
- Expect (connection_string ).To (BeEquivalentTo (fmt .Sprintf ("amqp://%s:%s@%s:%s/" , username , password , host , port )))
111
+ Expect (secret .Data ).To (HaveKeyWithValue ("connection_string" , []byte (fmt .Sprintf ("amqp://%s:%s@%s:%s/" , secret .Data ["username" ], secret .Data ["password" ], secret .Data ["host" ], secret .Data ["port" ]))))
123
112
})
124
113
125
114
By ("creating a default_user.conf file that contains the correct sysctl config format to be parsed by RabbitMQ" , func () {
@@ -197,18 +186,11 @@ var _ = Describe("DefaultUserSecret", func() {
197
186
secret = obj .(* corev1.Secret )
198
187
199
188
By ("Setting the AMQPS port in the user secret" , func () {
200
- var port []byte
201
- port , ok := secret .Data ["port" ]
202
- Expect (ok ).To (BeTrue (), "Failed to find key \" port\" in the generated Secret" )
203
- Expect (port ).To (BeEquivalentTo ("5671" ))
189
+ Expect (secret .Data ).To (HaveKeyWithValue ("port" , []byte ("5671" )))
204
190
})
205
191
206
192
By ("setting the connection string to use the AMQPS protocol" , func () {
207
- var connection_string []byte
208
- connection_string , ok := secret .Data ["connection_string" ]
209
- Expect (ok ).To (BeTrue (), "Failed to find key \" connection_string\" in the generated Secret" )
210
- Expect (connection_string ).To (HavePrefix ("amqps:" ))
211
- Expect (connection_string ).To (HaveSuffix (":5671/" ))
193
+ Expect (secret .Data ).To (HaveKeyWithValue ("connection_string" , MatchRegexp ("amqps:.*:5671/" )))
212
194
})
213
195
})
214
196
@@ -369,10 +351,7 @@ var _ = Describe("DefaultUserSecret", func() {
369
351
Expect (ok ).To (BeTrue ())
370
352
Expect (port ).To (BeEquivalentTo ("5671" ))
371
353
372
- connection_string , ok := secret .Data ["connection_string" ]
373
- Expect (ok ).To (BeTrue (), "Failed to find key \" connection_string\" in the generated Secret" )
374
- Expect (connection_string ).To (HavePrefix ("amqps:" ))
375
- Expect (connection_string ).To (HaveSuffix (":5671/" ))
354
+ Expect (secret .Data ).To (HaveKeyWithValue ("connection_string" , MatchRegexp ("amqps:.*:5671/" )))
376
355
377
356
port , ok = secret .Data ["mqtt-port" ]
378
357
Expect (ok ).To (BeTrue ())
0 commit comments