aboutsummaryrefslogtreecommitdiffstats
path: root/test/mitmproxy/addons/test_core.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2018-02-27 19:05:59 +0100
committerMaximilian Hils <git@maximilianhils.com>2018-02-27 19:05:59 +0100
commit944e81dcfcc5220c7853c64405a725f5c4039810 (patch)
tree3201f3f64492035d07f50a831f90b5fe27b1cbba /test/mitmproxy/addons/test_core.py
parent65b8b65ebc47ed9b610e0df765e273df6a27ce6a (diff)
downloadmitmproxy-944e81dcfcc5220c7853c64405a725f5c4039810.tar.gz
mitmproxy-944e81dcfcc5220c7853c64405a725f5c4039810.tar.bz2
mitmproxy-944e81dcfcc5220c7853c64405a725f5c4039810.zip
clean up ProxyConfig
some of these options weren't even used anymore, others only in one place where it makes sense to use options directly.
Diffstat (limited to 'test/mitmproxy/addons/test_core.py')
-rw-r--r--test/mitmproxy/addons/test_core.py21
1 files changed, 20 insertions, 1 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")