@@ -104,6 +104,7 @@ all_tests() -> [
104104 definitions_server_named_queue_test ,
105105 definitions_with_charset_test ,
106106 definitions_default_queue_type_test ,
107+ definitions_vhost_metadata_test ,
107108 long_definitions_test ,
108109 long_definitions_multipart_test ,
109110 aliveness_test ,
@@ -439,7 +440,6 @@ auth_test(Config) ->
439440 % % NOTE: this one won't have www-authenticate in the response,
440441 % % because user/password are ok, tags are not
441442 test_auth (Config , ? NOT_AUTHORISED , [auth_header (" user" , " user" )]),
442- WrongAuthResponseHeaders = test_auth (Config , ? NOT_AUTHORISED , [auth_header (" guest" , " gust" )]),
443443 % ?assertEqual(true, lists:keymember("www-authenticate", 1, WrongAuthResponseHeaders)),
444444 test_auth (Config , ? OK , [auth_header (" guest" , " guest" )]),
445445 http_delete (Config , " /users/user" , {group , '2xx' }),
@@ -1800,6 +1800,48 @@ defs_default_queue_type_vhost(Config, QueueType) ->
18001800 http_delete (Config , " /vhosts/test-vhost" , {group , '2xx' }),
18011801 ok .
18021802
1803+ definitions_vhost_metadata_test (Config ) ->
1804+ register_parameters_and_policy_validator (Config ),
1805+
1806+ VHostName = <<" test-vhost" >>,
1807+ Desc = <<" Created by definitions_vhost_metadata_test" >>,
1808+ DQT = <<" quorum" >>,
1809+ Tags = [<<" one" >>, <<" tag-two" >>],
1810+ Metadata = #{
1811+ description => Desc ,
1812+ default_queue_type => DQT ,
1813+ tags => Tags
1814+ },
1815+
1816+ % % Create a test vhost
1817+ http_put (Config , " /vhosts/test-vhost" , Metadata , {group , '2xx' }),
1818+ PermArgs = [{configure , <<" .*" >>}, {write , <<" .*" >>}, {read , <<" .*" >>}],
1819+ http_put (Config , " /permissions/test-vhost/guest" , PermArgs , {group , '2xx' }),
1820+
1821+ % % Get the definitions
1822+ Definitions = http_get (Config , " /definitions" , ? OK ),
1823+
1824+ % % Check if vhost definition is correct
1825+ VHosts = maps :get (vhosts , Definitions ),
1826+ {value , VH } = lists :search (fun (VH ) ->
1827+ maps :get (name , VH ) =:= VHostName
1828+ end , VHosts ),
1829+ ct :pal (" VHost: ~p " , [VH ]),
1830+ ? assertEqual (#{
1831+ name => VHostName ,
1832+ description => Desc ,
1833+ default_queue_type => DQT ,
1834+ tags => Tags ,
1835+ metadata => Metadata
1836+ }, VH ),
1837+
1838+ % % Post the definitions back
1839+ http_post (Config , " /definitions" , Definitions , {group , '2xx' }),
1840+
1841+ % % Remove the test vhost
1842+ http_delete (Config , " /vhosts/test-vhost" , {group , '2xx' }),
1843+ ok .
1844+
18031845definitions_default_queue_type_test (Config ) ->
18041846 defs_default_queue_type_vhost (Config , <<" classic" >>),
18051847 defs_default_queue_type_vhost (Config , <<" quorum" >>).
0 commit comments