Skip to content

Commit

Permalink
Update cookie tests against latest WPT
Browse files Browse the repository at this point in the history
The http-state tests were removed and replaced with
tests in HTML pages. I have devised a way to semi-
automatically import them and test them.

Additional fixes were made following changes in
the rfc6265bis draft.
  • Loading branch information
essen committed Sep 12, 2022
1 parent 0724dbf commit 180ce23
Show file tree
Hide file tree
Showing 458 changed files with 499 additions and 622 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ CT_OPTS += -ct_hooks gun_ct_hook [] # -boot start_sasl
LOCAL_DEPS = ssl

DEPS = cowlib
dep_cowlib = git https://github.com/ninenines/cowlib 2.11.0
dep_cowlib = git https://github.com/ninenines/cowlib master

DOC_DEPS = asciideck

TEST_DEPS = $(if $(CI_ERLANG_MK),ci.erlang.mk) ct_helper cowboy ranch
dep_ct_helper = git https://github.com/extend/ct_helper.git master
TEST_DEPS = $(if $(CI_ERLANG_MK),ci.erlang.mk) ct_helper cowboy ranch jsx
dep_ct_helper = git https://github.com/ninenines/ct_helper.git master
dep_cowboy_commit = 2.9.0
dep_ranch_commit = 2.0.0

Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{deps, [
{cowlib,".*",{git,"https://github.com/ninenines/cowlib","2.11.0"}}
{cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}}
]}.
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard]}.
2 changes: 2 additions & 0 deletions src/gun_cookies.erl
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ session_gc({Mod, State0}) ->
%% @todo The given URI must be normalized.
-spec set_cookie(Store, uri_string:uri_map(), binary(), binary(), cow_cookie:cookie_attrs())
-> {ok, Store} | {error, any()} when Store::store().
set_cookie(_, _, Name, Value, _) when byte_size(Name) + byte_size(Value) > 4096 ->
{error, larger_than_4096_bytes};
set_cookie(Store, URI=#{host := Host}, Name, Value, Attrs) ->
%% This is where we would add a feature to block cookies (like a blacklist).
CurrentTime = erlang:universaltime(),
Expand Down
8 changes: 7 additions & 1 deletion test/handlers/cookie_set_h.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ set_cookie_list(Req=#{qs := <<"prefix">>}) ->
set_cookie_list(#{qs := <<"secure_http">>}) ->
[<<"secure_from_nonsecure_http=1; Secure; Path=/">>];
set_cookie_list(#{qs := <<"secure_https">>}) ->
[<<"secure_from_secure_http=1; Secure; Path=/">>].
[<<"secure_from_secure_http=1; Secure; Path=/">>];
set_cookie_list(Req=#{qs := <<"ttb=",_/bits>>}) ->
#{ttb := SetCookies} = cowboy_req:match_qs([ttb], Req),
case binary_to_term(SetCookies) of
List when is_list(List) -> List;
Bin -> [Bin]
end.
Loading

0 comments on commit 180ce23

Please sign in to comment.