Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xeps/bind2 inlines #4114

Merged
merged 16 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions big_tests/tests/sasl2_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ groups() ->
{basic, [parallel],
[
server_does_not_announce_if_not_tls,
server_announces_sasl2_with_some_mechanism,
server_announces_sasl2_with_some_mechanism_and_inline_sm,
authenticate_stanza_has_invalid_mechanism,
user_agent_is_invalid,
user_agent_is_invalid_uuid_but_not_v4,
Expand Down Expand Up @@ -101,13 +101,16 @@ server_does_not_announce_if_not_tls(Config) ->
Sasl2 = exml_query:path(Features, [{element_with_ns, <<"authentication">>, ?NS_SASL_2}]),
?assertEqual(undefined, Sasl2).

server_announces_sasl2_with_some_mechanism(Config) ->
server_announces_sasl2_with_some_mechanism_and_inline_sm(Config) ->
Steps = [create_connect_tls, start_stream_get_features],
#{features := Features} = sasl2_helper:apply_steps(Steps, Config),
Sasl2 = exml_query:path(Features, [{element_with_ns, <<"authentication">>, ?NS_SASL_2}]),
?assertNotEqual(undefined, Sasl2),
Mechs = exml_query:paths(Sasl2, [{element, <<"mechanism">>}]),
?assertNotEqual([], Mechs).
?assertNotEqual([], Mechs),
Sm = exml_query:path(Sasl2, [{element, <<"inline">>},
{element_with_ns, <<"sm">>, ?NS_STREAM_MGNT_3}]),
?assertNotEqual(undefined, Sm).

authenticate_stanza_has_invalid_mechanism(Config) ->
Steps = [start_new_user, send_invalid_mech_auth_stanza],
Expand Down
2 changes: 1 addition & 1 deletion src/stream_management/mod_stream_management_sasl2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-spec sasl2_stream_features(Acc, #{c2s_data := mongoose_c2s:data()}, gen_hook:extra()) ->
{ok, Acc} when Acc :: [exml:element()].
sasl2_stream_features(Acc, _, _) ->
Resume = #xmlel{name = <<"resume">>, attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3}]},
Resume = #xmlel{name = <<"sm">>, attrs = [{<<"xmlns">>, ?NS_STREAM_MGNT_3}]},
chrzaszcz marked this conversation as resolved.
Show resolved Hide resolved
{ok, [Resume | Acc]}.

-spec sasl2_start(SaslAcc, #{stanza := exml:element()}, gen_hook:extra()) ->
Expand Down Expand Up @@ -98,7 +98,7 @@
handle_bind_enable(SaslAcc, #{c2s_data := C2SData}, Inline, El) ->
case mod_stream_management:if_not_already_enabled_create_sm_state(C2SData) of
error ->
mod_stream_management:stream_error(SaslAcc, C2SData);

Check warning on line 101 in src/stream_management/mod_stream_management_sasl2.erl

View check run for this annotation

Codecov / codecov/patch

src/stream_management/mod_stream_management_sasl2.erl#L101

Added line #L101 was not covered by tests
SmState ->
do_handle_bind_enable(SaslAcc, C2SData, SmState, Inline, El)
end.
Expand All @@ -118,5 +118,5 @@
SaslAcc2 = mod_bind2:append_inline_bound_answer(SaslAcc1, Inline, Stanza),
{ok, SaslAcc2};
_ ->
mod_stream_management:stream_error(SaslAcc, C2SData)

Check warning on line 121 in src/stream_management/mod_stream_management_sasl2.erl

View check run for this annotation

Codecov / codecov/patch

src/stream_management/mod_stream_management_sasl2.erl#L121

Added line #L121 was not covered by tests
end.
Loading