Make these tests more resilient to node data variations
E.g. if other test suites created a bunch of users first. We should not assume that there's only one user present.
This commit is contained in:
parent
31822baf8c
commit
2d60573f03
|
|
@ -76,7 +76,8 @@ defmodule SetPermissionsCommandTest do
|
||||||
vhost_opts
|
vhost_opts
|
||||||
) == :ok
|
) == :ok
|
||||||
|
|
||||||
assert List.first(list_permissions(context[:vhost]))[:configure] == "^#{context[:user]}-.*"
|
u = Enum.find(list_permissions(context[:vhost]), fn(x) -> x[:user] == context[:user] end)
|
||||||
|
assert u[:configure] == "^#{context[:user]}-.*"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "run: throws a badrpc when instructed to contact an unreachable RabbitMQ node" do
|
test "run: throws a badrpc when instructed to contact an unreachable RabbitMQ node" do
|
||||||
|
|
@ -93,8 +94,6 @@ defmodule SetPermissionsCommandTest do
|
||||||
[context[:user], "^#{context[:user]}-.*", ".*", ".*"],
|
[context[:user], "^#{context[:user]}-.*", ".*", ".*"],
|
||||||
context[:opts]
|
context[:opts]
|
||||||
) == {:error, {:no_such_user, context[:user]}}
|
) == {:error, {:no_such_user, context[:user]}}
|
||||||
|
|
||||||
assert List.first(list_permissions(context[:vhost]))[:configure] == ".*"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag user: @user, vhost: "wintermute"
|
@tag user: @user, vhost: "wintermute"
|
||||||
|
|
@ -108,14 +107,15 @@ defmodule SetPermissionsCommandTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag user: @user, vhost: @root
|
@tag user: @user, vhost: @root
|
||||||
test "run: Invalid regex patterns return error", context do
|
test "run: invalid regex patterns return error", context do
|
||||||
assert @command.run(
|
assert @command.run(
|
||||||
[context[:user], "^#{context[:user]}-.*", ".*", "*"],
|
[context[:user], "^#{context[:user]}-.*", ".*", "*"],
|
||||||
context[:opts]
|
context[:opts]
|
||||||
) == {:error, {:invalid_regexp, '*', {'nothing to repeat', 0}}}
|
) == {:error, {:invalid_regexp, '*', {'nothing to repeat', 0}}}
|
||||||
|
|
||||||
# asserts that the bad command didn't change anything
|
# asserts that the failed command didn't change anything
|
||||||
assert List.first(list_permissions(context[:vhost])) == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
|
u = Enum.find(list_permissions(context[:vhost]), fn(x) -> x[:user] == context[:user] end)
|
||||||
|
assert u == [user: context[:user], configure: ".*", write: ".*", read: ".*"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag user: @user, vhost: @vhost
|
@tag user: @user, vhost: @vhost
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue