aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMickael Remond <mremond@process-one.net>2016-07-25 18:28:40 +0200
committerMickael Remond <mremond@process-one.net>2016-07-25 18:28:40 +0200
commitdbc049827941f9d6f18fe3673141dabe41d118b4 (patch)
tree0cf6eb7799368b61672158e71c632c2eb4af0d99 /test
parentSimplify code for command policy group expansion (diff)
Fix tests, command need to be properly added to list of exposed commands
Diffstat (limited to 'test')
-rw-r--r--test/ejabberd_commands_mock_test.exs16
1 files changed, 9 insertions, 7 deletions
diff --git a/test/ejabberd_commands_mock_test.exs b/test/ejabberd_commands_mock_test.exs
index 7c15b58b3..72e7c2d3a 100644
--- a/test/ejabberd_commands_mock_test.exs
+++ b/test/ejabberd_commands_mock_test.exs
@@ -185,7 +185,7 @@ defmodule EjabberdCommandsMockTest do
test "API command with user policy" do
- mock_commands_config
+ mock_commands_config [:user, :admin]
# Register a command test(user, domain) -> {:versionN, user, domain}
# with policy=user and versions 1 & 3
@@ -319,7 +319,7 @@ defmodule EjabberdCommandsMockTest do
test "API command with admin policy" do
- mock_commands_config
+ mock_commands_config [:admin]
# Register a command test(user, domain) -> {user, domain}
# with policy=admin
@@ -398,7 +398,7 @@ defmodule EjabberdCommandsMockTest do
end
test "Commands can perform extra check on access" do
- mock_commands_config
+ mock_commands_config [:admin, :open]
command_name = :test
function = :test_command
@@ -414,8 +414,8 @@ defmodule EjabberdCommandsMockTest do
end)
assert :ok == :ejabberd_commands.register_commands [command]
- :acl.add(:global, :basic_acl_1, {:user, @user})
- :acl.add_access(:global, :basic_rule_1, [{:allow, [{:acl, :basic_acl_1}]}])
+# :acl.add(:global, :basic_acl_1, {:user, @user, @host})
+# :acl.add_access(:global, :basic_rule_1, [{:allow, [{:acl, :basic_acl_1}]}])
assert {@user, @domain} ==
:ejabberd_commands.execute_command(:undefined,
@@ -437,7 +437,7 @@ defmodule EjabberdCommandsMockTest do
# Mock a config where only @admin user is allowed to call commands
# as admin
- def mock_commands_config do
+ def mock_commands_config(commands \\ []) do
EjabberdAuthMock.init
EjabberdAuthMock.create_user @user, @domain, @userpass
EjabberdAuthMock.create_user @admin, @domain, @adminpass
@@ -446,11 +446,13 @@ defmodule EjabberdCommandsMockTest do
:meck.expect(:ejabberd_config, :get_option,
fn(:commands_admin_access, _, _) -> :commands_admin_access
(:oauth_access, _, _) -> :all
+ (:commands, _, _) -> [{:add_commands, commands}]
(_, _, default) -> default
end)
:meck.expect(:ejabberd_config, :get_myhosts,
fn() -> [@domain] end)
- :meck.new :acl #, [:passthrough]
+
+ :meck.new :acl
:meck.expect(:acl, :access_matches,
fn(:commands_admin_access, info, _scope) ->
case info do