25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Fix failing tests

This commit is contained in:
Mickael Remond 2016-03-31 17:34:50 +02:00
parent 3290a5ff15
commit ef2e2e45b3
3 changed files with 7 additions and 7 deletions

View File

@ -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) ->

View File

@ -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, [])

View File

@ -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(),