{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) ->
Record.defrecord :ejabberd_commands, Record.extract(:ejabberd_commands, from_lib: "ejabberd/include/ejabberd_commands.hrl")
setup_all do
+ :mnesia.start
:ejabberd_commands.init
end
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, [])
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 ->
%% 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(),