summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarcin RaczyƄski <marc1n@users.noreply.github.com>2019-11-29 08:52:24 +0100
committerGitHub <noreply@github.com>2019-11-29 08:52:24 +0100
commit43f4b3fbab0a7fa97d729e01ea3e8719fb672012 (patch)
tree68d11ea9f03ecce7f0b60c34ee99752468860425 /tests
parent08c42635faf47ab921d00e2c68478f655d27bd62 (diff)
downloadwebob-43f4b3fbab0a7fa97d729e01ea3e8719fb672012.tar.gz
#406 Added teststs for samesite='None'
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cookies.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/test_cookies.py b/tests/test_cookies.py
index a375e25..f891a80 100644
--- a/tests/test_cookies.py
+++ b/tests/test_cookies.py
@@ -106,6 +106,13 @@ def test_cookie_samesite_lax():
c[b"foo"].samesite = b"Lax"
assert c.serialize() == "foo=bar; SameSite=Lax"
+
+def test_cookie_samesite_none():
+ c = cookies.Cookie()
+ c[b"foo"] = b"bar"
+ c[b"foo"].samesite = b"None"
+ assert c.serialize() == "foo=bar; SameSite=None"
+
def test_cookie_reserved_keys():
c = cookies.Cookie("dismiss-top=6; CP=null*; $version=42; a=42")
@@ -135,6 +142,7 @@ def test_serialize_cookie_date():
def test_serialize_samesite():
assert cookies.serialize_samesite(b"Lax") == b"Lax"
assert cookies.serialize_samesite(b"Strict") == b"Strict"
+ assert cookies.serialize_samesite(b"None") == b"None"
with pytest.raises(ValueError):
cookies.serialize_samesite(b"SomethingElse")
@@ -483,7 +491,7 @@ class TestCookieMakeCookie(object):
assert "test_cookie=value" in cookie
assert "Path=/foo/bar/baz" in cookie
- @pytest.mark.parametrize("samesite", ["Strict", "Lax"])
+ @pytest.mark.parametrize("samesite", ["Strict", "Lax", "None"])
def test_make_cookie_samesite(self, samesite):
cookie = self.makeOne("test_cookie", "value", samesite=samesite)
@@ -708,7 +716,7 @@ class TestSignedCookieProfile(CommonCookieProfile):
for cookie in ret:
assert "; HttpOnly" in cookie[1]
- @pytest.mark.parametrize("samesite", [b"Strict", b"Lax"])
+ @pytest.mark.parametrize("samesite", [b"Strict", b"Lax", b"None"])
def test_with_samesite_bytes(self, samesite):
cookie = self.makeOne(samesite=samesite)
ret = cookie.get_headers("test")
@@ -716,7 +724,7 @@ class TestSignedCookieProfile(CommonCookieProfile):
for cookie in ret:
assert "; SameSite=" + samesite.decode("ascii") in cookie[1]
- @pytest.mark.parametrize("samesite", ["Strict", "Lax"])
+ @pytest.mark.parametrize("samesite", ["Strict", "Lax", "None"])
def test_with_samesite(self, samesite):
cookie = self.makeOne(samesite=samesite)
ret = cookie.get_headers("test")