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}),
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.
anonymous ->
<<"">>;
legacy_auth ->
- randoms:get_string();
+ p1_rand:get_string();
_ ->
?config(resource, OrigConfig)
end,
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).
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">>}),
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),
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),
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,
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}]}),
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),
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) ->
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),
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),
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),
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 =
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}),
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) ->
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}),
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}]}),
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}]),
[] ->
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]),
[] ->
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]),
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"),
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),
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),
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),
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).
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}]} =
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,
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),
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"),
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"),
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) ->
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}]]
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]],
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 =
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,
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) ->
#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) ->
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]),
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) ->
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),
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),
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).
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}]),
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,
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]),
id(<<>>).
id(<<>>) ->
- randoms:get_string();
+ p1_rand:get_string();
id(ID) ->
ID.
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()),
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,
[?NS_HTTP_UPLOAD_0, ?NS_HTTP_UPLOAD, ?NS_HTTP_UPLOAD_OLD].
filename() ->
- <<(randoms:get_string())/binary, ".png">>.
+ <<(p1_rand:get_string())/binary, ".png">>.