aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_protocol_http.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_protocol_http.py')
-rw-r--r--test/test_protocol_http.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py
index 23c3f469..08ed114c 100644
--- a/test/test_protocol_http.py
+++ b/test/test_protocol_http.py
@@ -1,6 +1,10 @@
+from cStringIO import StringIO
+
from mock import MagicMock
+
from libmproxy.protocol.http import *
-from cStringIO import StringIO
+from netlib import odict
+
import tutils, tservers
@@ -131,6 +135,41 @@ class TestHTTPRequest:
assert r.get_form_multipart.called
+ def test_get_cookies_none(self):
+ h = odict.ODictCaseless()
+ r = tutils.treq()
+ r.headers = h
+ assert r.get_cookies() is None
+
+ def test_get_cookies_single(self):
+ h = odict.ODictCaseless()
+ h["Cookie"] = ["cookiename=cookievalue"]
+ r = tutils.treq()
+ r.headers = h
+ result = r.get_cookies()
+ assert len(result)==1
+ assert result['cookiename']==('cookievalue',{})
+
+ def test_get_cookies_double(self):
+ h = odict.ODictCaseless()
+ h["Cookie"] = ["cookiename=cookievalue;othercookiename=othercookievalue"]
+ r = tutils.treq()
+ r.headers = h
+ result = r.get_cookies()
+ assert len(result)==2
+ assert result['cookiename']==('cookievalue',{})
+ assert result['othercookiename']==('othercookievalue',{})
+
+ def test_get_cookies_withequalsign(self):
+ h = odict.ODictCaseless()
+ h["Cookie"] = ["cookiename=coo=kievalue;othercookiename=othercookievalue"]
+ r = tutils.treq()
+ r.headers = h
+ result = r.get_cookies()
+ assert len(result)==2
+ assert result['cookiename']==('coo=kievalue',{})
+ assert result['othercookiename']==('othercookievalue',{})
+