diff options
| author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-03-04 19:47:31 +0100 |
|---|---|---|
| committer | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-03-04 19:47:31 +0100 |
| commit | d7e9dda85c731b9e827b244358d6f7537133dcfb (patch) | |
| tree | c7e9af91219045bb9ad7a38f5d5656a7199612eb /test | |
| parent | b48d1fa5b8995bbacf3c89df397c466f786e7754 (diff) | |
| parent | 0e27dfd9c132e1f8768ae33a33ae8a1c55541948 (diff) | |
| download | mitmproxy-d7e9dda85c731b9e827b244358d6f7537133dcfb.tar.gz mitmproxy-d7e9dda85c731b9e827b244358d6f7537133dcfb.tar.bz2 mitmproxy-d7e9dda85c731b9e827b244358d6f7537133dcfb.zip | |
Merge pull request #988 from xhy940801/master
Add upstream proxy authentication
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/test_cmdline.py | 11 | ||||
| -rw-r--r-- | test/mitmproxy/test_proxy.py | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/test/mitmproxy/test_cmdline.py b/test/mitmproxy/test_cmdline.py index 5a70f3e0..e75b7baf 100644 --- a/test/mitmproxy/test_cmdline.py +++ b/test/mitmproxy/test_cmdline.py @@ -1,4 +1,5 @@ import argparse +import base64 from mitmproxy import cmdline from . import tutils @@ -53,6 +54,16 @@ def test_parse_server_spec(): "http://") +def test_parse_upstream_auth(): + tutils.raises("Invalid upstream auth specification", cmdline.parse_upstream_auth, "") + tutils.raises("Invalid upstream auth specification", cmdline.parse_upstream_auth, ":") + tutils.raises("Invalid upstream auth specification", cmdline.parse_upstream_auth, ":test") + assert cmdline.parse_upstream_auth( + "test:test") == "Basic" + " " + base64.b64encode("test:test") + assert cmdline.parse_upstream_auth( + "test:") == "Basic" + " " + base64.b64encode("test:") + + def test_parse_setheaders(): x = cmdline.parse_setheader("/foo/bar/voing") assert x == ("foo", "bar", "voing") diff --git a/test/mitmproxy/test_proxy.py b/test/mitmproxy/test_proxy.py index 34b75b62..fddb851e 100644 --- a/test/mitmproxy/test_proxy.py +++ b/test/mitmproxy/test_proxy.py @@ -92,6 +92,10 @@ class TestProcessProxyOptions: self.assert_err("expected one argument", "-U") self.assert_err("Invalid server specification", "-U", "upstream") + self.assert_noerr("--upstream-auth", "test:test") + self.assert_err("expected one argument", "--upstream-auth") + self.assert_err("Invalid upstream auth specification", "--upstream-auth", "test") + self.assert_err("not allowed with", "-R", "http://localhost", "-T") def test_socks_auth(self): |
