aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-20 13:12:32 +0200
committerLoïc Hoguin <[email protected]>2020-04-20 13:12:32 +0200
commit921c47146b2d9567eac7e9a4d2ccc60fffd4f327 (patch)
tree49f093b3b052ea1b134d08289cf917c6549acb3b
parentc8dc7d2da7b40226a73584feed307467d74edbf8 (diff)
downloadgun-921c47146b2d9567eac7e9a4d2ccc60fffd4f327.tar.gz
gun-921c47146b2d9567eac7e9a4d2ccc60fffd4f327.tar.bz2
gun-921c47146b2d9567eac7e9a4d2ccc60fffd4f327.zip
Update the WPT cookie tests
-rw-r--r--Makefile8
-rw-r--r--src/gun_cookies.erl26
-rw-r--r--test/wpt/cookies/chromium0009-expected1
-rw-r--r--test/wpt/cookies/chromium0010-expected1
-rw-r--r--test/wpt/cookies/chromium0012-expected1
-rw-r--r--test/wpt/cookies/mozilla0012-expected2
-rw-r--r--test/wpt/cookies/mozilla0014-expected1
-rw-r--r--test/wpt/cookies/mozilla0015-expected1
-rw-r--r--test/wpt/cookies/mozilla0016-expected1
-rw-r--r--test/wpt/cookies/mozilla0017-expected2
-rw-r--r--test/wpt/cookies/name0017-expected1
-rw-r--r--test/wpt/cookies/name0023-expected1
-rw-r--r--test/wpt/cookies/name0025-expected1
-rw-r--r--test/wpt/cookies/name0028-expected1
-rw-r--r--test/wpt/cookies/name0031-expected1
-rw-r--r--test/wpt/cookies/name0032-expected1
-rw-r--r--test/wpt/cookies/name0033-expected1
17 files changed, 26 insertions, 25 deletions
diff --git a/Makefile b/Makefile
index 105de1c..93c757f 100644
--- a/Makefile
+++ b/Makefile
@@ -111,6 +111,14 @@ gen: gen-idna | $(ERLANG_MK_TMP)
$(gen_verbose) wget -qO - $(GEN_URL) > $(GEN_DAT)
$(gen_verbose) $(call erlang,$(call gen.erl))
+# Automatically update the http-state files in test/wpt/cookies.
+
+update-cookie-tests:
+ $(verbose) rm -rf $(ERLANG_MK_TMP)/wpt
+ $(verbose) rm -f test/wpt/cookies/*
+ $(verbose) git clone https://github.com/web-platform-tests/wpt $(ERLANG_MK_TMP)/wpt
+ $(verbose) cp $(ERLANG_MK_TMP)/wpt/cookies/http-state/resources/test-files/* test/wpt/cookies/
+
# Prepare for the release.
prepare_tag:
diff --git a/src/gun_cookies.erl b/src/gun_cookies.erl
index ce951c6..ce33b49 100644
--- a/src/gun_cookies.erl
+++ b/src/gun_cookies.erl
@@ -407,23 +407,8 @@ wpt_http_state_test_files() ->
wpt_http_state_test_files(TestPath) ->
filelib:wildcard(TestPath ++ "wpt/cookies/*-test") -- [
TestPath ++ "wpt/cookies/attribute0023-test", %% Doesn't match the spec (path override).
- TestPath ++ "wpt/cookies/chromium0009-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/chromium0010-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/chromium0012-test", %% Doesn't match the spec (empty names).
TestPath ++ "wpt/cookies/disabled-chromium0020-test", %% Doesn't match the spec (empty names).
TestPath ++ "wpt/cookies/disabled-chromium0022-test", %% Nonsense.
- TestPath ++ "wpt/cookies/mozilla0012-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/mozilla0014-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/mozilla0015-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/mozilla0016-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/mozilla0017-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/name0017-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/name0023-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/name0025-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/name0028-test", %% Doesn't match the spec (empty names).
- TestPath ++ "wpt/cookies/name0031-test", %% Doesn't match the spec (name with quotes).
- TestPath ++ "wpt/cookies/name0032-test", %% Doesn't match the spec (name with quotes).
- TestPath ++ "wpt/cookies/name0033-test", %% Doesn't match the spec (empty names).
TestPath ++ "wpt/cookies/optional-domain0042-test" %% Doesn't match the spec (empty domain override).
].
@@ -464,17 +449,12 @@ wpt_http_state_test_() ->
{ok, <<"Cookie: ",CookiesBin0/bits>>} ->
%% We only care about the first line.
[CookiesBin, <<>>|_] = string:split(CookiesBin0, <<"\n">>, all),
- ExpectedCookies = cow_cookie:parse_cookie(CookiesBin),
- wpt_http_state_test_validate_cookies(Cookies, ExpectedCookies)
+ CookiesBin = iolist_to_binary(cow_cookie:cookie(
+ [{Name, Value} || #{name := Name, value := Value} <- Cookies])),
+ ok
end
end} || F <- TestFiles].
-wpt_http_state_test_validate_cookies([], []) ->
- ok;
-wpt_http_state_test_validate_cookies([Cookie|Tail], [{Name, Value}|ExpectedTail]) ->
- #{name := Name, value := Value} = Cookie,
- wpt_http_state_test_validate_cookies(Tail, ExpectedTail).
-
%% WPT: path/default
wpt_path_default_test() ->
URIMap = #{scheme => <<"http">>, host => <<?HOST>>, path => <<"/path/to/resource">>},
diff --git a/test/wpt/cookies/chromium0009-expected b/test/wpt/cookies/chromium0009-expected
index e69de29..d347326 100644
--- a/test/wpt/cookies/chromium0009-expected
+++ b/test/wpt/cookies/chromium0009-expected
@@ -0,0 +1 @@
+Cookie: BLAHHH
diff --git a/test/wpt/cookies/chromium0010-expected b/test/wpt/cookies/chromium0010-expected
index e69de29..21b4b84 100644
--- a/test/wpt/cookies/chromium0010-expected
+++ b/test/wpt/cookies/chromium0010-expected
@@ -0,0 +1 @@
+Cookie: "BLA\"HHH"
diff --git a/test/wpt/cookies/chromium0012-expected b/test/wpt/cookies/chromium0012-expected
index e69de29..7bed67c 100644
--- a/test/wpt/cookies/chromium0012-expected
+++ b/test/wpt/cookies/chromium0012-expected
@@ -0,0 +1 @@
+Cookie: ABC
diff --git a/test/wpt/cookies/mozilla0012-expected b/test/wpt/cookies/mozilla0012-expected
index 10e669a..eeba662 100644
--- a/test/wpt/cookies/mozilla0012-expected
+++ b/test/wpt/cookies/mozilla0012-expected
@@ -1 +1 @@
-Cookie: test="fubar! = foo
+Cookie: test="fubar! = foo; five
diff --git a/test/wpt/cookies/mozilla0014-expected b/test/wpt/cookies/mozilla0014-expected
index e69de29..fb53284 100644
--- a/test/wpt/cookies/mozilla0014-expected
+++ b/test/wpt/cookies/mozilla0014-expected
@@ -0,0 +1 @@
+Cookie: six
diff --git a/test/wpt/cookies/mozilla0015-expected b/test/wpt/cookies/mozilla0015-expected
index e69de29..42f58fd 100644
--- a/test/wpt/cookies/mozilla0015-expected
+++ b/test/wpt/cookies/mozilla0015-expected
@@ -0,0 +1 @@
+Cookie: seven
diff --git a/test/wpt/cookies/mozilla0016-expected b/test/wpt/cookies/mozilla0016-expected
index e69de29..1f8fc04 100644
--- a/test/wpt/cookies/mozilla0016-expected
+++ b/test/wpt/cookies/mozilla0016-expected
@@ -0,0 +1 @@
+Cookie: eight
diff --git a/test/wpt/cookies/mozilla0017-expected b/test/wpt/cookies/mozilla0017-expected
index fc9a249..599acb3 100644
--- a/test/wpt/cookies/mozilla0017-expected
+++ b/test/wpt/cookies/mozilla0017-expected
@@ -1 +1 @@
-Cookie: test=six
+Cookie: eight; test=six
diff --git a/test/wpt/cookies/name0017-expected b/test/wpt/cookies/name0017-expected
index e69de29..9652792 100644
--- a/test/wpt/cookies/name0017-expected
+++ b/test/wpt/cookies/name0017-expected
@@ -0,0 +1 @@
+Cookie: a=bar
diff --git a/test/wpt/cookies/name0023-expected b/test/wpt/cookies/name0023-expected
index e69de29..5ab2766 100644
--- a/test/wpt/cookies/name0023-expected
+++ b/test/wpt/cookies/name0023-expected
@@ -0,0 +1 @@
+Cookie: foo
diff --git a/test/wpt/cookies/name0025-expected b/test/wpt/cookies/name0025-expected
index e69de29..68c3859 100644
--- a/test/wpt/cookies/name0025-expected
+++ b/test/wpt/cookies/name0025-expected
@@ -0,0 +1 @@
+Cookie: ==a=bar
diff --git a/test/wpt/cookies/name0028-expected b/test/wpt/cookies/name0028-expected
index e69de29..f14f993 100644
--- a/test/wpt/cookies/name0028-expected
+++ b/test/wpt/cookies/name0028-expected
@@ -0,0 +1 @@
+Cookie: a
diff --git a/test/wpt/cookies/name0031-expected b/test/wpt/cookies/name0031-expected
index e69de29..0cd5a50 100644
--- a/test/wpt/cookies/name0031-expected
+++ b/test/wpt/cookies/name0031-expected
@@ -0,0 +1 @@
+Cookie: "foo
diff --git a/test/wpt/cookies/name0032-expected b/test/wpt/cookies/name0032-expected
index e69de29..f4f7f3f 100644
--- a/test/wpt/cookies/name0032-expected
+++ b/test/wpt/cookies/name0032-expected
@@ -0,0 +1 @@
+Cookie: "foo\"bar
diff --git a/test/wpt/cookies/name0033-expected b/test/wpt/cookies/name0033-expected
index e69de29..6e7762e 100644
--- a/test/wpt/cookies/name0033-expected
+++ b/test/wpt/cookies/name0033-expected
@@ -0,0 +1 @@
+Cookie: aaa