core -> core_option_validation

longer, but much clearer for devs who are unfamiliar with the codebase.
This commit is contained in:
Maximilian Hils 2017-03-08 15:17:07 +01:00
parent f276c7a80d
commit 63179d9751
3 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ from mitmproxy.addons import anticomp
from mitmproxy.addons import check_alpn
from mitmproxy.addons import check_ca
from mitmproxy.addons import clientplayback
from mitmproxy.addons import core
from mitmproxy.addons import core_option_validation
from mitmproxy.addons import disable_h2c_upgrade
from mitmproxy.addons import onboarding
from mitmproxy.addons import proxyauth
@ -20,7 +20,7 @@ from mitmproxy.addons import upstream_auth
def default_addons():
return [
core.Core(),
core_option_validation.CoreOptionValidation(),
anticache.AntiCache(),
anticomp.AntiComp(),
check_alpn.CheckALPN(),

View File

@ -8,7 +8,7 @@ from mitmproxy.net import server_spec
from mitmproxy.utils import human
class Core:
class CoreOptionValidation:
def configure(self, opts, updated):
if opts.add_upstream_certs_to_client_chain and not opts.upstream_cert:
raise exceptions.OptionsError(

View File

@ -1,12 +1,12 @@
from mitmproxy import exceptions
from mitmproxy.addons import core
from mitmproxy.addons import core_option_validation
from mitmproxy.test import taddons
import pytest
from unittest import mock
def test_simple():
sa = core.Core()
sa = core_option_validation.CoreOptionValidation()
with taddons.context() as tctx:
with pytest.raises(exceptions.OptionsError):
tctx.configure(sa, body_size_limit = "invalid")
@ -28,7 +28,7 @@ def test_simple():
@mock.patch("mitmproxy.platform.original_addr", None)
def test_no_transparent():
sa = core.Core()
sa = core_option_validation.CoreOptionValidation()
with taddons.context() as tctx:
with pytest.raises(Exception, match="Transparent mode not supported"):
tctx.configure(sa, mode = "transparent")
@ -36,7 +36,7 @@ def test_no_transparent():
@mock.patch("mitmproxy.platform.original_addr")
def test_modes(m):
sa = core.Core()
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"):