-type version() :: #version{}.
-record(bind, {jid :: jid:jid(),
- resource :: binary()}).
+ resource = <<>> :: binary()}).
-type bind() :: #bind{}.
-record(rosterver_feature, {}).
wait_for_bind(Pkt, StateData) when ?IS_STREAM_MGMT_PACKET(Pkt) ->
fsm_next_state(wait_for_bind, dispatch_stream_mgmt(Pkt, StateData));
wait_for_bind(#iq{type = set,
- sub_els = [#bind{resource = R}]} = IQ, StateData) ->
+ sub_els = [#bind{resource = R0}]} = IQ, StateData) ->
U = StateData#state.user,
+ R = case R0 of
+ <<>> -> new_uniq_id();
+ _ -> R0
+ end,
case resource_conflict_action(U, StateData#state.server, R) of
closenew ->
Err = xmpp:make_error(IQ, xmpp:err_conflict()),
decode_bind(__TopXMLNS, __IgnoreEls,
{xmlel, <<"bind">>, _attrs, _els}) ->
{Jid, Resource} = decode_bind_els(__TopXMLNS,
- __IgnoreEls, _els, undefined, undefined),
+ __IgnoreEls, _els, undefined, <<>>),
{bind, Jid, Resource}.
decode_bind_els(__TopXMLNS, __IgnoreEls, [], Jid,
'encode_bind_$jid'(Jid, __TopXMLNS, _acc) ->
[encode_bind_jid(Jid, __TopXMLNS) | _acc].
-'encode_bind_$resource'(undefined, __TopXMLNS, _acc) ->
- _acc;
+'encode_bind_$resource'(<<>>, __TopXMLNS, _acc) -> _acc;
'encode_bind_$resource'(Resource, __TopXMLNS, _acc) ->
[encode_bind_resource(Resource, __TopXMLNS) | _acc].
set_opt(server_port, Port,
set_opt(stream_version, undefined,
set_opt(lang, <<"">>, Config))))));
-do_init_per_group(_GroupName, Config) ->
+do_init_per_group(GroupName, Config) ->
Pid = start_event_relay(),
- set_opt(event_relay, Pid, Config).
+ NewConfig = set_opt(event_relay, Pid, Config),
+ case GroupName of
+ anonymous -> set_opt(anonymous, true, NewConfig);
+ _ -> NewConfig
+ end.
end_per_group(mnesia, _Config) ->
ok;
ejabberd_config:add_option(s2s_use_starttls, false);
end_per_group(_GroupName, Config) ->
stop_event_relay(Config),
- ok.
+ set_opt(anonymous, false, Config).
init_per_testcase(stop_ejabberd, Config) ->
open_session(bind(auth(connect(Config))));
name, ?config(tc_group_properties, OrigConfig)),
Server = ?config(server, OrigConfig),
Resource = case TestGroup of
- generic ->
- randoms:get_string();
+ anonymous ->
+ <<"">>;
legacy_auth ->
randoms:get_string();
_ ->
test_legacy_auth_fail]}.
no_db_tests() ->
- [{generic, [parallel],
+ [{anonymous, [parallel],
[test_connect_bad_xml,
test_connect_unexpected_xml,
test_connect_unknown_ns,
test_starttls,
test_zlib,
test_auth,
- test_auth_fail,
test_bind,
test_open_session,
codec_failure,
stats,
disco]},
{presence_and_s2s, [sequence],
- [presence,
+ [test_auth_fail,
+ presence,
s2s_dialback,
s2s_optional,
s2s_required,
{riak, [sequence], db_tests(riak)}].
all() ->
- [{group, ldap},
+ [%%{group, ldap},
{group, no_db},
- {group, mnesia},
- {group, redis},
- {group, mysql},
- {group, pgsql},
- {group, sqlite},
- {group, extauth},
- {group, riak},
- {group, component},
- {group, s2s},
+ %% {group, mnesia},
+ %% {group, redis},
+ %% {group, mysql},
+ %% {group, pgsql},
+ %% {group, sqlite},
+ %% {group, extauth},
+ %% {group, riak},
+ %% {group, component},
+ %% {group, s2s},
stop_ejabberd].
stop_ejabberd(Config) ->
mod_time: []
mod_version: []
"localhost":
- auth_method: internal
+ auth_method: [internal, anonymous]
"ldap.localhost":
ldap_servers:
- "localhost"
{slave_nick, <<"slave_nick!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>},
{room_subject, <<"hello, world!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>},
{certfile, CertFile},
+ {anonymous, false},
{type, client},
{xmlns, ?NS_CLIENT},
{ns_stream, ?NS_STREAM},
auth(Config, ShouldFail) ->
Type = ?config(type, Config),
+ IsAnonymous = ?config(anonymous, Config),
Mechs = ?config(mechs, Config),
HaveMD5 = lists:member(<<"DIGEST-MD5">>, Mechs),
HavePLAIN = lists:member(<<"PLAIN">>, Mechs),
HaveExternal = lists:member(<<"EXTERNAL">>, Mechs),
- if HavePLAIN ->
+ HaveAnonymous = lists:member(<<"ANONYMOUS">>, Mechs),
+ if HaveAnonymous and IsAnonymous ->
+ auth_SASL(<<"ANONYMOUS">>, Config, ShouldFail);
+ HavePLAIN ->
auth_SASL(<<"PLAIN">>, Config, ShouldFail);
HaveMD5 ->
auth_SASL(<<"DIGEST-MD5">>, Config, ShouldFail);
end.
bind(Config) ->
+ U = ?config(user, Config),
+ S = ?config(server, Config),
+ R = ?config(resource, Config),
case ?config(type, Config) of
client ->
- #iq{type = result, sub_els = [#bind{}]} =
+ #iq{type = result, sub_els = [#bind{jid = JID}]} =
send_recv(
- Config,
- #iq{type = set,
- sub_els = [#bind{resource = ?config(resource, Config)}]});
+ Config, #iq{type = set, sub_els = [#bind{resource = R}]}),
+ case ?config(anonymous, Config) of
+ false ->
+ {U, S, R} = jid:tolower(JID),
+ Config;
+ true ->
+ {User, S, Resource} = jid:tolower(JID),
+ set_opt(user, User, set_opt(resource, Resource, Config))
+ end;
component ->
- ok
- end,
- Config.
+ Config
+ end.
open_session(Config) ->
open_session(Config, false).
sasl_new(<<"EXTERNAL">>, _User, _Server, _Password) ->
{<<"">>,
fun(_) -> ct:fail(sasl_challenge_is_not_expected) end};
+sasl_new(<<"ANONYMOUS">>, _User, _Server, _Password) ->
+ {<<"">>,
+ fun(_) -> ct:fail(sasl_challenge_is_not_expected) end};
sasl_new(<<"DIGEST-MD5">>, User, Server, Password) ->
{<<"">>,
fun (ServerIn) ->
min = 0, max = 1},
#ref{name = bind_resource,
min = 0, max = 1,
+ default = <<"">>,
label = '$resource'}]}).
-xml(legacy_auth_username,