aboutsummaryrefslogtreecommitdiffstats
path: root/test/netlib/http/test_cookies.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-07-09 13:20:45 -0700
committerGitHub <noreply@github.com>2016-07-09 13:20:45 -0700
commitdc6266e08e58a2ec7a6660e125ddc585916f4dcd (patch)
tree967ae4b327074a93cb37d87876cd91c4cc976a5c /test/netlib/http/test_cookies.py
parent7efd63f94c5871ab6f93a1e39355cb37d9d6e107 (diff)
parent7eade1ef7c24b98567c1657973290aa5377b2719 (diff)
downloadmitmproxy-dc6266e08e58a2ec7a6660e125ddc585916f4dcd.tar.gz
mitmproxy-dc6266e08e58a2ec7a6660e125ddc585916f4dcd.tar.bz2
mitmproxy-dc6266e08e58a2ec7a6660e125ddc585916f4dcd.zip
Merge pull request #1324 from dufferzafar/sticky-cookies
Delete stickycookies when told by the server
Diffstat (limited to 'test/netlib/http/test_cookies.py')
-rw-r--r--test/netlib/http/test_cookies.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/netlib/http/test_cookies.py b/test/netlib/http/test_cookies.py
index 83b85656..17e21b94 100644
--- a/test/netlib/http/test_cookies.py
+++ b/test/netlib/http/test_cookies.py
@@ -245,3 +245,24 @@ def test_refresh_cookie():
assert cookies.refresh_set_cookie_header(c, 0)
c = "foo/bar=bla"
assert cookies.refresh_set_cookie_header(c, 0)
+
+
+def test_is_expired():
+ CA = cookies.CookieAttrs
+
+ # A cookie can be expired
+ # by setting the expire time in the past
+ assert cookies.is_expired(CA([("Expires", "Thu, 01-Jan-1970 00:00:00 GMT")]))
+
+ # or by setting Max-Age to 0
+ assert cookies.is_expired(CA([("Max-Age", "0")]))
+
+ # or both
+ assert cookies.is_expired(CA([("Expires", "Thu, 01-Jan-1970 00:00:00 GMT"), ("Max-Age", "0")]))
+
+ assert not cookies.is_expired(CA([("Expires", "Thu, 24-Aug-2063 00:00:00 GMT")]))
+ assert not cookies.is_expired(CA([("Max-Age", "1")]))
+ assert not cookies.is_expired(CA([("Expires", "Thu, 15-Jul-2068 00:00:00 GMT"), ("Max-Age", "1")]))
+
+ assert not cookies.is_expired(CA([("Max-Age", "nan")]))
+ assert not cookies.is_expired(CA([("Expires", "false")]))