From 63179d97511519ce0ba4384b2c6849ba96748d88 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 8 Mar 2017 15:17:07 +0100 Subject: core -> core_option_validation longer, but much clearer for devs who are unfamiliar with the codebase. --- test/mitmproxy/addons/test_core.py | 43 ---------------------- .../addons/test_core_option_validation.py | 43 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 43 deletions(-) delete mode 100644 test/mitmproxy/addons/test_core.py create mode 100644 test/mitmproxy/addons/test_core_option_validation.py (limited to 'test') diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py deleted file mode 100644 index db739b5d..00000000 --- a/test/mitmproxy/addons/test_core.py +++ /dev/null @@ -1,43 +0,0 @@ -from mitmproxy import exceptions -from mitmproxy.addons import core -from mitmproxy.test import taddons -import pytest -from unittest import mock - - -def test_simple(): - sa = core.Core() - with taddons.context() as tctx: - with pytest.raises(exceptions.OptionsError): - tctx.configure(sa, body_size_limit = "invalid") - tctx.configure(sa, body_size_limit = "1m") - assert tctx.options._processed["body_size_limit"] - - with pytest.raises(exceptions.OptionsError, match="mutually exclusive"): - tctx.configure( - sa, - add_upstream_certs_to_client_chain = True, - upstream_cert = False - ) - with pytest.raises(exceptions.OptionsError, match="Invalid mode"): - tctx.configure( - sa, - mode = "Flibble" - ) - - -@mock.patch("mitmproxy.platform.original_addr", None) -def test_no_transparent(): - sa = core.Core() - with taddons.context() as tctx: - with pytest.raises(Exception, match="Transparent mode not supported"): - tctx.configure(sa, mode = "transparent") - - -@mock.patch("mitmproxy.platform.original_addr") -def test_modes(m): - sa = core.Core() - 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:") diff --git a/test/mitmproxy/addons/test_core_option_validation.py b/test/mitmproxy/addons/test_core_option_validation.py new file mode 100644 index 00000000..0bb2bb0d --- /dev/null +++ b/test/mitmproxy/addons/test_core_option_validation.py @@ -0,0 +1,43 @@ +from mitmproxy import exceptions +from mitmproxy.addons import core_option_validation +from mitmproxy.test import taddons +import pytest +from unittest import mock + + +def test_simple(): + sa = core_option_validation.CoreOptionValidation() + with taddons.context() as tctx: + with pytest.raises(exceptions.OptionsError): + tctx.configure(sa, body_size_limit = "invalid") + tctx.configure(sa, body_size_limit = "1m") + assert tctx.options._processed["body_size_limit"] + + with pytest.raises(exceptions.OptionsError, match="mutually exclusive"): + tctx.configure( + sa, + add_upstream_certs_to_client_chain = True, + upstream_cert = False + ) + with pytest.raises(exceptions.OptionsError, match="Invalid mode"): + tctx.configure( + sa, + mode = "Flibble" + ) + + +@mock.patch("mitmproxy.platform.original_addr", None) +def test_no_transparent(): + sa = core_option_validation.CoreOptionValidation() + with taddons.context() as tctx: + with pytest.raises(Exception, match="Transparent mode not supported"): + tctx.configure(sa, mode = "transparent") + + +@mock.patch("mitmproxy.platform.original_addr") +def test_modes(m): + sa = core_option_validation.CoreOptionValidation() + 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:") -- cgit v1.2.3