aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/net/test_tcp.py34
-rw-r--r--test/mitmproxy/net/test_tls.py38
2 files changed, 38 insertions, 34 deletions
diff --git a/test/mitmproxy/net/test_tcp.py b/test/mitmproxy/net/test_tcp.py
index 3345840e..f0e8b776 100644
--- a/test/mitmproxy/net/test_tcp.py
+++ b/test/mitmproxy/net/test_tcp.py
@@ -789,40 +789,6 @@ class TestPeekSSL(TestPeek):
return conn.pop()
-class TestSSLKeyLogger(tservers.ServerTestBase):
- handler = EchoHandler
- ssl = dict(
- cipher_list="AES256-SHA"
- )
-
- def test_log(self, tmpdir):
- testval = b"echo!\n"
- _logfun = tcp.log_ssl_key
-
- logfile = str(tmpdir.join("foo", "bar", "logfile"))
- tcp.log_ssl_key = tcp.SSLKeyLogger(logfile)
-
- c = tcp.TCPClient(("127.0.0.1", self.port))
- with c.connect():
- c.convert_to_ssl()
- c.wfile.write(testval)
- c.wfile.flush()
- assert c.rfile.readline() == testval
- c.finish()
-
- tcp.log_ssl_key.close()
- with open(logfile, "rb") as f:
- assert f.read().count(b"CLIENT_RANDOM") == 2
-
- tcp.log_ssl_key = _logfun
-
- def test_create_logfun(self):
- assert isinstance(
- tcp.SSLKeyLogger.create_logfun("test"),
- tcp.SSLKeyLogger)
- assert not tcp.SSLKeyLogger.create_logfun(False)
-
-
class TestSSLInvalid(tservers.ServerTestBase):
handler = EchoHandler
ssl = True
diff --git a/test/mitmproxy/net/test_tls.py b/test/mitmproxy/net/test_tls.py
new file mode 100644
index 00000000..473163aa
--- /dev/null
+++ b/test/mitmproxy/net/test_tls.py
@@ -0,0 +1,38 @@
+from mitmproxy.net import tls
+from mitmproxy.net.tcp import TCPClient
+from test.mitmproxy.net.test_tcp import EchoHandler
+from . import tservers
+
+
+class TestSSLKeyLogger(tservers.ServerTestBase):
+ handler = EchoHandler
+ ssl = dict(
+ cipher_list="AES256-SHA"
+ )
+
+ def test_log(self, tmpdir):
+ testval = b"echo!\n"
+ _logfun = tls.log_master_secret
+
+ logfile = str(tmpdir.join("foo", "bar", "logfile"))
+ tls.log_master_secret = tls.MasterSecretLogger(logfile)
+
+ c = TCPClient(("127.0.0.1", self.port))
+ with c.connect():
+ c.convert_to_ssl()
+ c.wfile.write(testval)
+ c.wfile.flush()
+ assert c.rfile.readline() == testval
+ c.finish()
+
+ tls.log_master_secret.close()
+ with open(logfile, "rb") as f:
+ assert f.read().count(b"CLIENT_RANDOM") == 2
+
+ tls.log_master_secret = _logfun
+
+ def test_create_logfun(self):
+ assert isinstance(
+ tls.MasterSecretLogger.create_logfun("test"),
+ tls.MasterSecretLogger)
+ assert not tls.MasterSecretLogger.create_logfun(False)