diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2013-02-23 21:59:25 +1300 | 
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2013-02-23 21:59:25 +1300 | 
| commit | 05e4d4468ec372adb73649e6980c525a185e9c07 (patch) | |
| tree | 158727e939713e7e5378362502699f886b40bc10 /test/test_server.py | |
| parent | 269780c57780d155c4d8bd95fcc2af2104effa5b (diff) | |
| download | mitmproxy-05e4d4468ec372adb73649e6980c525a185e9c07.tar.gz mitmproxy-05e4d4468ec372adb73649e6980c525a185e9c07.tar.bz2 mitmproxy-05e4d4468ec372adb73649e6980c525a185e9c07.zip | |
Test request and response kill functionality.
Diffstat (limited to 'test/test_server.py')
| -rw-r--r-- | test/test_server.py | 32 | 
1 files changed, 31 insertions, 1 deletions
| diff --git a/test/test_server.py b/test/test_server.py index 5cba891c..8aefa4b8 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -2,7 +2,7 @@ import socket, time  from netlib import tcp  from libpathod import pathoc  import tutils, tservers -from libmproxy import flow +from libmproxy import flow, proxy  """      Note that the choice of response code in these tests matters more than you @@ -147,6 +147,7 @@ class TestProxy(tservers.HTTPProxTest):          assert request.timestamp_end - request.timestamp_start <= 0.1 +  class MasterFakeResponse(tservers.TestMaster):      def handle_request(self, m):          resp = tutils.tresp() @@ -160,3 +161,32 @@ class TestFakeResponse(tservers.HTTPProxTest):          f = self.pathod("200")          assert "header_response" in f.headers.keys() + + +class MasterKillRequest(tservers.TestMaster): +    def handle_request(self, m): +        m.reply(proxy.KILL) + + +class TestKillRequest(tservers.HTTPProxTest): +    masterclass = MasterKillRequest +    def test_kill(self): +        p = self.pathoc() +        tutils.raises("empty reply", self.pathod, "200") +        # Nothing should have hit the server +        assert not self.last_log() + + +class MasterKillResponse(tservers.TestMaster): +    def handle_response(self, m): +        m.reply(proxy.KILL) + + +class TestKillResponse(tservers.HTTPProxTest): +    masterclass = MasterKillResponse +    def test_kill(self): +        p = self.pathoc() +        tutils.raises("empty reply", self.pathod, "200") +        # The server should have seen a request +        assert self.last_log() + | 
