diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2011-01-26 14:52:03 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2011-01-26 14:52:03 +1300 |
commit | 29d800767802ffc17c3577aaebfaf59221e0fb7e (patch) | |
tree | caa6da763476c7e9384c7eb0a77062814eb37980 /test | |
parent | 7983dbb26a023db149a6e3e91f19fc7171680534 (diff) | |
download | mitmproxy-29d800767802ffc17c3577aaebfaf59221e0fb7e.tar.gz mitmproxy-29d800767802ffc17c3577aaebfaf59221e0fb7e.tar.bz2 mitmproxy-29d800767802ffc17c3577aaebfaf59221e0fb7e.zip |
Add serialization hooks to flows and flow component objects.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_console.py | 9 | ||||
-rw-r--r-- | test/test_proxy.py | 27 | ||||
-rw-r--r-- | test/test_utils.py | 15 |
3 files changed, 51 insertions, 0 deletions
diff --git a/test/test_console.py b/test/test_console.py index cda61bd5..399cc485 100644 --- a/test/test_console.py +++ b/test/test_console.py @@ -196,6 +196,15 @@ class uFlow(libpry.AutoTree): f.backup() f.revert() + def test_getset_state(self): + f = tflow() + state = f.get_state() + assert f == console.ConsoleFlow.from_state(state) + f.response = tresp() + f.request = f.response.request + state = f.get_state() + assert f == console.ConsoleFlow.from_state(state) + def test_simple(self): f = tflow() assert f.get_text() diff --git a/test/test_proxy.py b/test/test_proxy.py index 90cfbbfb..ea1c56aa 100644 --- a/test/test_proxy.py +++ b/test/test_proxy.py @@ -225,6 +225,14 @@ class uRequest(libpry.AutoTree): assert r.short() assert r.assemble() + def test_getset_state(self): + h = utils.Headers() + h["test"] = ["test"] + c = proxy.BrowserConnection("addr", 2222) + r = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") + state = r.get_state() + assert proxy.Request.from_state(state) == r + class uResponse(libpry.AutoTree): def test_simple(self): @@ -236,6 +244,24 @@ class uResponse(libpry.AutoTree): assert resp.short() assert resp.assemble() + def test_getset_state(self): + h = utils.Headers() + h["test"] = ["test"] + c = proxy.BrowserConnection("addr", 2222) + r = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") + req = proxy.Request(c, "host", 22, "https", "GET", "/", h, "content") + resp = proxy.Response(req, 200, "HTTP", "msg", h.copy(), "content") + + state = resp.get_state() + assert proxy.Response.from_state(req, state) == resp + + +class uError(libpry.AutoTree): + def test_getset_state(self): + e = proxy.Error(None, "Error") + state = e.get_state() + assert proxy.Error.from_state(state) == e + class uProxyError(libpry.AutoTree): def test_simple(self): @@ -252,6 +278,7 @@ tests = [ uConfig(), u_parse_proxy_request(), u_parse_url(), + uError(), _TestServers(), [ uSanity(), uProxy(), diff --git a/test/test_utils.py b/test/test_utils.py index 8a4da968..cd435005 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -102,6 +102,14 @@ class uMultiDict(libpry.AutoTree): assert ("foo", 2) in l assert ("bar", 3) in l + def test_getset_state(self): + self.md.append("foo", 1) + self.md.append("foo", 2) + self.md.append("bar", 3) + state = self.md.get_state() + nd = utils.MultiDict.from_state(state) + assert nd == self.md + class uHeaders(libpry.AutoTree): def setUp(self): @@ -176,6 +184,13 @@ class uHeaders(libpry.AutoTree): assert h.match_re("two: due") assert not h.match_re("nonono") + def test_getset_state(self): + self.hd.append("foo", 1) + self.hd.append("foo", 2) + self.hd.append("bar", 3) + state = self.hd.get_state() + nd = utils.Headers.from_state(state) + assert nd == self.hd class uisStringLike(libpry.AutoTree): |