aboutsummaryrefslogtreecommitdiff
path: root/test/mod_http_api_test.exs
diff options
context:
space:
mode:
authorPaweł Chmielowski <pchmielowski@process-one.net>2017-07-06 17:19:05 +0200
committerPaweł Chmielowski <pchmielowski@process-one.net>2017-07-06 17:19:22 +0200
commiteb9faffadda2de756a077e3538754ba29b1436e7 (patch)
tree72c1800b3919ab9d940223149b43fe58340f9325 /test/mod_http_api_test.exs
parentHandle new possible result from ejabberd_config.add_option (diff)
Improve elixir tests
Diffstat (limited to 'test/mod_http_api_test.exs')
-rw-r--r--test/mod_http_api_test.exs10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/mod_http_api_test.exs b/test/mod_http_api_test.exs
index c39af79dc..29405a3ec 100644
--- a/test/mod_http_api_test.exs
+++ b/test/mod_http_api_test.exs
@@ -31,9 +31,11 @@ defmodule ModHttpApiTest do
:ok = :mnesia.start
:ejabberd_mnesia.start
:stringprep.start
+ :ejabberd_hooks.start_link
:ok = :ejabberd_config.start(["localhost"], [])
+ :acl.start_link
{:ok, _} = :ejabberd_access_permissions.start_link()
- :ok = :ejabberd_commands.init
+ {:ok, _} = :ejabberd_commands.start_link
:ok = :ejabberd_commands.register_commands(cmds)
on_exit fn ->
:meck.unload
@@ -42,7 +44,7 @@ defmodule ModHttpApiTest do
test "We can expose several commands to API at a time" do
setup_mocks()
- :ejabberd_commands.expose_commands([:open_cmd, :user_cmd])
+ assert :ok == :ejabberd_commands.expose_commands([:open_cmd, :user_cmd])
commands = :ejabberd_commands.get_exposed_commands()
assert Enum.member?(commands, :open_cmd)
assert Enum.member?(commands, :user_cmd)
@@ -58,14 +60,14 @@ defmodule ModHttpApiTest do
# This related to the commands config file option
test "Attempting to access a command that is not exposed as HTTP API returns 403" do
setup_mocks()
- :ejabberd_commands.expose_commands([])
+ assert :ok == :ejabberd_commands.expose_commands([])
request = request(method: :POST, ip: {{127,0,0,1},50000}, data: "[]")
{403, _, _} = :mod_http_api.process(["open_cmd"], request)
end
test "Call to user, admin or restricted commands without authentication are rejected" do
setup_mocks()
- :ejabberd_commands.expose_commands([:user_cmd, :admin_cmd, :restricted])
+ assert :ok == :ejabberd_commands.expose_commands([:user_cmd, :admin_cmd, :restricted])
request = request(method: :POST, ip: {{127,0,0,1},50000}, data: "[]")
{403, _, _} = :mod_http_api.process(["user_cmd"], request)
{403, _, _} = :mod_http_api.process(["admin_cmd"], request)