Skip to content

Commit 65aadba

Browse files
authored
Merge pull request #4303 from esl/escalus-ws-changes
MongooseIM using new version of escalus
2 parents 074de4f + 78a1893 commit 65aadba

7 files changed

+526
-446
lines changed

big_tests/rebar.config

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
{proper, "1.4.0"},
1717
{gun, "2.1.0"},
1818
{fusco, "0.1.1"},
19-
{escalus, "4.2.12"},
19+
{escalus, {git, "[email protected]:esl/escalus.git", {branch, "ws-stream-management"}}},
20+
% {escalus, "4.2.12"},
2021
{cowboy, "2.12.0"},
2122
{csv, "3.0.3", {pkg, csve}},
2223
{amqp_client, "3.12.14"},

big_tests/rebar.lock

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
{pkg,<<"credentials_obfuscation">>,<<"3.4.0">>},
99
1},
1010
{<<"csv">>,{pkg,<<"csve">>,<<"3.0.3">>},0},
11-
{<<"escalus">>,{pkg,<<"escalus">>,<<"4.2.12">>},0},
11+
{<<"escalus">>,
12+
{git,"[email protected]:esl/escalus.git",
13+
{ref,"f99d6efe1028f645d8a17c9ab3fb8e4adab69a76"}},
14+
0},
1215
{<<"esip">>,{pkg,<<"esip">>,<<"1.0.52">>},0},
1316
{<<"exml">>,{pkg,<<"hexml">>,<<"3.4.1">>},0},
1417
{<<"fast_pbkdf2">>,{pkg,<<"fast_pbkdf2">>,<<"1.0.5">>},2},
@@ -41,7 +44,6 @@
4144
{<<"cowlib">>, <<"DB8F7505D8332D98EF50A3EF34B34C1AFDDEC7506E4EE4DD4A3A266285D282CA">>},
4245
{<<"credentials_obfuscation">>, <<"34E18B126B3AEFD6E8143776FBE1CECEEA6792307C99AC5EE8687911F048CFD7">>},
4346
{<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>},
44-
{<<"escalus">>, <<"D0390EB227D4B19F5EA85CAE722F3BD9891DE054EBF1C154078D5203C07F7972">>},
4547
{<<"esip">>, <<"A2840287C493A4280E6FBA57A257706843B025C315875E38B03FD07190E22DBA">>},
4648
{<<"exml">>, <<"9581FE6512D9772C61BBE611CD4A8E5BB90B4D4481275325EC520F7A931A9393">>},
4749
{<<"fast_pbkdf2">>, <<"6045138C4C209FC8222A0B18B2CB1D7BD7407EF4ADAD0F14C5E0F7F4726E3E41">>},
@@ -73,7 +75,6 @@
7375
{<<"cowlib">>, <<"E1E1284DC3FC030A64B1AD0D8382AE7E99DA46C3246B815318A4B848873800A4">>},
7476
{<<"credentials_obfuscation">>, <<"738ACE0ED5545D2710D3F7383906FC6F6B582D019036E5269C4DBD85DBCED566">>},
7577
{<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>},
76-
{<<"escalus">>, <<"BE52DAAEDE0D920F100BA1AAA43220ECA070F41E1BB52472C192F2973C9B424D">>},
7778
{<<"esip">>, <<"6F00165395900500AA262CE0297162D93931C78C1464D89FD0EDC6E3D6BC011F">>},
7879
{<<"exml">>, <<"D8E7894E2544402B4986EEB2443C15B51B14F686266F091DBF2777D1D99A2FA2">>},
7980
{<<"fast_pbkdf2">>, <<"BC3B5A3CAB47AD114FF8BB815FEDE62A6187ACD14D8B37412F2AF8236A089CEF">>},

big_tests/tests/sasl_external_SUITE.erl

+2-3
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,10 @@ generate_user(C, User, Transport) ->
381381
{versions, ['tlsv1.2']},
382382
{certfile, maps:get(cert, UserCert)},
383383
{keyfile, maps:get(key, UserCert)}]}],
384-
Common ++ transport_specific_options(Transport)
385-
++ [{port, ct:get_config({hosts, mim, c2s_port})}].
384+
Common ++ transport_specific_options(Transport).
386385

387386
transport_specific_options(escalus_tcp) ->
388-
[{starttls, required}];
387+
[{starttls, required}, {port, ct:get_config({hosts, mim, c2s_port})}];
389388
transport_specific_options(_) ->
390389
[{port, ct:get_config({hosts, mim, cowboy_secure_port})},
391390
{ssl, true}].

big_tests/tests/sm_SUITE.erl

+496-435
Large diffs are not rendered by default.

big_tests/tests/sm_helper.erl

+7-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,13 @@ send_initial_presence(User) ->
277277

278278
process_initial_stanza(User) ->
279279
send_initial_presence(User),
280-
escalus:assert(is_presence, escalus:wait_for_stanza(User)).
280+
Stanza = escalus:wait_for_stanza(User),
281+
case escalus_pred:is_iq(Stanza) of
282+
true ->
283+
Stanza2 = escalus:wait_for_stanza(User),
284+
escalus:assert(is_presence, Stanza2);
285+
false -> escalus:assert(is_presence, Stanza)
286+
end.
281287

282288
send_messages(Bob, Alice, Texts) ->
283289
[escalus:send(Bob, escalus_stanza:chat_to(Alice, Text))

src/c2s/mongoose_c2s.erl

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ handle_info(StateData, _C2SState, {TcpOrSSl, _Socket, _Packet} = SocketData)
637637
when TcpOrSSl =:= tcp; TcpOrSSl =:= ssl ->
638638
handle_socket_data(StateData, SocketData);
639639
handle_info(StateData, C2SState, {Closed, _Socket} = SocketData)
640-
when Closed =:= tcp_closed; Closed =:= ssl_closed ->
640+
when Closed =:= tcp_closed; Closed =:= ssl_closed; Closed =:= websockets_closed ->
641641
handle_socket_closed(StateData, C2SState, SocketData);
642642
handle_info(StateData, C2SState, {Error, _Socket} = SocketData)
643-
when Error =:= tcp_error; Error =:= ssl_error ->
643+
when Error =:= tcp_error; Error =:= ssl_error; Error =:= websockets_error ->
644644
handle_socket_error(StateData, C2SState, SocketData);
645645
handle_info(StateData, C2SState, Info) ->
646646
handle_foreign_event(StateData, C2SState, info, Info).

src/mod_websockets.erl

+13-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,19 @@ init(Req, Opts = #{timeout := Timeout}) ->
9292
%% upgrade protocol
9393
{cowboy_websocket, Req1, AllModOpts, #{idle_timeout => Timeout}}.
9494

95-
terminate(_Reason, _Req, _State) ->
95+
terminate(_Reason, _Req, #ws_state{fsm_pid = undefined} = State) ->
96+
ok;
97+
terminate(Reason, _Req, #ws_state{fsm_pid = FSM} = State) when Reason =:= normal;
98+
Reason =:= stop;
99+
Reason =:= timeout;
100+
Reason =:= remote ->
101+
FSM ! {websockets_closed, undefined},
102+
ok;
103+
terminate({remote, _, _}, _Req, #ws_state{fsm_pid = FSM} = State) ->
104+
FSM ! {websockets_closed, undefined},
105+
ok;
106+
terminate(Reason, _Req, #ws_state{fsm_pid = FSM} = State) ->
107+
FSM ! {websockets_error, undefined},
96108
ok.
97109

98110
%%--------------------------------------------------------------------

0 commit comments

Comments
 (0)