diff options
| author | jonathan vanasco <jonathan@2xlp.com> | 2019-12-19 14:43:32 -0500 |
|---|---|---|
| committer | jonathan vanasco <jonathan@2xlp.com> | 2019-12-19 14:43:32 -0500 |
| commit | 549bd5ad763cc8b3d24f82301fb5b1960c378419 (patch) | |
| tree | c3d78539a2dc5a5405bb17797a5e698b0e258dec /tests | |
| parent | 43776f35d1d00a31c388c4d9da399dc0fd8aaa63 (diff) | |
| download | webob-549bd5ad763cc8b3d24f82301fb5b1960c378419.tar.gz | |
disable validating the SameSite value, if/when the cookie spec changes again
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_cookies.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_cookies.py b/tests/test_cookies.py index 6f0bc15..1262001 100644 --- a/tests/test_cookies.py +++ b/tests/test_cookies.py @@ -122,6 +122,36 @@ def test_cookie_samesite_none_not_secure(): with pytest.raises(ValueError): c.serialize() +def test_cookie_samesite_future(): + # first default + c = cookies.Cookie() + with pytest.raises(ValueError) as excinfo: + c[b"foo"] = b"bar" + c[b"foo"].samesite = b"Future" + c.serialize() + assert excinfo.value.args[0] == "SameSite must be 'strict', 'lax', or 'none'" + + try: + # disable validation so future args pass + cookies.SAMESITE_VALIDATION = False + c = cookies.Cookie() + c[b"foo"] = b"bar" + c[b"foo"].samesite = b"Future" + assert c.serialize() == "foo=bar; SameSite=Future" + + # reset to the default behavior pass + cookies.SAMESITE_VALIDATION = True + c = cookies.Cookie() + with pytest.raises(ValueError) as excinfo: + c[b"foo"] = b"bar" + c[b"foo"].samesite = b"Future" + c.serialize() + assert excinfo.value.args[0] == "SameSite must be 'strict', 'lax', or 'none'" + + except Exception as exc: + cookies.SAMESITE_VALIDATION = True + raise + def test_cookie_reserved_keys(): c = cookies.Cookie("dismiss-top=6; CP=null*; $version=42; a=42") |
