diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:58:37 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:58:37 +1300 |
commit | f361ea491c4719c2a17d4abc0ef894116556a4c1 (patch) | |
tree | 2b9ceaaa4f030c3a33278d09f542b51651f6b4d7 | |
parent | 2aa7ac584b7884b8fd7622aec86b47d1e33a4a11 (diff) | |
download | mitmproxy-f361ea491c4719c2a17d4abc0ef894116556a4c1.tar.gz mitmproxy-f361ea491c4719c2a17d4abc0ef894116556a4c1.tar.bz2 mitmproxy-f361ea491c4719c2a17d4abc0ef894116556a4c1.zip |
addon options: upstream_auth
Also the last "easy" option to shift.
-rw-r--r-- | mitmproxy/addons/upstream_auth.py | 10 | ||||
-rw-r--r-- | mitmproxy/options.py | 16 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_upstream_auth.py | 4 |
3 files changed, 12 insertions, 18 deletions
diff --git a/mitmproxy/addons/upstream_auth.py b/mitmproxy/addons/upstream_auth.py index 685494c2..ea6af337 100644 --- a/mitmproxy/addons/upstream_auth.py +++ b/mitmproxy/addons/upstream_auth.py @@ -1,4 +1,5 @@ import re +import typing import base64 from mitmproxy import exceptions @@ -28,6 +29,15 @@ class UpstreamAuth(): def __init__(self): self.auth = None + def load(self, loader): + loader.add_option( + "upstream_auth", typing.Optional[str], None, + """ + Add HTTP Basic authentication to upstream proxy and reverse proxy + requests. Format: username:password. + """ + ) + def configure(self, updated): # FIXME: We're doing this because our proxy core is terminally confused # at the moment. Ideally, we should be able to check if we're in diff --git a/mitmproxy/options.py b/mitmproxy/options.py index ed17489a..70d454fd 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -66,15 +66,6 @@ class Options(optmanager.OptManager): verbosity = None # type: str view_filter = None # type: Optional[str] - # FIXME: Options that should be uncomplicated to migrate to addons - upstream_auth = None # type: Optional[str] - view_order = None # type: str - view_order_reversed = None # type: bool - web_debug = None # type: bool - web_iface = None # type: str - web_open_browser = None # type: bool - web_port = None # type: int - def __init__(self, **kwargs) -> None: super().__init__() self.add_option( @@ -222,13 +213,6 @@ class Options(optmanager.OptManager): """ ) self.add_option( - "upstream_auth", Optional[str], None, - """ - Add HTTP Basic authentication to upstream proxy and reverse proxy - requests. Format: username:password. - """ - ) - self.add_option( "ssl_version_client", str, "secure", """ Set supported SSL/TLS versions for client connections. SSLv2, SSLv3 diff --git a/test/mitmproxy/addons/test_upstream_auth.py b/test/mitmproxy/addons/test_upstream_auth.py index c7342bb5..53b342a2 100644 --- a/test/mitmproxy/addons/test_upstream_auth.py +++ b/test/mitmproxy/addons/test_upstream_auth.py @@ -9,7 +9,7 @@ from mitmproxy.addons import upstream_auth def test_configure(): up = upstream_auth.UpstreamAuth() - with taddons.context() as tctx: + with taddons.context(up) as tctx: tctx.configure(up, upstream_auth="test:test") assert up.auth == b"Basic" + b" " + base64.b64encode(b"test:test") @@ -29,7 +29,7 @@ def test_configure(): def test_simple(): up = upstream_auth.UpstreamAuth() - with taddons.context() as tctx: + with taddons.context(up) as tctx: tctx.configure(up, upstream_auth="foo:bar") f = tflow.tflow() |