aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_app.py4
-rw-r--r--test/test_console_contentview.py2
-rw-r--r--test/test_proxy.py14
-rw-r--r--test/test_server.py5
-rw-r--r--test/tservers.py13
5 files changed, 18 insertions, 20 deletions
diff --git a/test/test_app.py b/test/test_app.py
index f0eab7cc..52cd1ba6 100644
--- a/test/test_app.py
+++ b/test/test_app.py
@@ -9,11 +9,9 @@ class TestApp(tservers.HTTPProxTest):
assert self.app("/").status_code == 200
def test_cert(self):
- path = tutils.test_data.path("data/confdir/") + "mitmproxy-ca-cert."
with tutils.tmpdir() as d:
for ext in ["pem", "p12"]:
resp = self.app("/cert/%s" % ext)
assert resp.status_code == 200
- with open(path + ext, "rb") as f:
- assert resp.content == f.read()
+ assert resp.content
diff --git a/test/test_console_contentview.py b/test/test_console_contentview.py
index a878ad4e..0aabd2c5 100644
--- a/test/test_console_contentview.py
+++ b/test/test_console_contentview.py
@@ -120,7 +120,7 @@ class TestContentView:
def test_view_css(self):
v = cv.ViewCSS()
- with open('./test/data/1.css', 'r') as fp:
+ with open(tutils.test_data.path('data/1.css'), 'r') as fp:
fixture_1 = fp.read()
result = v([], 'a', 100)
diff --git a/test/test_proxy.py b/test/test_proxy.py
index 5ff00290..b15e3f84 100644
--- a/test/test_proxy.py
+++ b/test/test_proxy.py
@@ -70,13 +70,6 @@ class TestProcessProxyOptions:
def test_simple(self):
assert self.p()
- def test_certfile_keyfile(self):
- self.assert_noerr("--certfile", tutils.test_data.path("data/testkey.pem"))
- self.assert_err("does not exist", "--certfile", "nonexistent")
-
- self.assert_noerr("--keyfile", tutils.test_data.path("data/testkey.pem"))
- self.assert_err("does not exist", "--keyfile", "nonexistent")
-
def test_confdir(self):
with tutils.tmpdir() as confdir:
self.assert_noerr("--confdir", confdir)
@@ -93,11 +86,16 @@ class TestProcessProxyOptions:
self.assert_err("invalid reverse proxy", "-P", "reverse")
self.assert_noerr("-P", "http://localhost")
- def test_certs(self):
+ def test_client_certs(self):
with tutils.tmpdir() as confdir:
self.assert_noerr("--client-certs", confdir)
self.assert_err("directory does not exist", "--client-certs", "nonexistent")
+ def test_certs(self):
+ with tutils.tmpdir() as confdir:
+ self.assert_noerr("--cert", tutils.test_data.path("data/testkey.pem"))
+ self.assert_err("does not exist", "--cert", "nonexistent")
+
def test_auth(self):
p = self.assert_noerr("--nonanonymous")
assert p.authenticator
diff --git a/test/test_server.py b/test/test_server.py
index 2714ef52..ed21e75c 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -213,8 +213,9 @@ class TestHTTPSNoCommonName(tservers.HTTPProxTest):
"""
ssl = True
ssloptions=pathod.SSLOptions(
- certfile = tutils.test_data.path("data/no_common_name.pem"),
- keyfile = tutils.test_data.path("data/no_common_name.pem"),
+ certs = [
+ ("*", tutils.test_data.path("data/no_common_name.pem"))
+ ]
)
def test_http(self):
f = self.pathod("202")
diff --git a/test/tservers.py b/test/tservers.py
index 540cda60..3a6a610f 100644
--- a/test/tservers.py
+++ b/test/tservers.py
@@ -1,4 +1,5 @@
import threading, Queue
+import shutil, tempfile
import flask
import libpathod.test, libpathod.pathoc
from libmproxy import proxy, flow, controller
@@ -72,7 +73,6 @@ class ProxTestBase(object):
ssl = None
ssloptions = False
clientcerts = False
- certfile = None
no_upstream_cert = False
authenticator = None
masterclass = TestMaster
@@ -82,9 +82,10 @@ class ProxTestBase(object):
cls.server = libpathod.test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions)
cls.server2 = libpathod.test.Daemon(ssl=cls.ssl, ssloptions=cls.ssloptions)
pconf = cls.get_proxy_config()
+ cls.confdir = tempfile.gettempdir()
config = proxy.ProxyConfig(
no_upstream_cert = cls.no_upstream_cert,
- cacert = tutils.test_data.path("data/confdir/mitmproxy-ca.pem"),
+ confdir = cls.confdir,
authenticator = cls.authenticator,
**pconf
)
@@ -93,6 +94,10 @@ class ProxTestBase(object):
cls.proxy = ProxyThread(tmaster)
cls.proxy.start()
+ @classmethod
+ def tearDownAll(cls):
+ shutil.rmtree(cls.confdir)
+
@property
def master(cls):
return cls.proxy.tmaster
@@ -127,9 +132,6 @@ class ProxTestBase(object):
d = dict()
if cls.clientcerts:
d["clientcerts"] = tutils.test_data.path("data/clientcert")
- if cls.certfile:
- d["certfile"] =tutils.test_data.path("data/testkey.pem")
- d["keyfile"] =tutils.test_data.path("data/testkey.pem")
return d
@@ -254,7 +256,6 @@ class ChainProxTest(ProxTestBase):
"""
n = 2
chain_config = [lambda: proxy.ProxyConfig(
- cacert = tutils.test_data.path("data/confdir/mitmproxy-ca.pem"),
)] * n
@classmethod
def setupAll(cls):