aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2018-02-27 20:19:30 +0100
committerGitHub <noreply@github.com>2018-02-27 20:19:30 +0100
commitc6802ba034d859a914bebddaa9e3214e15206d0e (patch)
tree3201f3f64492035d07f50a831f90b5fe27b1cbba /test
parent90166084866952c578b2dd81a0aa19ed516a619e (diff)
parent944e81dcfcc5220c7853c64405a725f5c4039810 (diff)
downloadmitmproxy-c6802ba034d859a914bebddaa9e3214e15206d0e.tar.gz
mitmproxy-c6802ba034d859a914bebddaa9e3214e15206d0e.tar.bz2
mitmproxy-c6802ba034d859a914bebddaa9e3214e15206d0e.zip
Merge pull request #2934 from mhils/cleanup-proxyconfig
Cleanup ProxyConfig
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_core.py21
-rw-r--r--test/mitmproxy/proxy/test_config.py18
-rw-r--r--test/mitmproxy/test_proxy.py5
3 files changed, 20 insertions, 24 deletions
diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py
index b1b105d9..3c674b3f 100644
--- a/test/mitmproxy/addons/test_core.py
+++ b/test/mitmproxy/addons/test_core.py
@@ -3,6 +3,7 @@ from unittest import mock
from mitmproxy.addons import core
from mitmproxy.test import taddons
from mitmproxy.test import tflow
+from mitmproxy.test import tutils
from mitmproxy import exceptions
import pytest
@@ -167,6 +168,12 @@ def test_validation_simple():
add_upstream_certs_to_client_chain = True,
upstream_cert = False
)
+ with pytest.raises(exceptions.OptionsError, match="requires certificate verification to be disabled"):
+ tctx.configure(
+ sa,
+ add_upstream_certs_to_client_chain = True,
+ ssl_insecure = False
+ )
with pytest.raises(exceptions.OptionsError, match="Invalid mode"):
tctx.configure(
sa,
@@ -188,4 +195,16 @@ def test_validation_modes(m):
with taddons.context() as tctx:
tctx.configure(sa, mode = "reverse:http://localhost")
with pytest.raises(Exception, match="Invalid server specification"):
- tctx.configure(sa, mode = "reverse:") \ No newline at end of file
+ tctx.configure(sa, mode = "reverse:")
+
+
+def test_client_certs():
+ sa = core.Core()
+ with taddons.context() as tctx:
+ # Folders should work.
+ tctx.configure(sa, client_certs = tutils.test_data.path("mitmproxy/data/clientcert"))
+ # Files, too.
+ tctx.configure(sa, client_certs = tutils.test_data.path("mitmproxy/data/clientcert/client.pem"))
+
+ with pytest.raises(exceptions.OptionsError, match="certificate path does not exist"):
+ tctx.configure(sa, client_certs = "invalid")
diff --git a/test/mitmproxy/proxy/test_config.py b/test/mitmproxy/proxy/test_config.py
index a7da980b..60a0deb5 100644
--- a/test/mitmproxy/proxy/test_config.py
+++ b/test/mitmproxy/proxy/test_config.py
@@ -7,30 +7,12 @@ from mitmproxy.test import tutils
class TestProxyConfig:
- def test_upstream_cert_insecure(self):
- opts = options.Options()
- opts.add_upstream_certs_to_client_chain = True
- with pytest.raises(exceptions.OptionsError, match="verify-upstream-cert"):
- ProxyConfig(opts)
-
def test_invalid_cadir(self):
opts = options.Options()
opts.cadir = "foo"
with pytest.raises(exceptions.OptionsError, match="parent directory does not exist"):
ProxyConfig(opts)
- def test_invalid_client_certs(self):
- opts = options.Options()
- opts.client_certs = "foo"
- with pytest.raises(exceptions.OptionsError, match="certificate path does not exist"):
- ProxyConfig(opts)
-
- def test_valid_client_certs(self):
- opts = options.Options()
- opts.client_certs = tutils.test_data.path("mitmproxy/data/clientcert/")
- p = ProxyConfig(opts)
- assert p.client_certs
-
def test_invalid_certificate(self):
opts = options.Options()
opts.certs = [tutils.test_data.path("mitmproxy/data/dumpfile-011")]
diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py
index 299abab3..75d4cdf0 100644
--- a/test/mitmproxy/test_proxy.py
+++ b/test/mitmproxy/test_proxy.py
@@ -1,6 +1,5 @@
import argparse
from unittest import mock
-from OpenSSL import SSL
import pytest
from mitmproxy.tools import cmdline
@@ -50,10 +49,6 @@ class TestProcessProxyOptions:
with pytest.raises(Exception, match="does not exist"):
self.p("--cert", "nonexistent")
- def test_insecure(self):
- p = self.assert_noerr("--ssl-insecure")
- assert p.openssl_verification_mode_server == SSL.VERIFY_NONE
-
class TestProxyServer: