aboutsummaryrefslogtreecommitdiffstats
path: root/test/req_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-10-05 11:23:57 +0200
committerLoïc Hoguin <[email protected]>2019-10-05 11:23:57 +0200
commit03dac1486d72d9d84a3cb99d2040c78b25853257 (patch)
treefaab2aced8c1abb9152e237bc9c7d60c77850bbc /test/req_SUITE.erl
parent5ffb4f98e0a8be09675ca508c269b71654294d6a (diff)
downloadcowboy-03dac1486d72d9d84a3cb99d2040c78b25853257.tar.gz
cowboy-03dac1486d72d9d84a3cb99d2040c78b25853257.tar.bz2
cowboy-03dac1486d72d9d84a3cb99d2040c78b25853257.zip
Add cowboy_req:filter_cookies/2
Diffstat (limited to 'test/req_SUITE.erl')
-rw-r--r--test/req_SUITE.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl
index 2cc8de4..76abba9 100644
--- a/test/req_SUITE.erl
+++ b/test/req_SUITE.erl
@@ -286,6 +286,27 @@ parse_cookies(Config) ->
[{<<"cookie">>, "goodname=strawberry\tmilkshake"}], Config),
ok.
+filter_then_parse_cookies(Config) ->
+ doc("Filter cookies then parse them."),
+ <<"[]">> = do_get_body("/filter_then_parse_cookies", Config),
+ <<"[{<<\"cake\">>,<<\"strawberry\">>}]">>
+ = do_get_body("/filter_then_parse_cookies", [{<<"cookie">>, "cake=strawberry"}], Config),
+ <<"[{<<\"cake\">>,<<\"strawberry\">>},{<<\"color\">>,<<\"blue\">>}]">>
+ = do_get_body("/filter_then_parse_cookies", [{<<"cookie">>, "cake=strawberry; color=blue"}], Config),
+ <<"[{<<\"cake\">>,<<\"strawberry\">>},{<<\"color\">>,<<\"blue\">>}]">>
+ = do_get_body("/filter_then_parse_cookies",
+ [{<<"cookie">>, "cake=strawberry"}, {<<"cookie">>, "color=blue"}], Config),
+ <<"[]">>
+ = do_get_body("/filter_then_parse_cookies",
+ [{<<"cookie">>, "bad name=strawberry"}], Config),
+ <<"[{<<\"cake\">>,<<\"strawberry\">>}]">>
+ = do_get_body("/filter_then_parse_cookies",
+ [{<<"cookie">>, "bad name=strawberry; cake=strawberry"}], Config),
+ <<"[]">>
+ = do_get_body("/filter_then_parse_cookies",
+ [{<<"cookie">>, "Blocked by http://www.example.com/upgrade-to-remove"}], Config),
+ ok.
+
parse_header(Config) ->
doc("Parsed request header with/without default."),
<<"[{{<<\"text\">>,<<\"html\">>,[]},1000,[]}]">>