Skip to content

Commit

Permalink
Fix using proper jid records from mongoose_jid instead of from escalus
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Dec 22, 2023
1 parent 1920633 commit 309fb47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions big_tests/tests/anonymous_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
-module(anonymous_SUITE).
-compile([export_all, nowarn_export_all]).

-include_lib("jid/include/jid.hrl").
-include_lib("escalus/include/escalus.hrl").
-include_lib("eunit/include/eunit.hrl").

Expand Down Expand Up @@ -67,7 +68,7 @@ connection_is_registered_with_sasl_anon(Config) ->
escalus:story(Config, [{jon, 1}], fun(Jon) ->
JID = jid:from_binary(escalus_client:short_jid(Jon)),
OrigName = escalus_users:get_username(Config, jon),
?assertNotEqual(OrigName, JID#jid.user),
?assertNotEqual(OrigName, JID#jid.luser),
F = fun() -> rpc(mim(), ejabberd_auth, does_user_exist, [JID]) end,
true = F(),
escalus_connection:kill(Jon),
Expand All @@ -78,7 +79,7 @@ connection_is_registered_with_login(Config) ->
escalus:story(Config, [{anna, 1}], fun(Anna) ->
JID = jid:from_binary(escalus_client:short_jid(Anna)),
OrigName = escalus_users:get_username(Config, anna),
?assertEqual(OrigName, JID#jid.user),
?assertEqual(OrigName, JID#jid.luser),
F = fun() -> rpc(mim(), ejabberd_auth, does_user_exist, [JID]) end,
true = F(),
escalus_connection:kill(Anna),
Expand Down
11 changes: 6 additions & 5 deletions big_tests/tests/bind2_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-include_lib("stdlib/include/assert.hrl").
-include_lib("exml/include/exml.hrl").
-include_lib("jid/include/jid.hrl").
-include_lib("escalus/include/escalus.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").

Expand Down Expand Up @@ -100,7 +101,7 @@ auth_and_bind_to_random_resource(Config) ->
Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]),
?assertNotEqual(undefined, Bound),
Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]),
#jid{resource = LResource} = jid:from_binary(Identifier),
#jid{lresource = LResource} = jid:from_binary(Identifier),
?assert(0 =< byte_size(LResource), LResource).

auth_and_bind_do_not_expose_user_agent_id_in_client(Config) ->
Expand All @@ -110,7 +111,7 @@ auth_and_bind_do_not_expose_user_agent_id_in_client(Config) ->
Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]),
?assertNotEqual(undefined, Bound),
Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]),
#jid{resource = LResource} = jid:from_binary(Identifier),
#jid{lresource = LResource} = jid:from_binary(Identifier),
?assertNotEqual(Uuid, LResource).

auth_and_bind_contains_client_tag(Config) ->
Expand All @@ -120,7 +121,7 @@ auth_and_bind_contains_client_tag(Config) ->
Bound = exml_query:path(Success, [{element_with_ns, <<"bound">>, ?NS_BIND_2}]),
?assertNotEqual(undefined, Bound),
Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]),
#jid{resource = LResource} = jid:from_binary(Identifier),
#jid{lresource = LResource} = jid:from_binary(Identifier),
ResourceParts = binary:split(LResource, <<"/">>, [global]),
?assertMatch([Tag, _], ResourceParts).

Expand Down Expand Up @@ -180,7 +181,7 @@ stream_resumption_failing_does_bind_and_contains_sm_status(Config) ->
Resumed = exml_query:path(Success, [{element_with_ns, <<"failed">>, ?NS_STREAM_MGNT_3}]),
escalus:assert(is_sm_failed, [<<"item-not-found">>], Resumed),
Identifier = exml_query:path(Success, [{element, <<"authorization-identifier">>}, cdata]),
#jid{resource = LResource} = jid:from_binary(Identifier),
#jid{lresource = LResource} = jid:from_binary(Identifier),
ResourceParts = binary:split(LResource, <<"/">>, [global]),
?assertMatch([Tag, _], ResourceParts).

Expand Down Expand Up @@ -286,7 +287,7 @@ plain_auth(_Config, Client, Data, BindElems, Extra) ->
escalus:send(Client, Authenticate),
Answer = escalus_client:wait_for_stanza(Client),
Identifier = exml_query:path(Answer, [{element, <<"authorization-identifier">>}, cdata]),
#jid{resource = LResource} = jid:from_binary(Identifier),
#jid{lresource = LResource} = jid:from_binary(Identifier),
{Client, Data#{answer => Answer, client_1_jid => Identifier, bind2_resource => LResource}}.

start_peer(Config, Client, Data) ->
Expand Down

0 comments on commit 309fb47

Please sign in to comment.