summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2016-04-07 13:04:58 +0200
committerMickael Remond <mremond@process-one.net>2016-04-07 13:04:58 +0200
commit373f9fb0ebc5f3f004c6b78dd2d0c32631288d3b (patch)
treedf7041eb74a18010fab8400ed817b4fcadcb43d2 /test
parentAdd test when mixing ip / user rules (diff)
Add tests on Access rules returning values
Diffstat (limited to 'test')
-rw-r--r--test/acl_test.exs14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/acl_test.exs b/test/acl_test.exs
index cc968212..603b4bc4 100644
--- a/test/acl_test.exs
+++ b/test/acl_test.exs
@@ -70,6 +70,20 @@ defmodule ACLTest do
assert :acl.match_rule(:global, :user_rule_1, :jid.from_string("test1@domain2")) == :deny
end
+ # Access rules are sometimes used to provide values (i.e.: max_s2s_connections, max_user_sessions)
+ test "Access rules providing values" do
+ :acl.add(:global, :user_acl, {:user_regexp, ""})
+ :acl.add(:global, :admin_acl, {:user, "admin"})
+ :acl.add_access(:global, :value_rule_1, [{:admin_acl, 10}, {:user_acl, 5}])
+ assert :acl.match_rule(:global, :value_rule_1, :jid.from_string("test1@domain1")) == 5
+ assert :acl.match_rule(:global, :value_rule_1, :jid.from_string("admin@domain1")) == 10
+
+ # If we have no match, :deny is still the default value
+ # TODO maybe we should have a match rule which allow passing custom default value ?
+ assert :acl.match_rule(:global, :value_rule_1, :jid.from_string("user@otherdomain")) == :deny
+ end
+
+
# At the moment IP and user rules to no go well together:
test "mixing IP and user access rules" do
:acl.add(:global, :user_acl_1, {:user, "test1"})