24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-16 22:05:29 +02:00

Fix tests, command need to be properly added to list of exposed commands

This commit is contained in:
Mickael Remond 2016-07-25 18:28:40 +02:00
parent c183092aa4
commit dbc0498279
No known key found for this signature in database
GPG Key ID: E6F6045D79965AA3

View File

@ -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