Skip to content

Commit f813f94

Browse files
authored
Merge pull request #4415 from esl/base16
Get rid of base16
2 parents 5b10044 + 2deccca commit f813f94

35 files changed

+67
-70
lines changed

big_tests/rebar.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
%% We use https:// instead of git://
1010
{deps, [
11-
{base16, "2.0.1"},
1211
{exml, "3.4.1", {pkg, hexml}},
1312
{bbmustache, "1.12.2"},
1413
{jiffy, "1.1.2"},

big_tests/rebar.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"1.2.0",
22
[{<<"amqp_client">>,{pkg,<<"amqp_client">>,<<"4.0.3">>},0},
3-
{<<"base16">>,{pkg,<<"base16">>,<<"2.0.1">>},0},
3+
{<<"base16">>,{pkg,<<"base16">>,<<"2.0.1">>},1},
44
{<<"bbmustache">>,{pkg,<<"bbmustache">>,<<"1.12.2">>},0},
55
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.12.0">>},0},
66
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.13.0">>},1},

big_tests/tests/component_helper.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ component_handshake(Conn = #client{props = Props}, []) ->
104104
component_handshake_el(SID, Password) ->
105105
Handshake = crypto:hash(sha, <<SID/binary, Password/binary>>),
106106
#xmlel{name = <<"handshake">>,
107-
children = [#xmlcdata{content = base16:encode(Handshake)}]}.
107+
children = [#xmlcdata{content = binary:encode_hex(Handshake, lowercase)}]}.
108108

109109
component_start_stream_subdomain(Conn = #client{props = Props}, []) ->
110110
{component, Component} = lists:keyfind(component, 1, Props),

big_tests/tests/graphql_helper.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ init_domain_admin_handler(Config) ->
170170
init_domain_admin_handler(Config, Domain) ->
171171
case mongoose_helper:is_rdbms_enabled(Domain) of
172172
true ->
173-
Password = base16:encode(crypto:strong_rand_bytes(8)),
173+
Password = binary:encode_hex(crypto:strong_rand_bytes(8)),
174174
Creds = {<<"admin@", Domain/binary>>, Password},
175175
domain_helper:set_domain_password(mim(), Domain, Password),
176176
add_specs([{protocol, http}, {domain_admin, Creds}, {schema_endpoint, domain_admin}

big_tests/tests/graphql_stanza_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ user_send_stanza_without_from_with_id(Config) ->
372372

373373
user_send_stanza_without_from_with_id_story(Config, Alice, Bob) ->
374374
Body = <<"Hi!">>,
375-
StanzaId = base16:encode(crypto:strong_rand_bytes(8)),
375+
StanzaId = binary:encode_hex(crypto:strong_rand_bytes(8)),
376376
Stanza = escalus_stanza:set_id(escalus_stanza:chat_to_short_jid(Bob, Body), StanzaId),
377377
Res = user_send_stanza(Alice, exml:to_binary(Stanza), Config),
378378
?assertEqual(#{<<"id">> => StanzaId}, get_ok_value([data, stanza, sendStanza], Res)),

big_tests/tests/inbox_helper.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ check_result(Packet, ExpectedResult) ->
317317
ExpectedResult).
318318

319319
maybe_make_queryid(iq_id) ->
320-
#{iq_id => base16:encode(crypto:strong_rand_bytes(16))};
320+
#{iq_id => binary:encode_hex(crypto:strong_rand_bytes(16), lowercase)};
321321
maybe_make_queryid(queryid) ->
322-
#{queryid => base16:encode(crypto:strong_rand_bytes(16))};
322+
#{queryid => binary:encode_hex(crypto:strong_rand_bytes(16), lowercase)};
323323
maybe_make_queryid(undefined) ->
324324
#{}.
325325

big_tests/tests/jingle_sip_translator.erl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ make_200_ok_for_conference_call(Socket, Tr, #sip{hdrs = Hdrs} = Sip, #sip{hdrs =
118118
make_200_ok_for_phone_call(Tr, Sip, Resp183),
119119
{_, #uri{user = ReceiverUser}, _Params} = Receiver = esip:get_hdr(to, RespHdrs),
120120
{_, _, _} = Initiator = esip:get_hdr(from, RespHdrs),
121-
Branch = base16:encode(crypto:strong_rand_bytes(3)),
121+
Branch = binary:encode_hex(crypto:strong_rand_bytes(3), lowercase),
122122
URIBin = <<"sip:",ReceiverUser/binary,"@127.0.0.1:12345;ob;transport=tcp">>,
123123
ContactURI = esip_codec:decode_uri(URIBin),
124124
Contact = {<<>>, ContactURI, []},
@@ -142,7 +142,7 @@ make_200_ok_for_conference_call(Socket, Tr, #sip{hdrs = Hdrs} = Sip, #sip{hdrs =
142142

143143
make_forward_req(#sip{hdrs = Hdrs} = Sip) ->
144144
%% Forward the request back to MongooseIM
145-
Branch = base16:encode(crypto:strong_rand_bytes(3)),
145+
Branch = binary:encode_hex(crypto:strong_rand_bytes(3), lowercase),
146146
{_, #uri{user = FromUser}, _} = esip:get_hdr(to, Hdrs),
147147
URIBin = <<"sip:",FromUser/binary,"@127.0.0.1:12345;ob;transport=tcp">>,
148148
ContactURI = esip_codec:decode_uri(URIBin),
@@ -246,7 +246,7 @@ dialog_callback(#sip{type = request, hdrs = Hdrs} = Req, Socket, _Tr) ->
246246
{_, #uri{user = ToUser}, _} = To,
247247
{_, #uri{user = _FromUser}, _} = From,
248248

249-
Branch = base16:encode(crypto:strong_rand_bytes(3)),
249+
Branch = binary:encode_hex(crypto:strong_rand_bytes(3), lowercase),
250250
URIBin = <<"sip:",ToUser/binary,"@127.0.0.1:12345;ob;transport=tcp">>,
251251
ContactURI = esip_codec:decode_uri(URIBin),
252252
Contact = {<<>>, ContactURI, []},
@@ -277,15 +277,15 @@ send_invite(From, To, Pid) ->
277277

278278
FromURI = esip_codec:decode_uri(<<"sip:", FromJID/binary>>),
279279
FromSIP = {FromUser, FromURI,
280-
[{<<"tag">>, base16:encode(crypto:strong_rand_bytes(2))}]},
280+
[{<<"tag">>, binary:encode_hex(crypto:strong_rand_bytes(2), lowercase)}]},
281281

282282
ToUser = escalus_client:username(To),
283283
ToJID = escalus_client:short_jid(To),
284284
ToURI = esip_codec:decode_uri(<<"sip:", ToJID/binary>>),
285285
ToSIP = {ToUser, ToURI, []},
286-
CallID = base16:encode(crypto:strong_rand_bytes(6)),
286+
CallID = binary:encode_hex(crypto:strong_rand_bytes(6), lowercase),
287287
CSeq = 141501489,
288-
Branch = base16:encode(crypto:strong_rand_bytes(3)),
288+
Branch = binary:encode_hex(crypto:strong_rand_bytes(3), lowercase),
289289
ContactURI = esip_codec:decode_uri(<<"sip:",FromUser/binary,"@127.0.0.1:12345;ob">>),
290290
Contact = {<<>>, ContactURI, []},
291291

@@ -322,7 +322,7 @@ send_ack_for_200_ok(#sip{type = response, method = <<"INVITE">>,
322322
'route', 'max-forwards',
323323
'authorization', 'to', 'from',
324324
'proxy-authorization'], Hdrs),
325-
Branch = base16:encode(crypto:strong_rand_bytes(3)),
325+
Branch = binary:encode_hex(crypto:strong_rand_bytes(3), lowercase),
326326
Via = #via{transport = <<"UDP">>, host = <<"127.0.0.1">>, port = 12345,
327327
params = [{<<"rport">>, <<>>},
328328
{<<"branch">>, <<"z9hG4bK-", Branch/binary>>}]},

big_tests/tests/mam_helper.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ generate_msg_for_date_user(Owner, Remote, DateTime) ->
958958
generate_msg_for_date_user(Owner, Remote, DateTime, random_text()).
959959

960960
random_text() ->
961-
base16:encode(crypto:strong_rand_bytes(4)).
961+
binary:encode_hex(crypto:strong_rand_bytes(4)).
962962

963963
generate_msg_for_date_user(Owner, {RemoteBin, _, _} = Remote, DateTime, Content) ->
964964
Microsec = datetime_to_microseconds(DateTime),

big_tests/tests/mim_c2s_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ two_users_can_log_and_chat(Config) ->
132132
too_big_stanza_is_rejected(Config) ->
133133
AliceSpec = escalus_fresh:create_fresh_user(Config, alice),
134134
{ok, Alice, _Features} = escalus_connection:start(AliceSpec),
135-
BigBody = base16:encode(crypto:strong_rand_bytes(?MAX_STANZA_SIZE)),
135+
BigBody = binary:encode_hex(crypto:strong_rand_bytes(?MAX_STANZA_SIZE)),
136136
escalus_client:send(Alice, escalus_stanza:chat_to(Alice, BigBody)),
137137
escalus:assert(is_stream_error, [<<"policy-violation">>, <<>>], escalus_client:wait_for_stanza(Alice)),
138138
escalus:assert(is_stream_end, escalus_client:wait_for_stanza(Alice)),
@@ -141,7 +141,7 @@ too_big_stanza_is_rejected(Config) ->
141141
too_big_opening_tag_is_rejected(Config) ->
142142
AliceSpec = escalus_fresh:create_fresh_user(Config, alice),
143143
{ok, Alice, _Features} = escalus_connection:start(AliceSpec, []),
144-
BigAttrs = [{<<"bigattr">>, base16:encode(crypto:strong_rand_bytes(?MAX_STANZA_SIZE))}],
144+
BigAttrs = [{<<"bigattr">>, binary:encode_hex(crypto:strong_rand_bytes(?MAX_STANZA_SIZE))}],
145145
escalus_client:send(Alice, #xmlel{name = <<"stream:stream">>, attrs = BigAttrs}),
146146
escalus:assert(is_stream_start, escalus_client:wait_for_stanza(Alice)),
147147
escalus:assert(is_stream_error, [<<"xml-not-well-formed">>, <<>>],

big_tests/tests/muc_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5419,4 +5419,4 @@ fresh_nick_name(Prefix) ->
54195419
<<Prefix/binary, (fresh_nick_name())/binary>>.
54205420

54215421
fresh_nick_name() ->
5422-
fresh_room_name(base16:encode(crypto:strong_rand_bytes(5))).
5422+
fresh_room_name(binary:encode_hex(crypto:strong_rand_bytes(5), lowercase)).

0 commit comments

Comments
 (0)