@@ -48,6 +48,8 @@ groups() ->
48
48
test_update_secret ,
49
49
cannot_update_username_after_authenticated ,
50
50
cannot_use_another_authmechanism_when_updating_secret ,
51
+ update_secret_should_close_connection_if_wrong_secret ,
52
+ update_secret_should_close_connection_if_unauthorized_vhost ,
51
53
unauthenticated_client_rejected_tcp_connected ,
52
54
timeout_tcp_connected ,
53
55
unauthenticated_client_rejected_peer_properties_exchanged ,
@@ -165,6 +167,12 @@ init_per_testcase(cannot_update_username_after_authenticated = TestCase, Config)
165
167
ok = rabbit_ct_broker_helpers :add_user (Config , <<" other" >>),
166
168
rabbit_ct_helpers :testcase_started (Config , TestCase );
167
169
170
+ init_per_testcase (update_secret_should_close_connection_if_unauthorized_vhost = TestCase ,
171
+ Config ) ->
172
+ ok = rabbit_ct_broker_helpers :add_user (Config , <<" other" >>),
173
+ ok = rabbit_ct_broker_helpers :set_full_permissions (Config , <<" other" >>, <<" /" >>),
174
+ rabbit_ct_helpers :testcase_started (Config , TestCase );
175
+
168
176
init_per_testcase (close_connection_on_consumer_update_timeout = TestCase , Config ) ->
169
177
ok = rabbit_ct_broker_helpers :rpc (Config ,
170
178
0 ,
@@ -200,6 +208,11 @@ end_per_testcase(cannot_update_username_after_authenticated = TestCase, Config)
200
208
ok = rabbit_ct_broker_helpers :delete_user (Config , <<" other" >>),
201
209
rabbit_ct_helpers :testcase_finished (Config , TestCase );
202
210
211
+ end_per_testcase (update_secret_should_close_connection_if_unauthorized_vhost = TestCase ,
212
+ Config ) ->
213
+ ok = rabbit_ct_broker_helpers :delete_user (Config , <<" other" >>),
214
+ rabbit_ct_helpers :testcase_finished (Config , TestCase );
215
+
203
216
end_per_testcase (close_connection_on_consumer_update_timeout = TestCase , Config ) ->
204
217
ok = rabbit_ct_broker_helpers :rpc (Config ,
205
218
0 ,
@@ -285,29 +298,53 @@ test_update_secret(Config) ->
285
298
{S , C0 } = connect_and_authenticate (Transport , Config ),
286
299
rabbit_ct_broker_helpers :change_password (Config , <<" guest" >>, <<" password" >>),
287
300
C1 = expect_successful_authentication (
288
- try_authenticate (Transport , S , C0 , <<" PLAIN" >>, <<" guest" >>, <<" password" >>)),
301
+ try_authenticate (Transport , S , C0 , <<" PLAIN" >>, <<" guest" >>, <<" password" >>)),
289
302
_C2 = test_close (Transport , S , C1 ),
290
303
closed = wait_for_socket_close (Transport , S , 10 ),
291
304
ok .
292
305
293
306
cannot_update_username_after_authenticated (Config ) ->
294
307
{S , C0 } = connect_and_authenticate (gen_tcp , Config ),
295
- C1 = expect_unsuccessful_authentication (
296
- try_authenticate (gen_tcp , S , C0 , <<" PLAIN" >>, <<" other" >>, <<" other" >>),
297
- ? RESPONSE_SASL_CANNOT_CHANGE_USERNAME ),
298
- _C2 = test_close (gen_tcp , S , C1 ),
308
+ _C1 = expect_unsuccessful_authentication (
309
+ try_authenticate (gen_tcp , S , C0 , <<" PLAIN" >>, <<" other" >>, <<" other" >>),
310
+ ? RESPONSE_SASL_CANNOT_CHANGE_USERNAME ),
299
311
closed = wait_for_socket_close (gen_tcp , S , 10 ),
300
312
ok .
301
313
302
314
cannot_use_another_authmechanism_when_updating_secret (Config ) ->
303
315
{S , C0 } = connect_and_authenticate (gen_tcp , Config ),
304
- C1 = expect_unsuccessful_authentication (
305
- try_authenticate (gen_tcp , S , C0 , <<" EXTERNAL" >>, <<" guest" >>, <<" new_password" >>),
306
- ? RESPONSE_SASL_CANNOT_CHANGE_MECHANISM ),
307
- _C2 = test_close (gen_tcp , S , C1 ),
316
+ _C1 = expect_unsuccessful_authentication (
317
+ try_authenticate (gen_tcp , S , C0 , <<" EXTERNAL" >>, <<" guest" >>, <<" new_password" >>),
318
+ ? RESPONSE_SASL_CANNOT_CHANGE_MECHANISM ),
308
319
closed = wait_for_socket_close (gen_tcp , S , 10 ),
309
320
ok .
310
321
322
+ update_secret_should_close_connection_if_wrong_secret (Config ) ->
323
+ Transport = gen_tcp ,
324
+ {S , C0 } = connect_and_authenticate (Transport , Config ),
325
+ Pwd = rand :bytes (20 ),
326
+ _C1 = expect_unsuccessful_authentication (
327
+ try_authenticate (Transport , S , C0 , <<" PLAIN" >>, <<" guest" >>, Pwd ),
328
+ ? RESPONSE_AUTHENTICATION_FAILURE ),
329
+ closed = wait_for_socket_close (Transport , S , 10 ),
330
+ ok .
331
+
332
+ update_secret_should_close_connection_if_unauthorized_vhost (Config ) ->
333
+ T = gen_tcp ,
334
+ Port = get_port (T , Config ),
335
+ Opts = get_opts (T ),
336
+ {ok , S } = T :connect (" localhost" , Port , Opts ),
337
+ C0 = rabbit_stream_core :init (0 ),
338
+ C1 = test_peer_properties (T , S , C0 ),
339
+ Username = <<" other" >>,
340
+ C2 = test_authenticate (T , S , C1 , Username ),
341
+ ok = rabbit_ct_broker_helpers :clear_permissions (Config , Username , <<" /" >>),
342
+ _C3 = expect_unsuccessful_authentication (
343
+ try_authenticate (gen_tcp , S , C2 , <<" PLAIN" >>, Username , Username ),
344
+ ? RESPONSE_VHOST_ACCESS_FAILURE ),
345
+ closed = wait_for_socket_close (T , S , 10 ),
346
+ ok .
347
+
311
348
test_stream_tls (Config ) ->
312
349
Stream = atom_to_binary (? FUNCTION_NAME , utf8 ),
313
350
test_server (ssl , Stream , Config ),
0 commit comments