@@ -31,7 +31,8 @@ groups() ->
3131
3232all_tests () -> [
3333 protected_virtual_host_cannot_be_deleted ,
34- virtual_host_can_be_deleted_after_protection_removal
34+ virtual_host_can_be_deleted_after_protection_removal ,
35+ protected_virtual_host_is_marked_as_such_in_definition_export
3536 ].
3637
3738% % -------------------------------------------------------------------
@@ -131,4 +132,39 @@ virtual_host_can_be_deleted_after_protection_removal(Config) ->
131132 % % subsequent deletion responds with a 404 Not Found
132133 http_delete (Config , Path , ? NOT_FOUND ),
133134
135+ passed .
136+
137+ protected_virtual_host_is_marked_as_such_in_definition_export (Config ) ->
138+ Name = rabbit_data_coercion :to_binary (? FUNCTION_NAME ),
139+
140+ % % extra care needs to be taken to a delete a potentially protected virtual host
141+ rabbit_ct_broker_helpers :disable_vhost_protection_from_deletion (Config , Name ),
142+ rabbit_ct_broker_helpers :delete_vhost (Config , Name ),
143+
144+ rabbit_ct_broker_helpers :add_vhost (Config , Name ),
145+ rabbit_ct_broker_helpers :set_full_permissions (Config , Name ),
146+
147+ % % protect the virtual host from deletion
148+ rabbit_ct_broker_helpers :enable_vhost_protection_from_deletion (Config , Name ),
149+
150+ % % Get the definitions
151+ Definitions = http_get (Config , " /definitions" , ? OK ),
152+ ct :pal (" Exported definitions:~n~tp~tn " , [Definitions ]),
153+
154+ % % Check if vhost definition is correct
155+ VHosts = maps :get (vhosts , Definitions ),
156+ {value , VHost } = lists :search (fun (VHost ) ->
157+ maps :get (name , VHost ) =:= Name
158+ end , VHosts ),
159+
160+ Metadata = maps :get (metadata , VHost ),
161+ ? assertEqual (Name , maps :get (name , VHost )),
162+ ? assertEqual (Metadata , #{
163+ protected_from_deletion => true ,
164+ default_queue_type => <<" classic" >>
165+ }),
166+
167+ rabbit_ct_broker_helpers :disable_vhost_protection_from_deletion (Config , Name ),
168+ rabbit_ct_broker_helpers :delete_vhost (Config , Name ),
169+
134170 passed .
0 commit comments