diff options
-rw-r--r-- | src/mod_http_api.erl | 2 | ||||
-rw-r--r-- | test/ejabberd_commands_test.exs | 5 | ||||
-rw-r--r-- | test/elixir_SUITE.erl | 7 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl index 5775b215d..60196f650 100644 --- a/src/mod_http_api.erl +++ b/src/mod_http_api.erl @@ -309,6 +309,8 @@ handle(Call, Auth, Args, Version) when is_atom(Call), is_list(Args) -> {401, jlib:atom_to_binary(Why)}; throw:{not_allowed, Msg} -> {401, iolist_to_binary(Msg)}; + throw:{error, account_unprivileged} -> + {401, iolist_to_binary(<<"Unauthorized: Account Unpriviledged">>)}; throw:{invalid_parameter, Msg} -> {400, iolist_to_binary(Msg)}; throw:{error, Why} when is_atom(Why) -> diff --git a/test/ejabberd_commands_test.exs b/test/ejabberd_commands_test.exs index f415fee51..31d108214 100644 --- a/test/ejabberd_commands_test.exs +++ b/test/ejabberd_commands_test.exs @@ -27,6 +27,7 @@ defmodule EjabberdCommandsTest do Record.defrecord :ejabberd_commands, Record.extract(:ejabberd_commands, from_lib: "ejabberd/include/ejabberd_commands.hrl") setup_all do + :mnesia.start :ejabberd_commands.init end @@ -38,7 +39,9 @@ defmodule EjabberdCommandsTest do test "Check that admin commands are rejected with noauth credentials" do :ok = :ejabberd_commands.register_commands([admin_test_command]) - {:error, :account_unprivileged} = :ejabberd_commands.execute_command(:undefined, :noauth, :test_admin, []) + + assert catch_throw(:ejabberd_commands.execute_command(:undefined, :noauth, :test_admin, [])) == {:error, :account_unprivileged} + # Command executed from ejabberdctl passes anyway with access commands trick # TODO: We should refactor to have explicit call when bypassing auth check for command-line :ok = :ejabberd_commands.execute_command([], :noauth, :test_admin, []) diff --git a/test/elixir_SUITE.erl b/test/elixir_SUITE.erl index 7047d221e..f92f750aa 100644 --- a/test/elixir_SUITE.erl +++ b/test/elixir_SUITE.erl @@ -30,7 +30,7 @@ all() -> case is_elixir_available() of true -> Dir = test_dir(), - filelib:fold_files(Dir, ".*\.exs", false, + filelib:fold_files(Dir, ".*\.exs$", false, fun(Filename, Acc) -> [list_to_atom(filename:basename(Filename)) | Acc] end, []); false -> @@ -69,11 +69,6 @@ run_elixir_test(Func) -> %% Elixir tests can be tagged as follow to be ignored (place before test start) %% @tag pending: true 'Elixir.ExUnit':start([{exclude, [{pending, true}]}]), - filelib:fold_files(test_dir(), ".*\\.exs\$", true, - fun (File, N) -> - 'Elixir.Code':require_file(list_to_binary(File)), - N+1 - end, 0), 'Elixir.Code':load_file(list_to_binary(filename:join(test_dir(), atom_to_list(Func)))), %% I did not use map syntax, so that this file can still be build under R16 ResultMap = 'Elixir.ExUnit':run(), |