@@ -49,6 +49,7 @@ groups() ->
4949 cannot_update_username_after_authenticated ,
5050 cannot_use_another_authmechanism_when_updating_secret ,
5151 update_secret_should_close_connection_if_wrong_secret ,
52+ update_secret_should_close_connection_if_unauthorized_vhost ,
5253 unauthenticated_client_rejected_tcp_connected ,
5354 timeout_tcp_connected ,
5455 unauthenticated_client_rejected_peer_properties_exchanged ,
@@ -166,6 +167,12 @@ init_per_testcase(cannot_update_username_after_authenticated = TestCase, Config)
166167 ok = rabbit_ct_broker_helpers :add_user (Config , <<" other" >>),
167168 rabbit_ct_helpers :testcase_started (Config , TestCase );
168169
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+
169176init_per_testcase (close_connection_on_consumer_update_timeout = TestCase , Config ) ->
170177 ok = rabbit_ct_broker_helpers :rpc (Config ,
171178 0 ,
@@ -201,6 +208,11 @@ end_per_testcase(cannot_update_username_after_authenticated = TestCase, Config)
201208 ok = rabbit_ct_broker_helpers :delete_user (Config , <<" other" >>),
202209 rabbit_ct_helpers :testcase_finished (Config , TestCase );
203210
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+
204216end_per_testcase (close_connection_on_consumer_update_timeout = TestCase , Config ) ->
205217 ok = rabbit_ct_broker_helpers :rpc (Config ,
206218 0 ,
@@ -286,7 +298,7 @@ test_update_secret(Config) ->
286298 {S , C0 } = connect_and_authenticate (Transport , Config ),
287299 rabbit_ct_broker_helpers :change_password (Config , <<" guest" >>, <<" password" >>),
288300 C1 = expect_successful_authentication (
289- try_authenticate (Transport , S , C0 , <<" PLAIN" >>, <<" guest" >>, <<" password" >>)),
301+ try_authenticate (Transport , S , C0 , <<" PLAIN" >>, <<" guest" >>, <<" password" >>)),
290302 _C2 = test_close (Transport , S , C1 ),
291303 closed = wait_for_socket_close (Transport , S , 10 ),
292304 ok .
@@ -317,6 +329,22 @@ update_secret_should_close_connection_if_wrong_secret(Config) ->
317329 closed = wait_for_socket_close (Transport , S , 10 ),
318330 ok .
319331
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+
320348test_stream_tls (Config ) ->
321349 Stream = atom_to_binary (? FUNCTION_NAME , utf8 ),
322350 test_server (ssl , Stream , Config ),
0 commit comments