@@ -41,11 +41,13 @@ defmodule SetPermissionsGloballyCommandTest do
4141 }
4242 end
4343
44+ @ tag user: @ user
4445 test "merge_defaults: defaults can be overridden" do
4546 assert @ command . merge_defaults ( [ ] , % { } ) == { [ ] , % { vhost: "/" } }
4647 assert @ command . merge_defaults ( [ ] , % { vhost: "non_default" } ) == { [ ] , % { vhost: "non_default" } }
4748 end
4849
50+ @ tag user: @ user
4951 test "validate: wrong number of arguments leads to an arg count error" do
5052 assert @ command . validate ( [ ] , % { } ) == { :validation_failure , :not_enough_args }
5153 assert @ command . validate ( [ "insufficient" ] , % { } ) == { :validation_failure , :not_enough_args }
@@ -74,6 +76,7 @@ defmodule SetPermissionsGloballyCommandTest do
7476 assert p3 [ :configure ] == "^#{ context [ :user ] } -.*"
7577 end
7678
79+ @ tag user: @ user
7780 test "run: throws a badrpc when instructed to contact an unreachable RabbitMQ node" do
7881 opts = % { node: :jake@thedog , timeout: 200 }
7982
@@ -90,19 +93,23 @@ defmodule SetPermissionsGloballyCommandTest do
9093
9194 @ tag user: @ user
9295 test "run: invalid regex patterns returns an error" , context do
96+ p1 = Enum . find ( list_permissions ( @ vhost1 ) , fn x -> x [ :user ] == context [ :user ] end )
97+ p2 = Enum . find ( list_permissions ( @ vhost2 ) , fn x -> x [ :user ] == context [ :user ] end )
98+ p3 = Enum . find ( list_permissions ( @ vhost3 ) , fn x -> x [ :user ] == context [ :user ] end )
99+
93100 assert @ command . run (
94101 [ context [ :user ] , "^#{ context [ :user ] } -.*" , ".*" , "*" ] ,
95102 context [ :opts ]
96103 ) == { :error , { :invalid_regexp , '*' , { 'nothing to repeat' , 0 } } }
97104
98105 # asserts that the failed command didn't change anything
99- p1 = Enum . find ( list_permissions ( @ vhost1 ) , fn x -> x [ :user ] == context [ :user ] end )
100- p2 = Enum . find ( list_permissions ( @ vhost2 ) , fn x -> x [ :user ] == context [ :user ] end )
101- p3 = Enum . find ( list_permissions ( @ vhost3 ) , fn x -> x [ :user ] == context [ :user ] end )
106+ p4 = Enum . find ( list_permissions ( @ vhost1 ) , fn x -> x [ :user ] == context [ :user ] end )
107+ p5 = Enum . find ( list_permissions ( @ vhost2 ) , fn x -> x [ :user ] == context [ :user ] end )
108+ p6 = Enum . find ( list_permissions ( @ vhost3 ) , fn x -> x [ :user ] == context [ :user ] end )
102109
103- assert p1 == [ user: context [ :user ] , configure: ".*" , write: ".*" , read: ".*" ]
104- assert p2 == [ user: context [ :user ] , configure: ".*" , write: ".*" , read: ".*" ]
105- assert p3 == [ user: context [ :user ] , configure: ".*" , write: ".*" , read: ".*" ]
110+ assert p1 == p4
111+ assert p2 == p5
112+ assert p3 == p6
106113 end
107114
108115 @ tag user: @ user
0 commit comments