25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

Use p1_rand in the test suite

This commit is contained in:
Evgeniy Khramtsov 2018-07-05 11:53:04 +03:00
parent ed1ee6061e
commit 59f5a098b5
12 changed files with 61 additions and 61 deletions

View File

@ -135,7 +135,7 @@ prepare_slave(Config) ->
send_messages(Config) ->
Server = ?config(server, Config),
MyJID = my_jid(Config),
JID = jid:make(randoms:get_string(), Server),
JID = jid:make(p1_rand:get_string(), Server),
lists:foreach(
fun({send, #message{type = Type} = Msg}) ->
I = send(Config, Msg#message{to = JID}),

View File

@ -57,7 +57,7 @@ init_per_suite(Config) ->
inet_db:add_host({127,0,0,1}, [binary_to_list(?S2S_VHOST),
binary_to_list(?MNESIA_VHOST),
binary_to_list(?UPLOAD_VHOST)]),
inet_db:set_domain(binary_to_list(randoms:get_string())),
inet_db:set_domain(binary_to_list(p1_rand:get_string())),
inet_db:set_lookup([file, native]),
start_ejabberd(NewConfig),
NewConfig.
@ -227,7 +227,7 @@ init_per_testcase(TestCase, OrigConfig) ->
anonymous ->
<<"">>;
legacy_auth ->
randoms:get_string();
p1_rand:get_string();
_ ->
?config(resource, OrigConfig)
end,
@ -718,7 +718,7 @@ bad_nonza(Config) ->
disconnect(Config).
invalid_from(Config) ->
send(Config, #message{from = jid:make(randoms:get_string())}),
send(Config, #message{from = jid:make(p1_rand:get_string())}),
?recv1(#stream_error{reason = 'invalid-from'}),
?recv1({xmlstreamend, <<"stream:stream">>}),
close_socket(Config).
@ -738,8 +738,8 @@ test_missing_to(Config) ->
close_socket(Config).
test_invalid_from(Config) ->
From = jid:make(randoms:get_string()),
To = jid:make(randoms:get_string()),
From = jid:make(p1_rand:get_string()),
To = jid:make(p1_rand:get_string()),
send(Config, #message{from = From, to = To}),
?recv1(#stream_error{reason = 'invalid-from'}),
?recv1({xmlstreamend, <<"stream:stream">>}),
@ -780,7 +780,7 @@ s2s_required_trusted(Config) ->
s2s_ping(Config) ->
From = my_jid(Config),
To = jid:make(?MNESIA_VHOST),
ID = randoms:get_string(),
ID = p1_rand:get_string(),
ejabberd_s2s:route(#iq{from = From, to = To, id = ID,
type = get, sub_els = [#ping{}]}),
#iq{type = result, id = ID, sub_els = []} = recv_iq(Config),
@ -901,7 +901,7 @@ presence(Config) ->
disconnect(Config).
presence_broadcast(Config) ->
Feature = <<"p1:tmp:", (randoms:get_string())/binary>>,
Feature = <<"p1:tmp:", (p1_rand:get_string())/binary>>,
Ver = crypto:hash(sha, ["client", $/, "bot", $/, "en", $/,
"ejabberd_ct", $<, Feature, $<]),
B64Ver = base64:encode(Ver),

View File

@ -63,18 +63,18 @@ feature_enabled(Config) ->
fake_by(Config) ->
BareServerJID = server_jid(Config),
FullServerJID = jid:replace_resource(BareServerJID, randoms:get_string()),
FullServerJID = jid:replace_resource(BareServerJID, p1_rand:get_string()),
FullMyJID = my_jid(Config),
BareMyJID = jid:remove_resource(FullMyJID),
Fakes = lists:flatmap(
fun(JID) ->
[#mam_archived{id = randoms:get_string(), by = JID},
#stanza_id{id = randoms:get_string(), by = JID}]
[#mam_archived{id = p1_rand:get_string(), by = JID},
#stanza_id{id = p1_rand:get_string(), by = JID}]
end, [BareServerJID, FullServerJID, BareMyJID, FullMyJID]),
Body = xmpp:mk_text(<<"body">>),
ForeignJID = jid:make(randoms:get_string()),
Archived = #mam_archived{id = randoms:get_string(), by = ForeignJID},
StanzaID = #stanza_id{id = randoms:get_string(), by = ForeignJID},
ForeignJID = jid:make(p1_rand:get_string()),
Archived = #mam_archived{id = p1_rand:get_string(), by = ForeignJID},
StanzaID = #stanza_id{id = p1_rand:get_string(), by = ForeignJID},
#message{body = Body, sub_els = SubEls} =
send_recv(Config, #message{to = FullMyJID,
body = Body,
@ -416,7 +416,7 @@ recv_messages_from_room(Config, Range) ->
Room = muc_room_jid(Config),
MyNickJID = jid:replace_resource(Room, MyNick),
MyJID = my_jid(Config),
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Count = length(Range),
I = send(Config, #iq{type = set, to = Room,
sub_els = [#mam_query{xmlns = ?NS_MAM_2, id = QID}]}),
@ -450,7 +450,7 @@ query_all(Config, From, To) ->
end, ?VERSIONS).
query_all(Config, From, To, NS) ->
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Range = lists:seq(1, 5),
ID = send_query(Config, #mam_query{xmlns = NS, id = QID}),
recv_archived_messages(Config, From, To, QID, Range),
@ -465,7 +465,7 @@ query_with(Config, From, To) ->
query_with(Config, From, To, NS) ->
Peer = ?config(peer, Config),
BarePeer = jid:remove_resource(Peer),
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Range = lists:seq(1, 5),
lists:foreach(
fun(JID) ->
@ -492,7 +492,7 @@ query_rsm_max(Config, From, To) ->
query_rsm_max(Config, From, To, NS) ->
lists:foreach(
fun(Max) ->
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Range = lists:sublist(lists:seq(1, Max), 5),
Query = #mam_query{xmlns = NS, id = QID, rsm = #rsm_set{max = Max}},
ID = send_query(Config, Query),
@ -512,7 +512,7 @@ query_rsm_after(Config, From, To, NS) ->
fun(Range, #rsm_first{data = After}) ->
ct:comment("Retrieving ~p messages after '~s'",
[length(Range), After]),
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Query = #mam_query{xmlns = NS, id = QID,
rsm = #rsm_set{'after' = After}},
ID = send_query(Config, Query),
@ -534,7 +534,7 @@ query_rsm_before(Config, From, To, NS) ->
fun(Range, Before) ->
ct:comment("Retrieving ~p messages before '~s'",
[length(Range), Before]),
QID = randoms:get_string(),
QID = p1_rand:get_string(),
Query = #mam_query{xmlns = NS, id = QID,
rsm = #rsm_set{before = Before}},
ID = send_query(Config, Query),

View File

@ -89,7 +89,7 @@ all_master(Config) ->
recv_message(Config),
#mix_participant{jid = MyBareJID} = xmpp:decode(PXML),
%% Coming online
PresenceID = randoms:get_string(),
PresenceID = p1_rand:get_string(),
Presence = xmpp:encode(#presence{}),
#iq{type = result,
sub_els =

View File

@ -58,7 +58,7 @@ single_cases() ->
service_presence_error(Config) ->
Service = muc_jid(Config),
ServiceResource = jid:replace_resource(Service, randoms:get_string()),
ServiceResource = jid:replace_resource(Service, p1_rand:get_string()),
lists:foreach(
fun(To) ->
send(Config, #presence{type = error, to = To}),
@ -81,7 +81,7 @@ service_message_error(Config) ->
send_recv(Config, #message{type = Type, to = Service}),
#stanza_error{reason = 'forbidden'} = xmpp:get_error(Err1)
end, [chat, normal, headline, groupchat]),
ServiceResource = jid:replace_resource(Service, randoms:get_string()),
ServiceResource = jid:replace_resource(Service, p1_rand:get_string()),
send(Config, #message{type = error, to = ServiceResource}),
lists:foreach(
fun(Type) ->
@ -93,7 +93,7 @@ service_message_error(Config) ->
service_unknown_ns_iq_error(Config) ->
Service = muc_jid(Config),
ServiceResource = jid:replace_resource(Service, randoms:get_string()),
ServiceResource = jid:replace_resource(Service, p1_rand:get_string()),
lists:foreach(
fun(To) ->
send(Config, #iq{type = result, to = To}),
@ -162,7 +162,7 @@ service_features(Config) ->
service_disco_info_node_error(Config) ->
MUC = muc_jid(Config),
Node = randoms:get_string(),
Node = p1_rand:get_string(),
#iq{type = error} = Err =
send_recv(Config, #iq{type = get, to = MUC,
sub_els = [#disco_info{node = Node}]}),
@ -594,7 +594,7 @@ invite_members_only_slave(Config) ->
invite_password_protected_master(Config) ->
Room = muc_room_jid(Config),
PeerJID = ?config(slave, Config),
Password = randoms:get_string(),
Password = p1_rand:get_string(),
ok = join_new(Config),
[104] = set_config(Config, [{passwordprotectedroom, true},
{roomsecret, Password}]),
@ -695,7 +695,7 @@ change_role_master(Config) ->
[] ->
ok
end,
Reason = randoms:get_string(),
Reason = p1_rand:get_string(),
put_event(Config, {Role, Reason}),
ok = set_role(Config, Role, Reason),
ct:comment("Receiving role change to ~s", [Role]),
@ -759,7 +759,7 @@ change_affiliation_master(Config) ->
[] ->
ok
end,
Reason = randoms:get_string(),
Reason = p1_rand:get_string(),
put_event(Config, {Aff, Role, Status, Reason}),
ok = set_affiliation(Config, Aff, Reason),
ct:comment("Receiving affiliation change to ~s", [Aff]),
@ -926,7 +926,7 @@ vcard_master(Config) ->
Room = muc_room_jid(Config),
PeerNick = ?config(slave_nick, Config),
PeerNickJID = jid:replace_resource(Room, PeerNick),
FN = randoms:get_string(),
FN = p1_rand:get_string(),
VCard = #vcard_temp{fn = FN},
ok = join_new(Config),
ct:comment("Waiting for slave to join"),
@ -956,7 +956,7 @@ vcard_slave(Config) ->
disconnect(Config).
nick_change_master(Config) ->
NewNick = randoms:get_string(),
NewNick = p1_rand:get_string(),
PeerJID = ?config(peer, Config),
PeerNickJID = peer_muc_jid(Config),
ok = master_join(Config),
@ -1006,8 +1006,8 @@ nick_change_slave(Config) ->
disconnect(NewConfig).
config_title_desc_master(Config) ->
Title = randoms:get_string(),
Desc = randoms:get_string(),
Title = p1_rand:get_string(),
Desc = p1_rand:get_string(),
Room = muc_room_jid(Config),
PeerNick = ?config(slave_nick, Config),
PeerNickJID = jid:replace_resource(Room, PeerNick),
@ -1059,7 +1059,7 @@ config_public_list_slave(Config) ->
disconnect(Config).
config_password_master(Config) ->
Password = randoms:get_string(),
Password = p1_rand:get_string(),
Room = muc_room_jid(Config),
PeerNick = ?config(slave_nick, Config),
PeerNickJID = jid:replace_resource(Room, PeerNick),
@ -1078,7 +1078,7 @@ config_password_slave(Config) ->
Password = get_event(Config),
#stanza_error{reason = 'not-authorized'} = join(Config),
#stanza_error{reason = 'not-authorized'} =
join(Config, #muc{password = randoms:get_string()}),
join(Config, #muc{password = p1_rand:get_string()}),
{[], _, _} = join(Config, #muc{password = Password}),
ok = leave(Config),
disconnect(Config).
@ -1137,7 +1137,7 @@ config_members_only_master(Config) ->
lists:member(<<"muc_membersonly">>, get_features(Config, Room)),
ct:comment("Waiting for slave to fail joining the room"),
set_member = get_event(Config),
ok = set_affiliation(Config, member, randoms:get_string()),
ok = set_affiliation(Config, member, p1_rand:get_string()),
#message{from = Room, type = normal} = Msg = recv_message(Config),
#muc_user{items = [#muc_item{jid = PeerBareJID,
affiliation = member}]} =
@ -1146,7 +1146,7 @@ config_members_only_master(Config) ->
put_event(Config, join),
ct:comment("Waiting for peer to join"),
recv_muc_presence(Config, PeerNickJID, available),
ok = set_affiliation(Config, none, randoms:get_string()),
ok = set_affiliation(Config, none, p1_rand:get_string()),
ct:comment("Waiting for peer to be kicked"),
#muc_user{status_codes = NewCodes,
items = [#muc_item{affiliation = none,
@ -1199,7 +1199,7 @@ config_moderated_master(Config) ->
PeerNickJID = peer_muc_jid(Config),
ok = master_join(Config),
lists:member(<<"muc_moderated">>, get_features(Config, Room)),
ok = set_role(Config, visitor, randoms:get_string()),
ok = set_role(Config, visitor, p1_rand:get_string()),
#muc_user{items = [#muc_item{role = visitor}]} =
recv_muc_presence(Config, PeerNickJID, available),
set_unmoderated = get_event(Config),
@ -1371,7 +1371,7 @@ config_allow_invites_slave(Config) ->
config_visitor_status_master(Config) ->
PeerNickJID = peer_muc_jid(Config),
Status = xmpp:mk_text(randoms:get_string()),
Status = xmpp:mk_text(p1_rand:get_string()),
ok = join_new(Config),
[104] = set_config(Config, [{members_by_default, false}]),
ct:comment("Asking the slave to join as a visitor"),
@ -1500,7 +1500,7 @@ config_visitor_nickchange_master(Config) ->
disconnect(Config).
config_visitor_nickchange_slave(Config) ->
NewNick = randoms:get_string(),
NewNick = p1_rand:get_string(),
MyNickJID = my_muc_jid(Config),
MyNewNickJID = jid:replace_resource(MyNickJID, NewNick),
ct:comment("Waiting for 'join' command from the master"),

View File

@ -76,11 +76,11 @@ send_non_existent(Config) ->
disconnect(Config).
view_non_existent(Config) ->
#stanza_error{reason = 'item-not-found'} = view(Config, [randoms:get_string()], false),
#stanza_error{reason = 'item-not-found'} = view(Config, [p1_rand:get_string()], false),
disconnect(Config).
remove_non_existent(Config) ->
ok = remove(Config, [randoms:get_string()]),
ok = remove(Config, [p1_rand:get_string()]),
disconnect(Config).
view_non_integer(Config) ->
@ -92,7 +92,7 @@ remove_non_integer(Config) ->
disconnect(Config).
malformed_iq(Config) ->
Item = #offline_item{node = randoms:get_string()},
Item = #offline_item{node = p1_rand:get_string()},
Range = [{Type, SubEl} || Type <- [set, get],
SubEl <- [#offline{items = [], _ = false},
#offline{items = [Item], _ = true}]]
@ -111,7 +111,7 @@ malformed_iq(Config) ->
wrong_user(Config) ->
Server = ?config(server, Config),
To = jid:make(<<"foo">>, Server),
Item = #offline_item{node = randoms:get_string()},
Item = #offline_item{node = p1_rand:get_string()},
Range = [{Type, Items, Purge, Fetch} ||
Type <- [set, get],
Items <- [[], [Item]],
@ -129,7 +129,7 @@ wrong_user(Config) ->
disconnect(Config).
unsupported_iq(Config) ->
Item = #offline_item{node = randoms:get_string()},
Item = #offline_item{node = p1_rand:get_string()},
lists:foreach(
fun(Type) ->
#iq{type = error} = Err =
@ -399,7 +399,7 @@ message_iterator(Config) ->
Offline = [[#offline{}]],
Hints = [[#hint{type = T}] || T <- [store, 'no-store']],
XEvent = [[#xevent{id = ID, offline = OfflineFlag}]
|| ID <- [undefined, randoms:get_string()],
|| ID <- [undefined, p1_rand:get_string()],
OfflineFlag <- [false, true]],
Delay = [[#delay{stamp = p1_time_compat:timestamp(), from = ServerJID}]],
AllEls = [Els1 ++ Els2 || Els1 <- [[]] ++ ChatStates ++ Delay ++ Hints ++ Offline,

View File

@ -202,7 +202,7 @@ malformed_iq_query(Config) ->
disconnect(Config).
malformed_get(Config) ->
JID = jid:make(randoms:get_string()),
JID = jid:make(p1_rand:get_string()),
Item = #block_item{jid = JID},
lists:foreach(
fun(SubEl) ->
@ -228,7 +228,7 @@ malformed_set(Config) ->
#block_list{},
#block_list{
items = [#block_item{
jid = jid:make(randoms:get_string())}]}]),
jid = jid:make(p1_rand:get_string())}]}]),
disconnect(Config).
malformed_type_value(Config) ->
@ -245,8 +245,8 @@ malformed_type_value(Config) ->
disconnect(Config).
set_get_block(Config) ->
J1 = jid:make(randoms:get_string(), randoms:get_string()),
J2 = jid:make(randoms:get_string(), randoms:get_string()),
J1 = jid:make(p1_rand:get_string(), p1_rand:get_string()),
J2 = jid:make(p1_rand:get_string(), p1_rand:get_string()),
{ok, ListName} = set_block(Config, [J1, J2]),
JIDs = get_block(Config),
JIDs = lists:sort([J1, J2]),
@ -304,7 +304,7 @@ deny_server_full_jid_slave(Config) ->
deny_slave(Config).
deny_group_master(Config) ->
Group = randoms:get_string(),
Group = p1_rand:get_string(),
deny_master(Config, {group, Group}).
deny_group_slave(Config) ->
@ -353,7 +353,7 @@ deny_master(Config, {Type, Value}) ->
lists:foreach(
fun(Opts) ->
ct:pal("Set list for ~s, ~s, ~w", [Type, Value, Opts]),
ListName = randoms:get_string(),
ListName = p1_rand:get_string(),
Item = #privacy_item{order = 0,
action = deny,
iq = proplists:get_bool(iq, Opts),

View File

@ -70,8 +70,8 @@ all_master(Config) ->
send_recv(
Config,
#iq{type = get, sub_els = [#bytestreams{}], to = Proxy}),
SID = randoms:get_string(),
Data = randoms:bytes(1024),
SID = p1_rand:get_string(),
Data = p1_rand:bytes(1024),
put_event(Config, {StreamHost, SID, Data}),
Socks5 = socks5_connect(StreamHost, {SID, MyJID, Peer}),
wait_for_slave(Config),

View File

@ -133,7 +133,7 @@ test_publish(Config) ->
disconnect(Config).
test_auto_create(Config) ->
Node = randoms:get_string(),
Node = p1_rand:get_string(),
publish_item(Config, Node),
delete_node(Config, Node),
disconnect(Config).
@ -287,7 +287,7 @@ affiliations_master(Config) ->
lists:foreach(
fun(Aff) ->
Node = <<(atom_to_binary(Aff, utf8))/binary,
$-, (randoms:get_string())/binary>>,
$-, (p1_rand:get_string())/binary>>,
create_node(Config, Node, default_node_config(Config)),
#ps_item{id = I} = publish_item(Config, Node),
ok = set_affiliations(Config, Node, [{Peer, Aff}]),
@ -598,7 +598,7 @@ set_node_config(Config, Node, Options) ->
publish_item(Config, Node) ->
PJID = pubsub_jid(Config),
ItemID = randoms:get_string(),
ItemID = p1_rand:get_string(),
Item = #ps_item{id = ItemID, sub_els = [xmpp:encode(#presence{id = ItemID})]},
case send_recv(Config,
#iq{type = set, to = PJID,

View File

@ -93,7 +93,7 @@ iq_set_many_items(Config) ->
iq_set_duplicated_groups(Config) ->
JID = jid:decode(<<"nurse@example.com">>),
G = randoms:get_string(),
G = p1_rand:get_string(),
ct:comment("Trying to send roster-set with duplicated groups"),
Item = #roster_item{jid = JID, groups = [G, G]},
#stanza_error{reason = 'bad-request'} = set_items(Config, [Item]),

View File

@ -720,7 +720,7 @@ id() ->
id(<<>>).
id(<<>>) ->
randoms:get_string();
p1_rand:get_string();
id(ID) ->
ID.

View File

@ -78,7 +78,7 @@ put_get_request(Config) ->
lists:foreach(
fun(NS) ->
{GetURL, PutURL, _Filename, Size} = slot_request(Config, NS),
Data = randoms:bytes(Size),
Data = p1_rand:bytes(Size),
put_request(Config, PutURL, Data),
get_request(Config, GetURL, Data)
end, namespaces()),
@ -119,7 +119,7 @@ get_size(NS, _Config, []) ->
slot_request(Config, NS) ->
To = upload_jid(Config),
Filename = filename(),
Size = randoms:uniform(1, 1024),
Size = p1_rand:uniform(1, 1024),
case NS of
?NS_HTTP_UPLOAD_0 ->
#iq{type = result,
@ -201,4 +201,4 @@ namespaces() ->
[?NS_HTTP_UPLOAD_0, ?NS_HTTP_UPLOAD, ?NS_HTTP_UPLOAD_OLD].
filename() ->
<<(randoms:get_string())/binary, ".png">>.
<<(p1_rand:get_string())/binary, ".png">>.