From 5ef542a638e25f934e9db179c305f2496202f4f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Thu, 6 Jul 2017 16:05:12 +0200 Subject: Remove tests for old commands interface --- test/mod_http_api_mock_test.exs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'test/mod_http_api_mock_test.exs') diff --git a/test/mod_http_api_mock_test.exs b/test/mod_http_api_mock_test.exs index 4dde78939..38337d95b 100644 --- a/test/mod_http_api_mock_test.exs +++ b/test/mod_http_api_mock_test.exs @@ -73,9 +73,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)]} 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) -> @@ -130,9 +128,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) -> @@ -231,9 +227,7 @@ 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}, -- cgit v1.2.3 From eb9faffadda2de756a077e3538754ba29b1436e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Thu, 6 Jul 2017 17:19:05 +0200 Subject: Improve elixir tests --- test/mod_http_api_mock_test.exs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'test/mod_http_api_mock_test.exs') diff --git a/test/mod_http_api_mock_test.exs b/test/mod_http_api_mock_test.exs index 38337d95b..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 @@ -79,10 +80,6 @@ defmodule ModHttpApiMockTest do 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]}]]) @@ -138,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 @@ -229,11 +221,6 @@ defmodule ModHttpApiMockTest do end) :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) -- cgit v1.2.3