diff options
author | Shadab Zafar <dufferzafar0@gmail.com> | 2016-07-10 01:06:50 +0530 |
---|---|---|
committer | Shadab Zafar <dufferzafar0@gmail.com> | 2016-07-10 01:06:50 +0530 |
commit | 39f51084003b93a2e9868f7a56acfc29c12ed79e (patch) | |
tree | f2c3c88baf77f843a492e938d6f612cdd9ff6f0e /test/netlib/http | |
parent | c92992f03bba6553ec39fc42e6716beb942967e3 (diff) | |
download | mitmproxy-39f51084003b93a2e9868f7a56acfc29c12ed79e.tar.gz mitmproxy-39f51084003b93a2e9868f7a56acfc29c12ed79e.tar.bz2 mitmproxy-39f51084003b93a2e9868f7a56acfc29c12ed79e.zip |
Test cookies.is_expired separately
Diffstat (limited to 'test/netlib/http')
-rw-r--r-- | test/netlib/http/test_cookies.py | 21 |
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")])) |