aboutsummaryrefslogtreecommitdiff
path: root/test/mod_http_api_mock_test.exs
diff options
context:
space:
mode:
authorKonstantinos Kallas <konstantinos.kallas@hotmail.com>2017-07-26 09:54:23 +0300
committerKonstantinos Kallas <konstantinos.kallas@hotmail.com>2017-07-26 09:54:23 +0300
commit61d1411ab3321b437f6741703405860d18c82b93 (patch)
tree44481834335fb872eee63e205e81417fa26249d5 /test/mod_http_api_mock_test.exs
parentAdd an erl_opt so that rsa can be used when the otp version is enough (diff)
parentUpdate oauth2 dependency (diff)
Sync fork with upstream
Diffstat (limited to 'test/mod_http_api_mock_test.exs')
-rw-r--r--test/mod_http_api_mock_test.exs31
1 files changed, 6 insertions, 25 deletions
diff --git a/test/mod_http_api_mock_test.exs b/test/mod_http_api_mock_test.exs
index 4dde78939..ceda2bb0f 100644
--- a/test/mod_http_api_mock_test.exs
+++ b/test/mod_http_api_mock_test.exs
@@ -45,10 +45,11 @@ defmodule ModHttpApiMockTest do
:jid.start
:mnesia.start
:ejabberd_mnesia.start
- :stringprep.start
+ :stringprep.start
+ :ejabberd_hooks.start_link
:ejabberd_config.start([@domain], [])
{:ok, _} = :ejabberd_access_permissions.start_link()
- :ejabberd_commands.init
+ :ejabberd_commands.start_link
rescue
_ -> :ok
end
@@ -73,18 +74,12 @@ defmodule ModHttpApiMockTest do
fn (@acommand, %{usr: {@user, @domain, _}}, @version) ->
{[], {:res, :rescode}}
end)
- :meck.expect(:ejabberd_commands, :get_command_policy_and_scope,
- fn (@acommand) -> {:ok, :user, [:erlang.atom_to_binary(@acommand,:utf8)]} end)
- :meck.expect(:ejabberd_commands, :get_exposed_commands,
+ :meck.expect(:ejabberd_commands, :get_exposed_commands,
fn () -> [@acommand] end)
:meck.expect(:ejabberd_commands, :execute_command2,
fn (@acommand, [], %{usr: {@user, @domain, _}}, @version) ->
:ok
end)
- :meck.expect(:ejabberd_commands, :execute_command,
- fn (:undefined, {@user, @domain, @userpass, false}, @acommand, [], @version, _) ->
- :ok
- end)
:ejabberd_config.add_local_option(:commands, [[{:add_commands, [@acommand]}]])
@@ -130,9 +125,7 @@ defmodule ModHttpApiMockTest do
fn (@acommand, %{usr: {@user, @domain, _}}, @version) ->
{[], {:res, :rescode}}
end)
- :meck.expect(:ejabberd_commands, :get_command_policy_and_scope,
- fn (@acommand) -> {:ok, :user, [:erlang.atom_to_binary(@acommand,:utf8), "ejabberd:user"]} end)
- :meck.expect(:ejabberd_commands, :get_exposed_commands,
+ :meck.expect(:ejabberd_commands, :get_exposed_commands,
fn () -> [@acommand] end)
:meck.expect(:ejabberd_commands, :execute_command2,
fn (@acommand, [], %{usr: {@user, @domain, _}, oauth_scope: ["ejabberd:user"]}, @version) ->
@@ -142,11 +135,6 @@ defmodule ModHttpApiMockTest do
(@acommand, [], %{usr: {@user, @domain, _}, oauth_scope: _}, @version) ->
throw({:error, :access_rules_unauthorized})
end)
- :meck.expect(:ejabberd_commands, :execute_command,
- fn (:undefined, {@user, @domain, {:oauth, _token}, false},
- @acommand, [], @version, _) ->
- :ok
- end)
# Correct OAuth call using specific scope
@@ -231,15 +219,8 @@ defmodule ModHttpApiMockTest do
fn (@acommand, {@user, @domain, {:oauth, _token}, false}, @version) ->
{[], {:res, :rescode}}
end)
- :meck.expect(:ejabberd_commands, :get_command_policy_and_scope,
- fn (@acommand) -> {:ok, :user, [:erlang.atom_to_binary(@acommand,:utf8), "ejabberd:user"]} end)
- :meck.expect(:ejabberd_commands, :get_exposed_commands,
+ :meck.expect(:ejabberd_commands, :get_exposed_commands,
fn () -> [@acommand] end)
- :meck.expect(:ejabberd_commands, :execute_command,
- fn (:undefined, {@user, @domain, {:oauth, _token}, false},
- @acommand, [], @version, _) ->
- :ok
- end)
#Mock acl to allow oauth authorizations
:meck.expect(:acl, :match_rule, fn(_Server, _Access, _Jid) -> :allow end)