aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-10-21 19:15:48 +0200
committerLoïc Hoguin <[email protected]>2020-10-21 20:17:18 +0200
commit465d072abf4a76104d4562ed15345b27fe9a0cff (patch)
tree853338dc133fda51ed65e74dedc81f845dc090de /test
parent69f19635df64ea48af3120c9685f7ad51b338f8f (diff)
downloadgun-465d072abf4a76104d4562ed15345b27fe9a0cff.tar.gz
gun-465d072abf4a76104d4562ed15345b27fe9a0cff.tar.bz2
gun-465d072abf4a76104d4562ed15345b27fe9a0cff.zip
Fix cookie handling when tunnel and origin schemes mismatch
The cookie_ignore_informational has been moved to http_opts and http2_opts. Also fix an issue when using 'protocols' in gun:open. When connecting via TLS the protocol's options were discarded.
Diffstat (limited to 'test')
-rw-r--r--test/rfc6265bis_SUITE.erl42
1 files changed, 37 insertions, 5 deletions
diff --git a/test/rfc6265bis_SUITE.erl b/test/rfc6265bis_SUITE.erl
index 8beee58..b4b443d 100644
--- a/test/rfc6265bis_SUITE.erl
+++ b/test/rfc6265bis_SUITE.erl
@@ -158,9 +158,8 @@ do_informational_set_cookie(Config, Boolean) ->
Protocol = config(protocol, Config),
{ok, ConnPid} = gun:open("localhost", config(port, Config), #{
transport => config(transport, Config),
- protocols => [Protocol],
- cookie_store => gun_cookies_list:init(),
- cookie_ignore_informational => Boolean
+ protocols => [{Protocol, #{cookie_ignore_informational => Boolean}}],
+ cookie_store => gun_cookies_list:init()
}),
{ok, Protocol} = gun:await_up(ConnPid),
StreamRef1 = gun:get(ConnPid, "/informational"),
@@ -176,13 +175,46 @@ do_informational_set_cookie(Config, Boolean) ->
gun:close(ConnPid),
Res.
-set_cookie_connect(Config) ->
+set_cookie_connect_tcp(Config) ->
doc("Cookies may also be set in responses going through CONNECT tunnels."),
Transport = config(transport, Config),
Protocol = config(protocol, Config),
- {ok, ProxyPid, ProxyPort} = event_SUITE:do_proxy_start(Protocol, Transport),
+ {ok, ProxyPid, ProxyPort} = event_SUITE:do_proxy_start(Protocol, tcp),
{ok, ConnPid} = gun:open("localhost", ProxyPort, #{
+ transport => tcp,
+ protocols => [Protocol],
+ cookie_store => gun_cookies_list:init()
+ }),
+ {ok, Protocol} = gun:await_up(ConnPid),
+ tunnel_SUITE:do_handshake_completed(Protocol, ProxyPid),
+ StreamRef1 = gun:connect(ConnPid, #{
+ host => "localhost",
+ port => config(port, Config),
transport => Transport,
+ protocols => [Protocol]
+ }),
+ %% @todo _IsFin is 'fin' for HTTP and 'nofin' for HTTP/2...
+ {response, _IsFin, 200, _} = gun:await(ConnPid, StreamRef1),
+ {up, Protocol} = gun:await(ConnPid, StreamRef1),
+ StreamRef2 = gun:get(ConnPid, "/cookie-set?prefix", #{
+ <<"please-set-cookie">> => <<"a=b">>
+ }, #{tunnel => StreamRef1}),
+ {response, fin, 204, Headers2} = gun:await(ConnPid, StreamRef2),
+ ct:log("Headers2:~n~p", [Headers2]),
+ StreamRef3 = gun:get(ConnPid, "/cookie-echo", [], #{tunnel => StreamRef1}),
+ {response, nofin, 200, _} = gun:await(ConnPid, StreamRef3),
+ {ok, Body3} = gun:await_body(ConnPid, StreamRef3),
+ ct:log("Body3:~n~p", [Body3]),
+ [{<<"a">>, <<"b">>}] = cow_cookie:parse_cookie(Body3),
+ gun:close(ConnPid).
+
+set_cookie_connect_tls(Config) ->
+ doc("Cookies may also be set in responses going through CONNECT tunnels."),
+ Transport = config(transport, Config),
+ Protocol = config(protocol, Config),
+ {ok, ProxyPid, ProxyPort} = event_SUITE:do_proxy_start(Protocol, tls),
+ {ok, ConnPid} = gun:open("localhost", ProxyPort, #{
+ transport => tls,
protocols => [Protocol],
cookie_store => gun_cookies_list:init()
}),