aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoryonder <kzxiao.hy@gmail.com>2016-03-02 12:19:33 -0500
committeryonder <kzxiao.hy@gmail.com>2016-03-02 12:19:33 -0500
commitb8ae666c78aef9a6ef0e67179d38980247d0e1a5 (patch)
treebb2f621d0b26a5bc8b388b2a30801fc950438015 /test
parent0077e0f8d91ba207574e359247f02e3d3203476a (diff)
downloadmitmproxy-b8ae666c78aef9a6ef0e67179d38980247d0e1a5.tar.gz
mitmproxy-b8ae666c78aef9a6ef0e67179d38980247d0e1a5.tar.bz2
mitmproxy-b8ae666c78aef9a6ef0e67179d38980247d0e1a5.zip
Add test for upstream-auth
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/test_cmdline.py7
-rw-r--r--test/mitmproxy/test_proxy.py4
2 files changed, 11 insertions, 0 deletions
diff --git a/test/mitmproxy/test_cmdline.py b/test/mitmproxy/test_cmdline.py
index 5a70f3e0..1546bb41 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,12 @@ def test_parse_server_spec():
"http://")
+def test_parse_upstream_auth():
+ tutils.raises("Invalid upstream auth specification", cmdline.parse_upstream_auth, "")
+ assert cmdline.parse_upstream_auth(
+ "test:test") == "Basic" + " " + base64.b64encode("test: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):