Skip to content

Commit

Permalink
Delete shotgun from big_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vkatsuba committed Aug 10, 2021
1 parent fd1489b commit 8913661
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 51 deletions.
1 change: 0 additions & 1 deletion big_tests/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
{gen_fsm_compat, "0.3.0"},
{cowboy, "2.9.0"},
{csv, "3.0.3", {pkg, csve}},
{shotgun, "0.5.0"},
{amqp_client, "3.8.14"},
{esip, "1.0.43"},
{jid, "1.0.0", {pkg, mongoose_jid}}
Expand Down
10 changes: 4 additions & 6 deletions big_tests/rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
{git,"https://github.com/proger/erlsh.git",
{ref,"4e8a107e4a082b5e687877cf08d152a45a715bf4"}},
0},
{<<"escalus">>,{pkg,<<"escalus">>,<<"4.2.4">>},0},
{<<"escalus">>,
{git,"https://github.com/esl/escalus.git",
{ref,"5d5c14a4e74124a5ebaf99bc577bc21f2b1ebd66"}},
0},
{<<"esip">>,{pkg,<<"esip">>,<<"1.0.43">>},0},
{<<"exml">>,{pkg,<<"hexml">>,<<"3.0.5">>},1},
{<<"fast_pbkdf2">>,{pkg,<<"fast_pbkdf2">>,<<"1.0.1">>},2},
Expand All @@ -33,7 +36,6 @@
{<<"rabbit_common">>,{pkg,<<"rabbit_common">>,<<"3.8.14">>},1},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},1},
{<<"recon">>,{pkg,<<"recon">>,<<"2.5.0">>},2},
{<<"shotgun">>,{pkg,<<"shotgun">>,<<"0.5.0">>},0},
{<<"stringprep">>,{pkg,<<"stringprep">>,<<"1.0.25">>},1},
{<<"stun">>,{pkg,<<"stun">>,<<"1.0.44">>},1},
{<<"uuid">>,{pkg,<<"uuid_erl">>,<<"2.0.2">>},1},
Expand All @@ -47,7 +49,6 @@
{<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>},
{<<"credentials_obfuscation">>, <<"9FB57683B84899CA3546B384E59AB5D3054A9F334EBA50D74C82CD0AE82DD6CA">>},
{<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>},
{<<"escalus">>, <<"765F5638D4B9C7AF11617E149473C5BB60DBA61D489AFC453DF7C56EA9BB6552">>},
{<<"esip">>, <<"1CBDC073073F80B9B50E2759F66CA13A353EB4F874BCF92501BD4CD767E34D46">>},
{<<"exml">>, <<"2A79262A744A9B100A9A27A8E76EADCF146F17653DABA2A88A74C8CF5B06ADF3">>},
{<<"fast_pbkdf2">>, <<"E63454F7FAA6D6E43751DD44EB7C287EB3509DA92CE7F4AE00661AC580A96100">>},
Expand All @@ -68,7 +69,6 @@
{<<"rabbit_common">>, <<"CC1604891295CD82F34597F1526AC611EA7B6A0E57B3DD79B41CB4224BCC6EC5">>},
{<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>},
{<<"recon">>, <<"2F7FCBEC2C35034BADE2F9717F77059DC54EB4E929A3049CA7BA6775C0BD66CD">>},
{<<"shotgun">>, <<"F780CC0D7BBEBB7B6067C519245D4DB62321F35BD05029080FC8499C1680F10C">>},
{<<"stringprep">>, <<"15062F6020777A51A96488F29CE9A2D83E3195F92FDF27F25ACC462DFF7D8D82">>},
{<<"stun">>, <<"30B6B774864B24B05BA901291ABE583BFF19081E7C4EFB3361DF50B781EC9D3B">>},
{<<"uuid">>, <<"0D1CA9D94CA3B058467BCE20B7706CC816A2BDBBE0574DD008936AE97EA4EBE7">>},
Expand All @@ -81,7 +81,6 @@
{<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>},
{<<"credentials_obfuscation">>, <<"D28A89830E30698B075DE9A4DBE683A20685C6BED1E3B7DF744A0C06E6FF200A">>},
{<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>},
{<<"escalus">>, <<"C9B2B0803FE9A5C2309992316058EF2E1160424572B49F474F0A0EE2CF96ADF2">>},
{<<"esip">>, <<"B2C758AE52C4588E0399C0B4CE550BFA56551A5A2F828A28389F2614797E4F4B">>},
{<<"exml">>, <<"426B50FA455C95760BA4F7C75ED76F90A58837742CBE38A86C6A75BEFA383907">>},
{<<"fast_pbkdf2">>, <<"CF834AB70270C628C8A37E9BFA4D7282AD6FF0C5DE6C8EB6A2F88C09F890857B">>},
Expand All @@ -102,7 +101,6 @@
{<<"rabbit_common">>, <<"27409E425413CDD3FC2C077CF08226C4A307D56B1467883F26AB3789B2E106D0">>},
{<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>},
{<<"recon">>, <<"72F3840FEDD94F06315C523F6CECF5B4827233BED7AE3FE135B2A0EBEAB5E196">>},
{<<"shotgun">>, <<"F7A03C23589C04FF2692FF8F5A1A6DB8DA22153DB15A97A9FE1223DBFFAF2213">>},
{<<"stringprep">>, <<"8E0807D94A6927D1C3F8E76D584A2E3CDD9B4BCB02823EAF96629EDF2A65B104">>},
{<<"stun">>, <<"E45BBA816CBEFFF01D820E49E66814F450DF25A7A468A70D68D1E64218D46520">>},
{<<"uuid">>, <<"4866CA7B3BD0265BC371590DCD0FE2832FC08588A071B72D07E09E23F163D0D6">>},
Expand Down
74 changes: 30 additions & 44 deletions big_tests/tests/rest_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ security_test_cases() ->
].

init_per_suite(Config) ->
application:ensure_all_started(shotgun),
Config1 = init_modules(Config),
[{muc_light_host, muc_light_helper:muc_host()}
| escalus:init_per_suite(Config1)].

end_per_suite(Config) ->
escalus_fresh:clean(),
HostType = host_type(),
application:stop(shotgun),
dynamic_modules:restore_modules(HostType, Config),
escalus:end_per_suite(Config).

Expand Down Expand Up @@ -595,11 +593,11 @@ msg_with_props_can_be_parsed(Config) ->
M1 = rest_helper:make_msg_stanza_with_props(BobJID,MsgID),

escalus:send(Alice, M1),

escalus:wait_for_stanza(Bob),
mam_helper:wait_for_archive_size(Bob, 1),
mam_helper:wait_for_archive_size(Alice, 1),

AliceCreds = {AliceJID, user_password(alice)},

% recent msgs with a limit
Expand Down Expand Up @@ -641,11 +639,11 @@ msg_with_malformed_props_can_be_parsed(Config) ->

M1 = rest_helper:make_malformed_msg_stanza_with_props(BobJID,MsgID),
escalus:send(Alice, M1),

escalus:wait_for_stanza(Bob),
mam_helper:wait_for_archive_size(Bob, 1),
mam_helper:wait_for_archive_size(Alice, 1),

% recent msgs with a limit
M2 = get_messages_with_props(AliceCreds, BobJID, 1),
Recv = [_Msg] = rest_helper:decode_maplist(M2),
Expand Down Expand Up @@ -712,7 +710,7 @@ given_new_room(Owner, RoomID) ->

given_new_room(Owner, RoomID, RoomName) ->
Creds = credentials(Owner),
create_room_with_id(Creds, RoomName, <<"This room subject">>, RoomID).
create_room_with_id(Creds, RoomName, <<"This room subject">>, RoomID).

given_user_invited({_, Inviter} = Owner, RoomID, Invitee) ->
JID = user_jid(Invitee),
Expand Down Expand Up @@ -896,45 +894,33 @@ is_participant(User, Role, RoomInfo) ->
lists:any(Fun, Participants).

connect_to_sse(User) ->
%% By default, gun prefers http2 protocol.
%%
%% The error occures with HTTP/2 enabled both on the client and the server:
%% "{error,{stream_error,protocol_error, 'Stream reset by server.'}}"
%%
%% Disable HTTP/2 on the client side:
GunOpts = #{protocols => [http]},
ShotGunOpts = #{gun_opts => GunOpts},
Port = ct:get_config({hosts, mim, http_api_client_endpoint_port}),
{ok, Conn} = shotgun:open("localhost", Port, https, ShotGunOpts),
Me = self(),
EventFun = fun(State, Ref, Bin) ->
Me ! {sse, State, Ref, Bin}
end,

{U, P} = credentials(User),
Options = #{async => true, async_mode => sse, handle_event => EventFun},
Headers = #{basic_auth => {binary_to_list(U), binary_to_list(P)}},
case shotgun:get(Conn, "/api/sse", Headers, Options) of
{ok, Ref} ->
{Conn, Ref};
Other ->
ct:fail(#{issue => connect_to_sse_failed,
headers => Headers,
reason => Other,
url => "https://localhost:8089/api/sse"})
end.

wait_for_event({_Conn, Ref}) ->
receive
{sse, _State, Ref, Bin} ->
shotgun:parse_event(Bin)
after
5000 ->
ct:fail("timeout waiting for SSE event")
{ok, ConnPid} = gun:open("localhost", Port, #{
transport => tls,
protocols => [http],
http_opts => #{content_handlers => [gun_sse_h, gun_data_h]}
}),
{ok, _} = gun:await_up(ConnPid),
{Username, Password} = credentials(User),
Base64 = base64:encode(binary_to_list(Username) ++ [$: | binary_to_list(Password)]),
Headers = [{<<"authorization">>, <<"basic ", Base64/binary>>},
{<<"host">>, <<"localhost">>},
{<<"accept">>, <<"text/event-stream">>}],
StreamRef = gun:get(ConnPid, "/api/sse", Headers),
#{pid => ConnPid, stream_ref => StreamRef}.

wait_for_event(#{pid := Pid, stream_ref := StreamRef} = Opts) ->
case gun:await(Pid, StreamRef) of
{response, nofin, Status, _} ->
wait_for_event(Opts);
{sse, #{data := [Response]}} ->
Opts#{data => Response};
Error ->
Error
end.

stop_sse({Conn, _Ref}) ->
shotgun:close(Conn).
stop_sse(Pid) ->
gun:close(Pid).

assert_json_message(Sent, Received) ->
#{<<"body">> := Body,
Expand Down Expand Up @@ -1251,7 +1237,7 @@ verify_server_name_in_header(Server, ExpectedName) ->
body => <<>>,
return_headers => true,
server => Server
},
},
{?UNAUTHORIZED, Headers2, _} = rest_helper:make_request(ReqParams),
% THEN expected server name is returned
ExpectedName = proplists:get_value(<<"server">>, Headers2).
Expand Down

0 comments on commit 8913661

Please sign in to comment.