aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_pathoc.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2014-03-02 19:04:56 +1300
committerAldo Cortesi <aldo@nullcube.com>2014-03-02 19:04:56 +1300
commit53334e437c6c9e7df0a6e979dbe255ab27d8e2c9 (patch)
tree88897add71d5d1c3f40b826fe31943dba73be3cd /test/test_pathoc.py
parent0177eb899a87995d0faaed8a836904cac7f844ce (diff)
downloadmitmproxy-53334e437c6c9e7df0a6e979dbe255ab27d8e2c9.tar.gz
mitmproxy-53334e437c6c9e7df0a6e979dbe255ab27d8e2c9.tar.bz2
mitmproxy-53334e437c6c9e7df0a6e979dbe255ab27d8e2c9.zip
pathoc -S dumps information on the remote SSL certificate chain
Diffstat (limited to 'test/test_pathoc.py')
-rw-r--r--test/test_pathoc.py47
1 files changed, 28 insertions, 19 deletions
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index 5d676d25..3eeec9f6 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -34,6 +34,28 @@ class _TestDaemon:
r = c.request("get:/api/info")
assert tuple(json.loads(r.content)["version"]) == version.IVERSION
+ def tval(self, requests, showreq=False, showresp=False, explain=False,
+ showssl=False, hexdump=False, timeout=None, ignorecodes=None,
+ ignoretimeout=None):
+ c = pathoc.Pathoc(("127.0.0.1", self.d.port), ssl=self.ssl)
+ c.connect()
+ if timeout:
+ c.settimeout(timeout)
+ s = cStringIO.StringIO()
+ for i in requests:
+ c.print_request(
+ i,
+ showreq = showreq,
+ showresp = showresp,
+ explain = explain,
+ showssl = showssl,
+ hexdump = hexdump,
+ ignorecodes = ignorecodes,
+ ignoretimeout = ignoretimeout,
+ fp = s
+ )
+ return s.getvalue()
+
class TestDaemonSSL(_TestDaemon):
ssl = True
@@ -50,6 +72,9 @@ class TestDaemonSSL(_TestDaemon):
d = json.loads(r.content)
assert d["log"][0]["request"]["sni"] == "foobar.com"
+ def test_showssl(self):
+ assert "certificate chain" in self.tval(["get:/p/200"], showssl=True)
+
def test_clientcert(self):
c = pathoc.Pathoc(
("127.0.0.1", self.d.port),
@@ -65,29 +90,13 @@ class TestDaemonSSL(_TestDaemon):
class TestDaemon(_TestDaemon):
ssl = False
- def tval(self, requests, showreq=False, showresp=False, explain=False, hexdump=False, timeout=None, ignorecodes=None, ignoretimeout=None):
- c = pathoc.Pathoc(("127.0.0.1", self.d.port))
- c.connect()
- if timeout:
- c.settimeout(timeout)
- s = cStringIO.StringIO()
- for i in requests:
- c.print_request(
- i,
- showreq = showreq,
- showresp = showresp,
- explain = explain,
- hexdump = hexdump,
- ignorecodes = ignorecodes,
- ignoretimeout = ignoretimeout,
- fp = s
- )
- return s.getvalue()
-
def test_ssl_error(self):
c = pathoc.Pathoc(("127.0.0.1", self.d.port), ssl = True)
tutils.raises("ssl handshake", c.connect)
+ def test_showssl(self):
+ assert not "certificate chain" in self.tval(["get:/p/200"], showssl=True)
+
def test_ignorecodes(self):
assert "200" in self.tval(["get:'/p/200:b@1'"])
assert "200" not in self.tval(["get:'/p/200:b@1'"], ignorecodes=[200])