aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-08-15 10:39:38 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-08-15 12:00:23 +0530
commitec0bae35c538d8b4fde1c5b46b162c19783ca1a7 (patch)
treeadf9f112b9e11b71949bc88c3a580db0855b9a14 /test
parentb9426fcec178395bf9c054f616ab6b23c5b2408a (diff)
downloadmitmproxy-ec0bae35c538d8b4fde1c5b46b162c19783ca1a7.tar.gz
mitmproxy-ec0bae35c538d8b4fde1c5b46b162c19783ca1a7.tar.bz2
mitmproxy-ec0bae35c538d8b4fde1c5b46b162c19783ca1a7.zip
Assert cookie groups explicitly rather than just the length
Diffstat (limited to 'test')
-rw-r--r--test/netlib/http/test_cookies.py56
1 files changed, 40 insertions, 16 deletions
diff --git a/test/netlib/http/test_cookies.py b/test/netlib/http/test_cookies.py
index 828029c6..56e0b21b 100644
--- a/test/netlib/http/test_cookies.py
+++ b/test/netlib/http/test_cookies.py
@@ -289,20 +289,44 @@ def test_is_expired():
def test_group_cookies():
- def group(cookie):
- return cookies.group_cookies(cookies.parse_cookie_header(c))
-
- c = "one=uno; foo=bar; foo=baz"
- assert len(group(c)) == 3
-
- c = "one=uno; Path=/; foo=bar; Max-Age=0; foo=baz; expires=24-08-1993"
- assert len(group(c)) == 3
-
- c = "one=uno;"
- assert len(group(c)) == 1
-
- c = "one=uno; Path=/; Max-Age=0; Expires=24-08-1993"
- assert len(group(c)) == 1
+ CA = cookies.CookieAttrs
+ groups = [
+ [
+ "one=uno; foo=bar; foo=baz",
+ [
+ ('one', 'uno', CA([])),
+ ('foo', 'bar', CA([])),
+ ('foo', 'baz', CA([]))
+ ]
+ ],
+ [
+ "one=uno; Path=/; foo=bar; Max-Age=0; foo=baz; expires=24-08-1993",
+ [
+ ('one', 'uno', CA([('Path', '/')])),
+ ('foo', 'bar', CA([('Max-Age', '0')])),
+ ('foo', 'baz', CA([('expires', '24-08-1993')]))
+ ]
+ ],
+ [
+ "one=uno;",
+ [
+ ('one', 'uno', CA([]))
+ ]
+ ],
+ [
+ "one=uno; Path=/; Max-Age=0; Expires=24-08-1993",
+ [
+ ('one', 'uno', CA([('Path', '/'), ('Max-Age', '0'), ('Expires', '24-08-1993')]))
+ ]
+ ],
+ [
+ "path=val; Path=/",
+ [
+ ('path', 'val', CA([('Path', '/')]))
+ ]
+ ]
+ ]
- c = "path=val; Path=/"
- assert group(c) == [("path", "val", cookies.CookieAttrs([("Path", "/")]))]
+ for c, expected in groups:
+ observed = cookies.group_cookies(cookies.parse_cookie_header(c))
+ assert observed == expected