From dbc049827941f9d6f18fe3673141dabe41d118b4 Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Mon, 25 Jul 2016 18:28:40 +0200 Subject: [PATCH] Fix tests, command need to be properly added to list of exposed commands --- test/ejabberd_commands_mock_test.exs | 16 +++++++++------- 1 file 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 -- 2.40.0