diff options
author | Maximilian Hils <git@maximilianhils.com> | 2014-02-07 07:08:59 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2014-02-07 07:08:59 +0100 |
commit | 545fc2506bdcb4a17705db9bc708d22613ace039 (patch) | |
tree | 2157bae5fab45ec66b9630ac47a98a9e1e0fdfa3 /test/test_protocol_http.py | |
parent | 9526c5d56570652400929cc33f8fb36f361eecd6 (diff) | |
download | mitmproxy-545fc2506bdcb4a17705db9bc708d22613ace039.tar.gz mitmproxy-545fc2506bdcb4a17705db9bc708d22613ace039.tar.bz2 mitmproxy-545fc2506bdcb4a17705db9bc708d22613ace039.zip |
Achievement Unlocked: Proxy Chain
Diffstat (limited to 'test/test_protocol_http.py')
-rw-r--r-- | test/test_protocol_http.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index bf569fb7..76d192de 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -1,7 +1,7 @@ from libmproxy import proxy # FIXME: Remove from libmproxy.protocol.http import * from cStringIO import StringIO -import tutils +import tutils, tservers def test_HttpAuthenticationError(): @@ -84,3 +84,30 @@ class TestHTTPResponse: assert r.code == 200 assert r.content == "" tutils.raises("Invalid server response: 'content", HTTPResponse.from_stream, s, "GET") + + +class TestProxyChaining(tservers.HTTPChainProxyTest): + def test_all(self): + self.chain[1].tmaster.replacehooks.add("~q", "foo", "bar") # replace in request + self.chain[0].tmaster.replacehooks.add("~q", "foo", "oh noes!") + self.proxy.tmaster.replacehooks.add("~q", "bar", "baz") + self.chain[0].tmaster.replacehooks.add("~s", "baz", "ORLY") # replace in response + + p = self.pathoc() + req = p.request("get:'%s/p/418:b\"foo\"'" % self.server.urlbase) + assert req.content == "ORLY" + assert req.status_code == 418 + + self.chain[0].tmaster.replacehooks.clear() + self.chain[1].tmaster.replacehooks.clear() + self.proxy.tmaster.replacehooks.clear() + + +class TestProxyChainingSSL(tservers.HTTPChainProxyTest): + ssl = True + + def test_full(self): + p = self.pathoc() + req = p.request("get:'/p/418:b@100'") + assert len(req.content) == 100 + assert req.status_code == 418
\ No newline at end of file |