Don't call deprecated jid functions from the test suite

This commit is contained in:
Evgeniy Khramtsov 2017-03-07 18:11:28 +03:00
parent 8b29af629b
commit 0aa22e5149
10 changed files with 32 additions and 32 deletions

View File

@ -1025,7 +1025,7 @@ vcard_get(Config) ->
disconnect(Config). disconnect(Config).
ldap_shared_roster_get(Config) -> ldap_shared_roster_get(Config) ->
Item = #roster_item{jid = jid:from_string(<<"user2@ldap.localhost">>), name = <<"Test User 2">>, Item = #roster_item{jid = jid:decode(<<"user2@ldap.localhost">>), name = <<"Test User 2">>,
groups = [<<"group1">>], subscription = both}, groups = [<<"group1">>], subscription = both},
#iq{type = result, sub_els = [#roster_query{items = [Item]}]} = #iq{type = result, sub_els = [#roster_query{items = [Item]}]} =
send_recv(Config, #iq{type = get, sub_els = [#roster_query{}]}), send_recv(Config, #iq{type = get, sub_els = [#roster_query{}]}),

View File

@ -94,8 +94,8 @@ get_set_prefs(Config) ->
JID <- [undefined, server_jid(Config)], JID <- [undefined, server_jid(Config)],
NS <- ?VERSIONS, NS <- ?VERSIONS,
Default <- [always, never, roster], Default <- [always, never, roster],
Always <- [[], [jid:from_string(<<"foo@bar.baz">>)]], Always <- [[], [jid:decode(<<"foo@bar.baz">>)]],
Never <- [[], [jid:from_string(<<"baz@bar.foo">>)]]], Never <- [[], [jid:decode(<<"baz@bar.foo">>)]]],
lists:foreach( lists:foreach(
fun({To, Prefs}) -> fun({To, Prefs}) ->
NS = Prefs#mam_prefs.xmlns, NS = Prefs#mam_prefs.xmlns,
@ -477,7 +477,7 @@ query_with(Config, From, To, NS) ->
Range = lists:seq(1, 5), Range = lists:seq(1, 5),
lists:foreach( lists:foreach(
fun(JID) -> fun(JID) ->
ct:comment("Sending query with jid ~s", [jid:to_string(JID)]), ct:comment("Sending query with jid ~s", [jid:encode(JID)]),
Query = if NS == ?NS_MAM_TMP -> Query = if NS == ?NS_MAM_TMP ->
#mam_query{xmlns = NS, with = JID, id = QID}; #mam_query{xmlns = NS, with = JID, id = QID};
true -> true ->

View File

@ -191,14 +191,14 @@ service_disco_items(Config) ->
service_vcard(Config) -> service_vcard(Config) ->
MUC = muc_jid(Config), MUC = muc_jid(Config),
ct:comment("Retreiving vCard from ~s", [jid:to_string(MUC)]), ct:comment("Retreiving vCard from ~s", [jid:encode(MUC)]),
#iq{type = result, sub_els = [#vcard_temp{}]} = #iq{type = result, sub_els = [#vcard_temp{}]} =
send_recv(Config, #iq{type = get, to = MUC, sub_els = [#vcard_temp{}]}), send_recv(Config, #iq{type = get, to = MUC, sub_els = [#vcard_temp{}]}),
disconnect(Config). disconnect(Config).
service_unique(Config) -> service_unique(Config) ->
MUC = muc_jid(Config), MUC = muc_jid(Config),
ct:comment("Requesting muc unique from ~s", [jid:to_string(MUC)]), ct:comment("Requesting muc unique from ~s", [jid:encode(MUC)]),
#iq{type = result, sub_els = [#muc_unique{name = Name}]} = #iq{type = result, sub_els = [#muc_unique{name = Name}]} =
send_recv(Config, #iq{type = get, to = MUC, sub_els = [#muc_unique{}]}), send_recv(Config, #iq{type = get, to = MUC, sub_els = [#muc_unique{}]}),
ct:comment("Checking if unique name is set in the response"), ct:comment("Checking if unique name is set in the response"),
@ -1711,7 +1711,7 @@ destroy(Config, Reason) ->
disco_items(Config) -> disco_items(Config) ->
MUC = muc_jid(Config), MUC = muc_jid(Config),
ct:comment("Performing disco#items request to ~s", [jid:to_string(MUC)]), ct:comment("Performing disco#items request to ~s", [jid:encode(MUC)]),
#iq{type = result, from = MUC, sub_els = [DiscoItems]} = #iq{type = result, from = MUC, sub_els = [DiscoItems]} =
send_recv(Config, #iq{type = get, to = MUC, send_recv(Config, #iq{type = get, to = MUC,
sub_els = [#disco_items{}]}), sub_els = [#disco_items{}]}),
@ -1819,7 +1819,7 @@ get_affiliation(Config, Aff) ->
set_vcard(Config, VCard) -> set_vcard(Config, VCard) ->
Room = muc_room_jid(Config), Room = muc_room_jid(Config),
ct:comment("Setting vCard for ~s", [jid:to_string(Room)]), ct:comment("Setting vCard for ~s", [jid:encode(Room)]),
case send_recv(Config, #iq{type = set, to = Room, case send_recv(Config, #iq{type = set, to = Room,
sub_els = [VCard]}) of sub_els = [VCard]}) of
#iq{type = result, sub_els = []} -> #iq{type = result, sub_els = []} ->
@ -1830,7 +1830,7 @@ set_vcard(Config, VCard) ->
get_vcard(Config) -> get_vcard(Config) ->
Room = muc_room_jid(Config), Room = muc_room_jid(Config),
ct:comment("Retreiving vCard from ~s", [jid:to_string(Room)]), ct:comment("Retreiving vCard from ~s", [jid:encode(Room)]),
case send_recv(Config, #iq{type = get, to = Room, case send_recv(Config, #iq{type = get, to = Room,
sub_els = [#vcard_temp{}]}) of sub_els = [#vcard_temp{}]}) of
#iq{type = result, sub_els = [VCard]} -> #iq{type = result, sub_els = [VCard]} ->

View File

@ -295,7 +295,7 @@ get_nodes(Config) ->
MyJID = my_jid(Config), MyJID = my_jid(Config),
MyBareJID = jid:remove_resource(MyJID), MyBareJID = jid:remove_resource(MyJID),
Peer = ?config(peer, Config), Peer = ?config(peer, Config),
Peer_s = jid:to_string(Peer), Peer_s = jid:encode(Peer),
ct:comment("Getting headers"), ct:comment("Getting headers"),
#iq{type = result, #iq{type = result,
sub_els = [#disco_items{ sub_els = [#disco_items{

View File

@ -266,14 +266,14 @@ master_slave_cases() ->
deny_bare_jid_master(Config) -> deny_bare_jid_master(Config) ->
PeerJID = ?config(peer, Config), PeerJID = ?config(peer, Config),
PeerBareJID = jid:remove_resource(PeerJID), PeerBareJID = jid:remove_resource(PeerJID),
deny_master(Config, {jid, jid:to_string(PeerBareJID)}). deny_master(Config, {jid, jid:encode(PeerBareJID)}).
deny_bare_jid_slave(Config) -> deny_bare_jid_slave(Config) ->
deny_slave(Config). deny_slave(Config).
deny_full_jid_master(Config) -> deny_full_jid_master(Config) ->
PeerJID = ?config(peer, Config), PeerJID = ?config(peer, Config),
deny_master(Config, {jid, jid:to_string(PeerJID)}). deny_master(Config, {jid, jid:encode(PeerJID)}).
deny_full_jid_slave(Config) -> deny_full_jid_slave(Config) ->
deny_slave(Config). deny_slave(Config).
@ -781,7 +781,7 @@ server_send_iqs(Config) ->
ServerJID = server_jid(Config), ServerJID = server_jid(Config),
MyJID = my_jid(Config), MyJID = my_jid(Config),
ct:comment("Sending IQs from ~s to ~s", ct:comment("Sending IQs from ~s to ~s",
[jid:to_string(ServerJID), jid:to_string(MyJID)]), [jid:encode(ServerJID), jid:encode(MyJID)]),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
ejabberd_router:route( ejabberd_router:route(
@ -798,7 +798,7 @@ server_send_iqs(Config) ->
server_recv_iqs(Config) -> server_recv_iqs(Config) ->
ServerJID = server_jid(Config), ServerJID = server_jid(Config),
ct:comment("Receiving IQs from ~s", [jid:to_string(ServerJID)]), ct:comment("Receiving IQs from ~s", [jid:encode(ServerJID)]),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
#iq{type = Type, from = ServerJID} = recv_iq(Config) #iq{type = Type, from = ServerJID} = recv_iq(Config)
@ -814,21 +814,21 @@ send_stanzas_to_server_resource(Config) ->
ServerJIDResource = jid:replace_resource(ServerJID, <<"resource">>), ServerJIDResource = jid:replace_resource(ServerJID, <<"resource">>),
%% All stanzas sent should be handled by local_send_to_resource_hook %% All stanzas sent should be handled by local_send_to_resource_hook
%% and should be bounced with item-not-found error %% and should be bounced with item-not-found error
ct:comment("Sending IQs to ~s", [jid:to_string(ServerJIDResource)]), ct:comment("Sending IQs to ~s", [jid:encode(ServerJIDResource)]),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
#iq{type = error} = Err = #iq{type = error} = Err =
send_recv(Config, #iq{type = Type, to = ServerJIDResource}), send_recv(Config, #iq{type = Type, to = ServerJIDResource}),
#stanza_error{reason = 'item-not-found'} = xmpp:get_error(Err) #stanza_error{reason = 'item-not-found'} = xmpp:get_error(Err)
end, [set, get]), end, [set, get]),
ct:comment("Sending messages to ~s", [jid:to_string(ServerJIDResource)]), ct:comment("Sending messages to ~s", [jid:encode(ServerJIDResource)]),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
#message{type = error} = Err = #message{type = error} = Err =
send_recv(Config, #message{type = Type, to = ServerJIDResource}), send_recv(Config, #message{type = Type, to = ServerJIDResource}),
#stanza_error{reason = 'item-not-found'} = xmpp:get_error(Err) #stanza_error{reason = 'item-not-found'} = xmpp:get_error(Err)
end, [normal, chat, groupchat, headline]), end, [normal, chat, groupchat, headline]),
ct:comment("Sending presences to ~s", [jid:to_string(ServerJIDResource)]), ct:comment("Sending presences to ~s", [jid:encode(ServerJIDResource)]),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
#presence{type = error} = Err = #presence{type = error} = Err =

View File

@ -48,7 +48,7 @@ feature_enabled(Config) ->
service_vcard(Config) -> service_vcard(Config) ->
JID = proxy_jid(Config), JID = proxy_jid(Config),
ct:comment("Retreiving vCard from ~s", [jid:to_string(JID)]), ct:comment("Retreiving vCard from ~s", [jid:encode(JID)]),
#iq{type = result, sub_els = [#vcard_temp{}]} = #iq{type = result, sub_els = [#vcard_temp{}]} =
send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}), send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}),
disconnect(Config). disconnect(Config).
@ -106,7 +106,7 @@ master_slave_test(T) ->
socks5_connect(#streamhost{host = Host, port = Port}, socks5_connect(#streamhost{host = Host, port = Port},
{SID, JID1, JID2}) -> {SID, JID1, JID2}) ->
Hash = p1_sha:sha([SID, jid:to_string(JID1), jid:to_string(JID2)]), Hash = p1_sha:sha([SID, jid:encode(JID1), jid:encode(JID2)]),
{ok, Sock} = gen_tcp:connect(binary_to_list(Host), Port, {ok, Sock} = gen_tcp:connect(binary_to_list(Host), Port,
[binary, {active, false}]), [binary, {active, false}]),
Init = <<?VERSION_5, 1, ?AUTH_ANONYMOUS>>, Init = <<?VERSION_5, 1, ?AUTH_ANONYMOUS>>,

View File

@ -85,7 +85,7 @@ test_features(Config) ->
test_vcard(Config) -> test_vcard(Config) ->
JID = pubsub_jid(Config), JID = pubsub_jid(Config),
ct:comment("Retreiving vCard from ~s", [jid:to_string(JID)]), ct:comment("Retreiving vCard from ~s", [jid:encode(JID)]),
#iq{type = result, sub_els = [#vcard_temp{}]} = #iq{type = result, sub_els = [#vcard_temp{}]} =
send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}), send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}),
disconnect(Config). disconnect(Config).

View File

@ -66,7 +66,7 @@ feature_enabled(Config) ->
disconnect(Config). disconnect(Config).
set_item(Config) -> set_item(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
Item = #roster_item{jid = JID}, Item = #roster_item{jid = JID},
{V1, Item} = set_items(Config, [Item]), {V1, Item} = set_items(Config, [Item]),
{V1, [Item]} = get_items(Config), {V1, [Item]} = get_items(Config),
@ -84,15 +84,15 @@ set_item(Config) ->
del_roster(disconnect(Config), JID). del_roster(disconnect(Config), JID).
iq_set_many_items(Config) -> iq_set_many_items(Config) ->
J1 = jid:from_string(<<"nurse1@example.com">>), J1 = jid:decode(<<"nurse1@example.com">>),
J2 = jid:from_string(<<"nurse2@example.com">>), J2 = jid:decode(<<"nurse2@example.com">>),
ct:comment("Trying to send roster-set with many <item/> elements"), ct:comment("Trying to send roster-set with many <item/> elements"),
Items = [#roster_item{jid = J1}, #roster_item{jid = J2}], Items = [#roster_item{jid = J1}, #roster_item{jid = J2}],
#stanza_error{reason = 'bad-request'} = set_items(Config, Items), #stanza_error{reason = 'bad-request'} = set_items(Config, Items),
disconnect(Config). disconnect(Config).
iq_set_duplicated_groups(Config) -> iq_set_duplicated_groups(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
G = randoms:get_string(), G = randoms:get_string(),
ct:comment("Trying to send roster-set with duplicated groups"), ct:comment("Trying to send roster-set with duplicated groups"),
Item = #roster_item{jid = JID, groups = [G, G]}, Item = #roster_item{jid = JID, groups = [G, G]},
@ -100,14 +100,14 @@ iq_set_duplicated_groups(Config) ->
disconnect(Config). disconnect(Config).
iq_set_ask(Config) -> iq_set_ask(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
ct:comment("Trying to send roster-set with 'ask' included"), ct:comment("Trying to send roster-set with 'ask' included"),
Item = #roster_item{jid = JID, ask = subscribe}, Item = #roster_item{jid = JID, ask = subscribe},
#stanza_error{reason = 'bad-request'} = set_items(Config, [Item]), #stanza_error{reason = 'bad-request'} = set_items(Config, [Item]),
disconnect(Config). disconnect(Config).
iq_get_item(Config) -> iq_get_item(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
ct:comment("Trying to send roster-get with <item/> element"), ct:comment("Trying to send roster-get with <item/> element"),
#iq{type = error} = Err3 = #iq{type = error} = Err3 =
send_recv(Config, #iq{type = get, send_recv(Config, #iq{type = get,
@ -117,7 +117,7 @@ iq_get_item(Config) ->
disconnect(Config). disconnect(Config).
iq_unexpected_element(Config) -> iq_unexpected_element(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
ct:comment("Trying to send IQs with unexpected element"), ct:comment("Trying to send IQs with unexpected element"),
lists:foreach( lists:foreach(
fun(Type) -> fun(Type) ->
@ -129,7 +129,7 @@ iq_unexpected_element(Config) ->
disconnect(Config). disconnect(Config).
version(Config) -> version(Config) ->
JID = jid:from_string(<<"nurse@example.com">>), JID = jid:decode(<<"nurse@example.com">>),
ct:comment("Requesting roster"), ct:comment("Requesting roster"),
{InitialVersion, _} = get_items(Config, <<"">>), {InitialVersion, _} = get_items(Config, <<"">>),
ct:comment("Requesting roster with initial version"), ct:comment("Requesting roster with initial version"),

View File

@ -689,7 +689,7 @@ get_features(Config) ->
get_features(Config, server_jid(Config)). get_features(Config, server_jid(Config)).
get_features(Config, To) -> get_features(Config, To) ->
ct:comment("Getting features of ~s", [jid:to_string(To)]), ct:comment("Getting features of ~s", [jid:encode(To)]),
#iq{type = result, sub_els = [#disco_info{features = Features}]} = #iq{type = result, sub_els = [#disco_info{features = Features}]} =
send_recv(Config, #iq{type = get, sub_els = [#disco_info{}], to = To}), send_recv(Config, #iq{type = get, sub_els = [#disco_info{}], to = To}),
Features. Features.
@ -738,7 +738,7 @@ set_roster(Config, Subscription, Groups) ->
PeerBareJID = jid:remove_resource(PeerJID), PeerBareJID = jid:remove_resource(PeerJID),
PeerLJID = jid:tolower(PeerBareJID), PeerLJID = jid:tolower(PeerBareJID),
ct:comment("Adding ~s to roster with subscription '~s' in groups ~p", ct:comment("Adding ~s to roster with subscription '~s' in groups ~p",
[jid:to_string(PeerBareJID), Subscription, Groups]), [jid:encode(PeerBareJID), Subscription, Groups]),
{atomic, _} = mod_roster:set_roster(#roster{usj = {U, S, PeerLJID}, {atomic, _} = mod_roster:set_roster(#roster{usj = {U, S, PeerLJID},
us = {U, S}, us = {U, S},
jid = PeerLJID, jid = PeerLJID,
@ -754,7 +754,7 @@ del_roster(Config, PeerJID) ->
{U, S, _} = jid:tolower(MyJID), {U, S, _} = jid:tolower(MyJID),
PeerBareJID = jid:remove_resource(PeerJID), PeerBareJID = jid:remove_resource(PeerJID),
PeerLJID = jid:tolower(PeerBareJID), PeerLJID = jid:tolower(PeerBareJID),
ct:comment("Removing ~s from roster", [jid:to_string(PeerBareJID)]), ct:comment("Removing ~s from roster", [jid:encode(PeerBareJID)]),
{atomic, _} = mod_roster:del_roster(U, S, PeerLJID), {atomic, _} = mod_roster:del_roster(U, S, PeerLJID),
Config. Config.

View File

@ -90,7 +90,7 @@ get_set(Config) ->
service_vcard(Config) -> service_vcard(Config) ->
JID = server_jid(Config), JID = server_jid(Config),
ct:comment("Retreiving vCard from ~s", [jid:to_string(JID)]), ct:comment("Retreiving vCard from ~s", [jid:encode(JID)]),
#iq{type = result, sub_els = [#vcard_temp{}]} = #iq{type = result, sub_els = [#vcard_temp{}]} =
send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}), send_recv(Config, #iq{type = get, to = JID, sub_els = [#vcard_temp{}]}),
disconnect(Config). disconnect(Config).