aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-12-29 17:51:11 +0100
committerMaximilian Hils <git@maximilianhils.com>2015-12-29 17:51:11 +0100
commit7b093b46b6a8ce98fe3d55de81d9305d966dfcbf (patch)
tree6cfb22f7f433b5b4af4079e2e6724f6730ebceb0 /test
parent6391b05ef1b92585765eb77e352921ec61b65020 (diff)
parent09168e1274b0e33448811c39efa3fbdd2aeff756 (diff)
downloadmitmproxy-7b093b46b6a8ce98fe3d55de81d9305d966dfcbf.tar.gz
mitmproxy-7b093b46b6a8ce98fe3d55de81d9305d966dfcbf.tar.bz2
mitmproxy-7b093b46b6a8ce98fe3d55de81d9305d966dfcbf.zip
Merge pull request #870 from bazzinotti/master
[docs/libmproxy/test] Support single client-side cert file
Diffstat (limited to 'test')
-rw-r--r--test/test_proxy.py6
-rw-r--r--test/test_server.py24
-rw-r--r--test/tservers.py2
3 files changed, 23 insertions, 9 deletions
diff --git a/test/test_proxy.py b/test/test_proxy.py
index b3e7258a..b498c800 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -1,3 +1,4 @@
+import os
import mock
from OpenSSL import SSL
@@ -99,8 +100,11 @@ class TestProcessProxyOptions:
def test_client_certs(self):
with tutils.tmpdir() as cadir:
self.assert_noerr("--client-certs", cadir)
+ self.assert_noerr(
+ "--client-certs",
+ os.path.join(tutils.test_data.path("data/clientcert"), "client.pem"))
self.assert_err(
- "directory does not exist",
+ "path does not exist",
"--client-certs",
"nonexistent")
diff --git a/test/test_server.py b/test/test_server.py
index e48e46fe..85c766eb 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -1,3 +1,4 @@
+import os
import socket
import time
from OpenSSL import SSL
@@ -313,13 +314,24 @@ class TestHTTPAuth(tservers.HTTPProxTest):
class TestHTTPS(tservers.HTTPProxTest, CommonMixin, TcpMixin):
ssl = True
ssloptions = pathod.SSLOptions(request_client_cert=True)
- clientcerts = True
-
- def test_clientcert(self):
- f = self.pathod("304")
- assert f.status_code == 304
- assert self.server.last_log()["request"]["clientcert"]["keyinfo"]
+ def test_clientcert_file(self):
+ try:
+ self.config.clientcerts = os.path.join(
+ tutils.test_data.path("data/clientcert"), "client.pem")
+ f = self.pathod("304")
+ assert f.status_code == 304
+ assert self.server.last_log()["request"]["clientcert"]["keyinfo"]
+ finally:
+ self.config.clientcerts = None
+ def test_clientcert_dir(self):
+ try:
+ self.config.clientcerts = tutils.test_data.path("data/clientcert")
+ f = self.pathod("304")
+ assert f.status_code == 304
+ assert self.server.last_log()["request"]["clientcert"]["keyinfo"]
+ finally:
+ self.config.clientcerts = None
def test_error_post_connect(self):
p = self.pathoc()
assert p.request("get:/:i0,'invalid\r\n\r\n'").status_code == 400
diff --git a/test/tservers.py b/test/tservers.py
index 8e60df60..5963667b 100644
--- a/test/tservers.py
+++ b/test/tservers.py
@@ -83,7 +83,6 @@ class ProxTestBase(object):
# Test Configuration
ssl = None
ssloptions = False
- clientcerts = False
no_upstream_cert = False
authenticator = None
masterclass = TestMaster
@@ -130,7 +129,6 @@ class ProxTestBase(object):
no_upstream_cert = cls.no_upstream_cert,
cadir = cls.cadir,
authenticator = cls.authenticator,
- clientcerts = tutils.test_data.path("data/clientcert") if cls.clientcerts else None
)