aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2011-03-20 18:52:16 +1300
committerAldo Cortesi <aldo@nullcube.com>2011-03-20 18:52:16 +1300
commitc0bd1a39e4f717854b424a9c2b86772fbafa843a (patch)
treef5290db49f7a3c29ff9b0857b919da0bbf5ee219
parentc726519e73761e5df3a20a1a92c1655497dd49c0 (diff)
downloadmitmproxy-c0bd1a39e4f717854b424a9c2b86772fbafa843a.tar.gz
mitmproxy-c0bd1a39e4f717854b424a9c2b86772fbafa843a.tar.bz2
mitmproxy-c0bd1a39e4f717854b424a9c2b86772fbafa843a.zip
unit test coverage ++
-rw-r--r--libmproxy/proxy.py13
-rw-r--r--test/test_cmdline.py5
-rw-r--r--test/test_console.py2
-rw-r--r--test/test_dump.py2
-rw-r--r--test/test_proxy.py18
5 files changed, 27 insertions, 13 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index e9561848..3f81096d 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -163,9 +163,6 @@ class Request(controller.Msg):
else:
return True
- def is_cached(self):
- return False
-
def load_state(self, state):
if state["client_conn"]:
if self.client_conn:
@@ -241,9 +238,6 @@ class Request(controller.Msg):
def is_response(self):
return False
- def assemble_proxy(self):
- return self.assemble(True)
-
def assemble(self, _proxy = False):
"""
Assembles the request for transmission to the server. We make some
@@ -278,7 +272,6 @@ class Response(controller.Msg):
self.code, self.msg = code, msg
self.headers, self.content = headers, content
self.timestamp = timestamp or utils.timestamp()
- self.cached = False
controller.Msg.__init__(self)
self.replay = False
@@ -304,9 +297,6 @@ class Response(controller.Msg):
del i["expires"]
return c.output(header="").strip()
- def __hash__(self):
- return id(self)
-
def refresh(self, now=None):
"""
This fairly complex and heuristic function refreshes a server
@@ -379,9 +369,6 @@ class Response(controller.Msg):
def is_response(self):
return True
- def is_cached(self):
- return self.cached
-
def assemble(self):
"""
Assembles the response for transmission to the client. We make some
diff --git a/test/test_cmdline.py b/test/test_cmdline.py
index 799e0e24..dc93640f 100644
--- a/test/test_cmdline.py
+++ b/test/test_cmdline.py
@@ -12,13 +12,18 @@ class uAll(libpry.AutoTree):
assert cmdline.get_common_options(opts)
opts.stickycookie_all = True
+ opts.stickyauth_all = True
v = cmdline.get_common_options(opts)
assert v["stickycookie"] == ".*"
+ assert v["stickyauth"] == ".*"
opts.stickycookie_all = False
+ opts.stickyauth_all = False
opts.stickycookie_filt = "foo"
+ opts.stickyauth_filt = "foo"
v = cmdline.get_common_options(opts)
assert v["stickycookie"] == "foo"
+ assert v["stickyauth"] == "foo"
diff --git a/test/test_console.py b/test/test_console.py
index 8b1e6d7c..15a2d299 100644
--- a/test/test_console.py
+++ b/test/test_console.py
@@ -39,6 +39,8 @@ class uState(libpry.AutoTree):
assert c.get_focus() == (f, 0)
c.set_focus(-1)
assert c.get_focus() == (f, 0)
+ c.set_focus(2)
+ assert c.get_focus() == (f2, 1)
c.delete_flow(f2)
assert c.get_focus() == (f, 0)
diff --git a/test/test_dump.py b/test/test_dump.py
index 7e4e0aa1..f860d1e0 100644
--- a/test/test_dump.py
+++ b/test/test_dump.py
@@ -121,6 +121,8 @@ class uDumpMaster(libpry.AutoTree):
def test_stickycookie(self):
ret = self._dummy_cycle(None, "", stickycookie = ".*")
+ def test_stickyauth(self):
+ ret = self._dummy_cycle(None, "", stickyauth = ".*")
diff --git a/test/test_proxy.py b/test/test_proxy.py
index 82d2dbec..46235e97 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -95,6 +95,9 @@ class uRequest(libpry.AutoTree):
assert r.url() == u
assert r.assemble()
+ r2 = r.copy()
+ assert r == r2
+
def test_anticache(self):
h = utils.Headers()
r = proxy.Request(None, "host", 22, "https", "GET", "/", h, "content")
@@ -121,6 +124,10 @@ class uRequest(libpry.AutoTree):
r.load_state(r2.get_state())
assert r == r2
+ r2.client_conn = None
+ r.load_state(r2.get_state())
+ assert not r.client_conn
+
class uResponse(libpry.AutoTree):
def test_simple(self):
@@ -131,6 +138,9 @@ class uResponse(libpry.AutoTree):
resp = proxy.Response(req, 200, "msg", h.copy(), "content")
assert resp.assemble()
+ resp2 = resp.copy()
+ assert resp2 == resp
+
def test_refresh(self):
r = tutils.tresp()
n = time.time()
@@ -190,6 +200,10 @@ class uError(libpry.AutoTree):
assert e == e2
+ e3 = e.copy()
+ assert e3 == e
+
+
class uProxyError(libpry.AutoTree):
def test_simple(self):
p = proxy.ProxyError(111, "msg")
@@ -208,6 +222,10 @@ class uClientConnect(libpry.AutoTree):
assert c == c2
+ c3 = c.copy()
+ assert c3 == c
+
+
tests = [
uProxyError(),
uRequest(),