mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Make test suite working again
This commit is contained in:
parent
e564f9ae31
commit
435e5e6263
@ -122,7 +122,7 @@ register_connection(_SID,
|
||||
case proplists:get_value(auth_module, Info) of
|
||||
?MODULE ->
|
||||
ejabberd_hooks:run(register_user, LServer, [LUser, LServer]);
|
||||
false ->
|
||||
_ ->
|
||||
ok
|
||||
end.
|
||||
|
||||
|
@ -368,11 +368,15 @@ bind(R, #{user := U, server := S, access := Access, lang := Lang,
|
||||
allow ->
|
||||
State1 = open_session(State#{resource => Resource,
|
||||
sid => ejabberd_sm:make_sid()}),
|
||||
State2 = ejabberd_hooks:run_fold(
|
||||
c2s_session_opened, LServer, State1, []),
|
||||
LBJID = jid:remove_resource(jid:tolower(JID)),
|
||||
PresF = ?SETS:add_element(LBJID, maps:get(pres_f, State1)),
|
||||
PresT = ?SETS:add_element(LBJID, maps:get(pres_t, State1)),
|
||||
State2 = State1#{pres_f => PresF, pres_t => PresT},
|
||||
State3 = ejabberd_hooks:run_fold(
|
||||
c2s_session_opened, LServer, State2, []),
|
||||
?INFO_MSG("(~s) Opened c2s session for ~s",
|
||||
[SockMod:pp(Socket), jid:to_string(JID)]),
|
||||
{ok, State2};
|
||||
{ok, State3};
|
||||
deny ->
|
||||
ejabberd_hooks:run(forbidden_session_hook, LServer, [JID]),
|
||||
?INFO_MSG("(~s) Forbidden c2s session for ~s",
|
||||
|
@ -33,7 +33,7 @@
|
||||
-export([start/0, start_link/0]).
|
||||
|
||||
-export([route/3, route_iq/4, route_iq/5, process_iq/3,
|
||||
process_iq_reply/3, register_iq_handler/4,
|
||||
process_iq_reply/3, register_iq_handler/4, get_features/1,
|
||||
register_iq_handler/5, register_iq_response_handler/4,
|
||||
register_iq_response_handler/5, unregister_iq_handler/2,
|
||||
unregister_iq_response_handler/2, bounce_resource_packet/3]).
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
-include("logger.hrl").
|
||||
|
||||
-include_lib("stdlib/include/ms_transform.hrl").
|
||||
-include("xmpp.hrl").
|
||||
|
||||
-record(state, {}).
|
||||
@ -193,6 +193,14 @@ bounce_resource_packet(From, To, Packet) ->
|
||||
ejabberd_router:route_error(To, From, Packet, Err),
|
||||
stop.
|
||||
|
||||
-spec get_features(binary()) -> [binary()].
|
||||
get_features(Host) ->
|
||||
ets:select(
|
||||
?IQTABLE,
|
||||
ets:fun2ms(fun({{XMLNS, H}, _, _, _}) when H == Host ->
|
||||
XMLNS
|
||||
end)).
|
||||
|
||||
%%====================================================================
|
||||
%% gen_server callbacks
|
||||
%%====================================================================
|
||||
|
@ -176,6 +176,8 @@ handle_info({mnesia_table_event,
|
||||
{write, #route{pid = Pid}, _ActivityId}}, State) ->
|
||||
erlang:monitor(process, Pid),
|
||||
{noreply, State};
|
||||
handle_info({mnesia_table_event, _}, State) ->
|
||||
{noreply, State};
|
||||
handle_info({'DOWN', _Ref, _Type, Pid, _Info}, State) ->
|
||||
F = fun () ->
|
||||
Es = mnesia:select(route,
|
||||
|
@ -698,6 +698,7 @@ opt_type(domain_certfile) -> fun iolist_to_binary/1;
|
||||
opt_type(s2s_certfile) -> fun iolist_to_binary/1;
|
||||
opt_type(s2s_ciphers) -> fun iolist_to_binary/1;
|
||||
opt_type(s2s_dhfile) -> fun iolist_to_binary/1;
|
||||
opt_type(s2s_cafile) -> fun iolist_to_binary/1;
|
||||
opt_type(s2s_protocol_options) ->
|
||||
fun (Options) -> str:join(Options, <<"|">>) end;
|
||||
opt_type(s2s_tls_compression) ->
|
||||
@ -717,5 +718,5 @@ opt_type(s2s_timeout) ->
|
||||
end;
|
||||
opt_type(_) ->
|
||||
[route_subdomains, s2s_access, s2s_certfile,
|
||||
s2s_ciphers, s2s_dhfile, s2s_protocol_options,
|
||||
s2s_ciphers, s2s_dhfile, s2s_cafile, s2s_protocol_options,
|
||||
s2s_tls_compression, s2s_use_starttls, s2s_timeout].
|
||||
|
@ -93,6 +93,7 @@ init([State, Opts]) ->
|
||||
lang => ?MYLANG,
|
||||
server => ?MYNAME,
|
||||
host_opts => HostOpts,
|
||||
stream_version => undefined,
|
||||
check_from => CheckFrom},
|
||||
ejabberd_hooks:run_fold(component_init, {ok, State1}, [Opts]).
|
||||
|
||||
@ -128,10 +129,10 @@ get_password_fun(#{remote_server := RemoteServer,
|
||||
{ok, Password} ->
|
||||
{Password, undefined};
|
||||
error ->
|
||||
?ERROR_MSG("(~s) Domain ~s is unconfigured for "
|
||||
"external component from ~s",
|
||||
[SockMod:pp(Socket), RemoteServer,
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
|
||||
?INFO_MSG("(~s) Domain ~s is unconfigured for "
|
||||
"external component from ~s",
|
||||
[SockMod:pp(Socket), RemoteServer,
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(IP))]),
|
||||
{false, undefined}
|
||||
end
|
||||
end.
|
||||
@ -155,14 +156,14 @@ handle_auth_failure(_, Mech, Reason,
|
||||
#{remote_server := RemoteServer,
|
||||
sockmod := SockMod,
|
||||
socket := Socket, ip := IP} = State) ->
|
||||
?ERROR_MSG("(~s) Failed external component ~s authentication "
|
||||
"for ~s from ~s: ~s",
|
||||
[SockMod:pp(Socket), Mech, RemoteServer,
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)),
|
||||
Reason]),
|
||||
?INFO_MSG("(~s) Failed external component ~s authentication "
|
||||
"for ~s from ~s: ~s",
|
||||
[SockMod:pp(Socket), Mech, RemoteServer,
|
||||
ejabberd_config:may_hide_data(jlib:ip_to_list(IP)),
|
||||
Reason]),
|
||||
State.
|
||||
|
||||
handle_authenticated_packet(Pkt, #{lang := Lang} = State) ->
|
||||
handle_authenticated_packet(Pkt, #{lang := Lang} = State) when ?is_stanza(Pkt) ->
|
||||
From = xmpp:get_from(Pkt),
|
||||
case check_from(From, State) of
|
||||
true ->
|
||||
@ -173,7 +174,9 @@ handle_authenticated_packet(Pkt, #{lang := Lang} = State) ->
|
||||
Txt = <<"Improper domain part of 'from' attribute">>,
|
||||
Err = xmpp:serr_invalid_from(Txt, Lang),
|
||||
xmpp_stream_in:send(State, Err)
|
||||
end.
|
||||
end;
|
||||
handle_authenticated_packet(_Pkt, State) ->
|
||||
State.
|
||||
|
||||
handle_info({route, From, To, Packet}, #{access := Access} = State) ->
|
||||
case acl:match_rule(global, Access, From) of
|
||||
|
@ -160,7 +160,7 @@ process_block(#iq{from = #jid{luser = LUser, lserver = LServer},
|
||||
broadcast_list_update(LUser, LServer, UserList, Default),
|
||||
broadcast_event(LUser, LServer,
|
||||
#block{items = [jid:make(J) || J <- JIDs]}),
|
||||
xmpp:make_iq_result(IQ);
|
||||
xmpp:make_iq_result(xmpp:put_meta(IQ, privacy_list, UserList));
|
||||
_Err ->
|
||||
?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer, JIDs}, _Err]),
|
||||
Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang),
|
||||
@ -183,7 +183,7 @@ process_unblock_all(#iq{from = #jid{luser = LUser, lserver = LServer},
|
||||
UserList = make_userlist(Default, List),
|
||||
broadcast_list_update(LUser, LServer, UserList, Default),
|
||||
broadcast_event(LUser, LServer, #unblock{}),
|
||||
xmpp:make_iq_result(IQ);
|
||||
xmpp:make_iq_result(xmpp:put_meta(IQ, privacy_list, UserList));
|
||||
_Err ->
|
||||
?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer}, _Err]),
|
||||
Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang),
|
||||
@ -210,7 +210,7 @@ process_unblock(#iq{from = #jid{luser = LUser, lserver = LServer},
|
||||
broadcast_list_update(LUser, LServer, UserList, Default),
|
||||
broadcast_event(LUser, LServer,
|
||||
#unblock{items = [jid:make(J) || J <- JIDs]}),
|
||||
xmpp:make_iq_result(IQ);
|
||||
xmpp:make_iq_result(xmpp:put_meta(IQ, privacy_list, UserList));
|
||||
_Err ->
|
||||
?ERROR_MSG("Error processing ~p: ~p", [{LUser, LServer, JIDs}, _Err]),
|
||||
Err = xmpp:err_internal_server_error(<<"Database failure">>, Lang),
|
||||
|
@ -175,13 +175,16 @@ get_local_identity(Acc, _From, _To, _Node, _Lang) ->
|
||||
get_local_features({error, _Error} = Acc, _From, _To,
|
||||
_Node, _Lang) ->
|
||||
Acc;
|
||||
get_local_features(Acc, _From, _To, <<"">>, _Lang) ->
|
||||
get_local_features(Acc, _From, To, <<"">>, _Lang) ->
|
||||
Feats = case Acc of
|
||||
{result, Features} -> Features;
|
||||
empty -> []
|
||||
end,
|
||||
{result, [<<"iq">>, <<"presence">>,
|
||||
?NS_DISCO_INFO, ?NS_DISCO_ITEMS |Feats]};
|
||||
{result, lists:usort(
|
||||
lists:flatten(
|
||||
[<<"iq">>, <<"presence">>,
|
||||
?NS_DISCO_INFO, ?NS_DISCO_ITEMS, Feats,
|
||||
ejabberd_local:get_features(To#jid.lserver)]))};
|
||||
get_local_features(Acc, _From, _To, _Node, Lang) ->
|
||||
case Acc of
|
||||
{result, _Features} -> Acc;
|
||||
|
@ -135,12 +135,12 @@ shutdown_rooms(Host) ->
|
||||
MyHost = gen_mod:get_module_opt_host(Host, mod_muc,
|
||||
<<"conference.@HOST@">>),
|
||||
Rooms = RMod:get_online_rooms(MyHost, undefined),
|
||||
lists:filter(
|
||||
lists:flatmap(
|
||||
fun({_, _, Pid}) when node(Pid) == node() ->
|
||||
Pid ! shutdown,
|
||||
true;
|
||||
[Pid];
|
||||
(_) ->
|
||||
false
|
||||
[]
|
||||
end, Rooms).
|
||||
|
||||
%% This function is called by a room in three situations:
|
||||
|
@ -561,6 +561,8 @@ resend_offline_messages(User, Server) ->
|
||||
_ -> ok
|
||||
end.
|
||||
|
||||
c2s_self_presence({_Pres, #{resend_offline := false}} = Acc) ->
|
||||
Acc;
|
||||
c2s_self_presence({#presence{type = available} = NewPres, State} = Acc) ->
|
||||
NewPrio = get_priority_from_presence(NewPres),
|
||||
LastPrio = try maps:get(pres_last, State) of
|
||||
|
@ -79,7 +79,7 @@ stream_feature_register(Acc, Host) ->
|
||||
AF = gen_mod:get_module_opt(Host, ?MODULE, access_from,
|
||||
fun(A) -> A end,
|
||||
all),
|
||||
case (AF /= none) and lists:keymember(sasl_mechanisms, 1, Acc) of
|
||||
case (AF /= none) of
|
||||
true ->
|
||||
[#feature_register{}|Acc];
|
||||
false ->
|
||||
@ -90,10 +90,11 @@ c2s_unauthenticated_packet(#{ip := IP, server := Server} = State,
|
||||
#iq{type = T, sub_els = [_]} = IQ)
|
||||
when T == set; T == get ->
|
||||
case xmpp:get_subtag(IQ, #register{}) of
|
||||
#register{} ->
|
||||
#register{} = Register ->
|
||||
{Address, _} = IP,
|
||||
IQ1 = xmpp:set_from_to(IQ, jid:make(<<>>), jid:make(Server)),
|
||||
ResIQ = process_iq(IQ1, Address),
|
||||
IQ1 = xmpp:set_els(IQ, [Register]),
|
||||
IQ2 = xmpp:set_from_to(IQ1, jid:make(<<>>), jid:make(Server)),
|
||||
ResIQ = process_iq(IQ2, Address),
|
||||
ResIQ1 = xmpp:set_from_to(ResIQ, jid:make(Server), undefined),
|
||||
{stop, ejabberd_c2s:send(State, ResIQ1)};
|
||||
false ->
|
||||
|
@ -521,13 +521,12 @@ roster_change(#{user := U, server := S, resource := R,
|
||||
end.
|
||||
|
||||
-spec c2s_session_opened(ejabberd_c2s:state()) -> ejabberd_c2s:state().
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID,
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer},
|
||||
pres_f := PresF, pres_t := PresT} = State) ->
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
Items = Mod:get_only_items(LUser, LServer),
|
||||
{F, T} = fill_subscription_lists(Items, PresF, PresT),
|
||||
LJID = jid:tolower(jid:remove_resource(JID)),
|
||||
State#{pres_f => ?SETS:add(LJID, F), pres_t => ?SETS:add(LJID, T)}.
|
||||
State#{pres_f => F, pres_t => T}.
|
||||
|
||||
fill_subscription_lists([I | Is], F, T) ->
|
||||
J = element(3, I#roster.usj),
|
||||
|
@ -175,11 +175,12 @@ s2s_in_packet(#{stream_id := StreamID} = State,
|
||||
{ok, Pid} = ejabberd_s2s_out:start(
|
||||
To, From, [{db_verify, {StreamID, Key, self()}}]),
|
||||
ejabberd_s2s_out:connect(Pid),
|
||||
State
|
||||
{stop, State}
|
||||
catch _:{badmatch, {error, Reason}} ->
|
||||
send_db_result(State,
|
||||
#db_verify{from = From, to = To, type = error,
|
||||
sub_els = [mk_error(Reason)]})
|
||||
{stop,
|
||||
send_db_result(State,
|
||||
#db_verify{from = From, to = To, type = error,
|
||||
sub_els = [mk_error(Reason)]})}
|
||||
end;
|
||||
s2s_in_packet(State, #db_verify{to = To, from = From, key = Key,
|
||||
id = StreamID, type = undefined}) ->
|
||||
@ -189,7 +190,7 @@ s2s_in_packet(State, #db_verify{to = To, from = From, key = Key,
|
||||
_ -> invalid
|
||||
end,
|
||||
Response = #db_verify{from = To, to = From, id = StreamID, type = Type},
|
||||
ejabberd_s2s_in:send(State, Response);
|
||||
{stop, ejabberd_s2s_in:send(State, Response)};
|
||||
s2s_in_packet(State, Pkt) when is_record(Pkt, db_result);
|
||||
is_record(Pkt, db_verify) ->
|
||||
?WARNING_MSG("Got stray dialback packet:~n~s", [xmpp:pp(Pkt)]),
|
||||
|
@ -292,7 +292,7 @@ set_item(User, Server, Resource, Item) ->
|
||||
jid:make(Server),
|
||||
ResIQ).
|
||||
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID,
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer},
|
||||
pres_f := PresF, pres_t := PresT} = State) ->
|
||||
US = {LUser, LServer},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
@ -300,11 +300,12 @@ c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID,
|
||||
get_group_users(LServer, Group)
|
||||
end,
|
||||
DisplayedGroups),
|
||||
BareLJID = jid:tolower(jid:remove_resource(JID)),
|
||||
PresBoth = lists:foldl(
|
||||
fun({U, S}, Acc) ->
|
||||
fun({U, S, _}, Acc) ->
|
||||
?SETS:add_element({U, S, <<"">>}, Acc);
|
||||
({U, S}, Acc) ->
|
||||
?SETS:add_element({U, S, <<"">>}, Acc)
|
||||
end, ?SETS:new(), [BareLJID|SRUsers]),
|
||||
end, ?SETS:new(), SRUsers),
|
||||
State#{pres_f => ?SETS:union(PresBoth, PresF),
|
||||
pres_t => ?SETS:union(PresBoth, PresT)}.
|
||||
|
||||
|
@ -161,7 +161,7 @@ process_item(RosterItem, _Host) ->
|
||||
_ -> RosterItem#roster{subscription = both, ask = none}
|
||||
end.
|
||||
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID,
|
||||
c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer},
|
||||
pres_f := PresF, pres_t := PresT} = State) ->
|
||||
US = {LUser, LServer},
|
||||
DisplayedGroups = get_user_displayed_groups(US),
|
||||
@ -169,11 +169,12 @@ c2s_session_opened(#{jid := #jid{luser = LUser, lserver = LServer} = JID,
|
||||
get_group_users(LServer, Group)
|
||||
end,
|
||||
DisplayedGroups),
|
||||
BareLJID = jid:tolower(jid:remove_resource(JID)),
|
||||
PresBoth = lists:foldl(
|
||||
fun({U, S}, Acc) ->
|
||||
fun({U, S, _}, Acc) ->
|
||||
?SETS:add_element({U, S, <<"">>}, Acc);
|
||||
({U, S}, Acc) ->
|
||||
?SETS:add_element({U, S, <<"">>}, Acc)
|
||||
end, ?SETS:new(), [BareLJID|SRUsers]),
|
||||
end, ?SETS:new(), SRUsers),
|
||||
State#{pres_f => ?SETS:union(PresBoth, PresF),
|
||||
pres_t => ?SETS:union(PresBoth, PresT)}.
|
||||
|
||||
|
@ -559,8 +559,8 @@ process_element(Pkt, #{stream_state := StateName, lang := Lang} = State) ->
|
||||
process_unauthenticated_packet(Pkt, State);
|
||||
_ when StateName == wait_for_starttls ->
|
||||
Txt = <<"Use of STARTTLS required">>,
|
||||
Err = xmpp:err_policy_violation(Txt, Lang),
|
||||
send_error(State, Pkt, Err);
|
||||
Err = xmpp:serr_policy_violation(Txt, Lang),
|
||||
send_pkt(State, Err);
|
||||
_ when StateName == wait_for_bind ->
|
||||
process_bind(Pkt, State);
|
||||
_ when StateName == established ->
|
||||
|
@ -285,6 +285,8 @@ init_per_testcase(TestCase, OrigConfig) ->
|
||||
case Test of
|
||||
"test_connect" ++ _ ->
|
||||
Config;
|
||||
"test_legacy_auth_feature" ->
|
||||
connect(Config);
|
||||
"test_legacy_auth" ++ _ ->
|
||||
init_stream(set_opt(stream_version, undefined, Config));
|
||||
"test_auth" ++ _ ->
|
||||
@ -326,7 +328,8 @@ end_per_testcase(_TestCase, _Config) ->
|
||||
|
||||
legacy_auth_tests() ->
|
||||
{legacy_auth, [parallel],
|
||||
[test_legacy_auth,
|
||||
[test_legacy_auth_feature,
|
||||
test_legacy_auth,
|
||||
test_legacy_auth_digest,
|
||||
test_legacy_auth_no_resource,
|
||||
test_legacy_auth_bad_jid,
|
||||
@ -344,7 +347,8 @@ no_db_tests() ->
|
||||
test_connect_missing_to,
|
||||
test_connect,
|
||||
unauthenticated_iq,
|
||||
unauthenticated_stanza,
|
||||
unauthenticated_message,
|
||||
unauthenticated_presence,
|
||||
test_starttls,
|
||||
test_zlib,
|
||||
test_auth,
|
||||
@ -481,7 +485,8 @@ component_tests() ->
|
||||
test_auth,
|
||||
test_auth_fail]},
|
||||
{component_tests, [sequence],
|
||||
[test_missing_address,
|
||||
[test_missing_from,
|
||||
test_missing_to,
|
||||
test_invalid_from,
|
||||
test_component_send,
|
||||
bad_nonza,
|
||||
@ -497,11 +502,11 @@ s2s_tests() ->
|
||||
test_connect,
|
||||
test_connect_s2s_starttls_required,
|
||||
test_starttls,
|
||||
test_connect_missing_from,
|
||||
test_connect_s2s_unauthenticated_iq,
|
||||
test_auth_starttls]},
|
||||
{s2s_tests, [sequence],
|
||||
[test_missing_address,
|
||||
[test_missing_from,
|
||||
test_missing_to,
|
||||
test_invalid_from,
|
||||
bad_nonza,
|
||||
codec_failure]}].
|
||||
@ -598,20 +603,12 @@ test_connect_missing_to(Config) ->
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config0).
|
||||
|
||||
test_connect_missing_from(Config) ->
|
||||
Config1 = starttls(connect(Config)),
|
||||
Config2 = set_opt(stream_from, <<"">>, Config1),
|
||||
Config3 = init_stream(Config2),
|
||||
?recv1(#stream_error{reason = 'policy-violation'}),
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config3).
|
||||
|
||||
test_connect(Config) ->
|
||||
disconnect(connect(Config)).
|
||||
|
||||
test_connect_s2s_starttls_required(Config) ->
|
||||
Config1 = connect(Config),
|
||||
send(Config1, #caps{}),
|
||||
send(Config1, #presence{}),
|
||||
?recv1(#stream_error{reason = 'policy-violation'}),
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config1).
|
||||
@ -681,18 +678,23 @@ try_unregister(Config) ->
|
||||
?recv1(#stream_error{reason = conflict}),
|
||||
Config.
|
||||
|
||||
unauthenticated_stanza(Config) ->
|
||||
%% Unauthenticated stanza should be silently dropped.
|
||||
send(Config, #message{to = server_jid(Config)}),
|
||||
disconnect(Config).
|
||||
unauthenticated_presence(Config) ->
|
||||
unauthenticated_packet(Config, #presence{}).
|
||||
|
||||
unauthenticated_message(Config) ->
|
||||
unauthenticated_packet(Config, #message{}).
|
||||
|
||||
unauthenticated_iq(Config) ->
|
||||
IQ = #iq{type = get, sub_els = [#disco_info{}]},
|
||||
unauthenticated_packet(Config, IQ).
|
||||
|
||||
unauthenticated_packet(Config, Pkt) ->
|
||||
From = my_jid(Config),
|
||||
To = server_jid(Config),
|
||||
#iq{type = error} =
|
||||
send_recv(Config, #iq{type = get, from = From, to = To,
|
||||
sub_els = [#disco_info{}]}),
|
||||
disconnect(Config).
|
||||
send(Config, xmpp:set_from_to(Pkt, From, To)),
|
||||
#stream_error{reason = 'not-authorized'} = recv(Config),
|
||||
{xmlstreamend, <<"stream:stream">>} = recv(Config),
|
||||
close_socket(Config).
|
||||
|
||||
bad_nonza(Config) ->
|
||||
%% Unsupported and invalid nonza should be silently dropped.
|
||||
@ -706,18 +708,27 @@ invalid_from(Config) ->
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config).
|
||||
|
||||
test_missing_address(Config) ->
|
||||
test_missing_from(Config) ->
|
||||
Server = server_jid(Config),
|
||||
#iq{type = error} = send_recv(Config, #iq{type = get, from = Server}),
|
||||
#iq{type = error} = send_recv(Config, #iq{type = get, to = Server}),
|
||||
disconnect(Config).
|
||||
send(Config, #message{to = Server}),
|
||||
?recv1(#stream_error{reason = 'improper-addressing'}),
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config).
|
||||
|
||||
test_missing_to(Config) ->
|
||||
Server = server_jid(Config),
|
||||
send(Config, #message{from = Server}),
|
||||
?recv1(#stream_error{reason = 'improper-addressing'}),
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config).
|
||||
|
||||
test_invalid_from(Config) ->
|
||||
From = jid:make(randoms:get_string()),
|
||||
To = jid:make(randoms:get_string()),
|
||||
#iq{type = error} =
|
||||
send_recv(Config, #iq{type = get, from = From, to = To}),
|
||||
disconnect(Config).
|
||||
send(Config, #message{from = From, to = To}),
|
||||
?recv1(#stream_error{reason = 'invalid-from'}),
|
||||
?recv1({xmlstreamend, <<"stream:stream">>}),
|
||||
close_socket(Config).
|
||||
|
||||
test_component_send(Config) ->
|
||||
To = jid:make(?COMMON_VHOST),
|
||||
@ -779,6 +790,10 @@ auth_plain(Config) ->
|
||||
{skipped, 'PLAIN_not_available'}
|
||||
end.
|
||||
|
||||
test_legacy_auth_feature(Config) ->
|
||||
true = ?config(legacy_auth, Config),
|
||||
disconnect(Config).
|
||||
|
||||
test_legacy_auth(Config) ->
|
||||
disconnect(auth_legacy(Config, _Digest = false)).
|
||||
|
||||
|
@ -51,6 +51,8 @@ host_config:
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -106,6 +108,8 @@ Welcome to this XMPP server."
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -166,6 +170,8 @@ Welcome to this XMPP server."
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -222,6 +228,8 @@ Welcome to this XMPP server."
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -279,6 +287,8 @@ Welcome to this XMPP server."
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -319,6 +329,8 @@ Welcome to this XMPP server."
|
||||
mod_disco: []
|
||||
mod_ping: []
|
||||
mod_proxy65: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_register:
|
||||
welcome_message:
|
||||
subject: "Welcome!"
|
||||
@ -450,6 +462,9 @@ modules:
|
||||
body: "Hi.
|
||||
Welcome to this XMPP server."
|
||||
mod_stats: []
|
||||
mod_s2s_dialback: []
|
||||
mod_legacy_auth: []
|
||||
mod_sm: []
|
||||
mod_time: []
|
||||
mod_version: []
|
||||
registration_timeout: infinity
|
||||
|
@ -235,6 +235,8 @@ process_stream_features(Config) ->
|
||||
set_opt(register, true, Acc);
|
||||
(#starttls{}, Acc) ->
|
||||
set_opt(starttls, true, Acc);
|
||||
(#legacy_auth_feature{}, Acc) ->
|
||||
set_opt(legacy_auth, true, Acc);
|
||||
(#compression{methods = Ms}, Acc) ->
|
||||
set_opt(compression, Ms, Acc);
|
||||
(_, Acc) ->
|
||||
@ -246,7 +248,7 @@ disconnect(Config) ->
|
||||
ct:comment("Disconnecting"),
|
||||
Socket = ?config(socket, Config),
|
||||
try
|
||||
ok = send_text(Config, ?STREAM_TRAILER)
|
||||
send_text(Config, ?STREAM_TRAILER)
|
||||
catch exit:normal ->
|
||||
ok
|
||||
end,
|
||||
@ -274,17 +276,17 @@ starttls(Config, ShouldFail) ->
|
||||
#starttls_failure{} ->
|
||||
ct:fail(starttls_failed);
|
||||
#starttls_proceed{} ->
|
||||
TLSSocket = ejabberd_socket:starttls(
|
||||
?config(socket, Config),
|
||||
[{certfile, ?config(certfile, Config)},
|
||||
connect]),
|
||||
{ok, TLSSocket} = ejabberd_socket:starttls(
|
||||
?config(socket, Config),
|
||||
[{certfile, ?config(certfile, Config)},
|
||||
connect]),
|
||||
set_opt(socket, TLSSocket, Config)
|
||||
end.
|
||||
|
||||
zlib(Config) ->
|
||||
send(Config, #compress{methods = [<<"zlib">>]}),
|
||||
receive #compressed{} -> ok end,
|
||||
ZlibSocket = ejabberd_socket:compress(?config(socket, Config)),
|
||||
{ok, ZlibSocket} = ejabberd_socket:compress(?config(socket, Config)),
|
||||
process_stream_features(init_stream(set_opt(socket, ZlibSocket, Config))).
|
||||
|
||||
auth(Config) ->
|
||||
|
Loading…
Reference in New Issue
Block a user