aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-08-07 16:22:17 +0200
committerGitHub <noreply@github.com>2017-08-07 16:22:17 +0200
commitcf135eab4464d8f545343267a1ff4fe45771e8a5 (patch)
treef42bb1019c4a856aa1c161f245986833eb4243b1 /test
parentaa8969b240310f265640c92e14a4b7d6363e464b (diff)
parent3d79ea4358c440a9fdb9bfc6aef9d0423846d8ee (diff)
downloadmitmproxy-cf135eab4464d8f545343267a1ff4fe45771e8a5.tar.gz
mitmproxy-cf135eab4464d8f545343267a1ff4fe45771e8a5.tar.bz2
mitmproxy-cf135eab4464d8f545343267a1ff4fe45771e8a5.zip
Merge pull request #2503 from ujjwal96/options
Improve options UX
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/utils/test_arg_check.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/mitmproxy/utils/test_arg_check.py b/test/mitmproxy/utils/test_arg_check.py
new file mode 100644
index 00000000..72913955
--- /dev/null
+++ b/test/mitmproxy/utils/test_arg_check.py
@@ -0,0 +1,36 @@
+import io
+import contextlib
+from unittest import mock
+
+import pytest
+
+from mitmproxy.utils import arg_check
+
+
+@pytest.mark.parametrize('arg, output', [
+ (["-T"], "-T is deprecated, please use --mode transparent instead"),
+ (["-U"], "-U is deprecated, please use --mode upstream:SPEC instead"),
+ (["--cadir"], "--cadir is deprecated.\n"
+ "Please use `--set cadir=value` instead.\n"
+ "To show all options and their default values use --options"),
+ (["--palette"], "--palette is deprecated.\n"
+ "Please use `--set console_palette=value` instead.\n"
+ "To show all options and their default values use --options"),
+ (["--wfile"], "--wfile is deprecated.\n"
+ "Please use `--save-stream-file` instead."),
+ (["--eventlog"], "--eventlog has been removed."),
+ (["--nonanonymous"], '--nonanonymous is deprecated.\n'
+ 'Please use `--proxyauth SPEC` instead.\n'
+ 'SPEC Format: "username:pass", "any" to accept any user/pass combination,\n'
+ '"@path" to use an Apache htpasswd file, or\n'
+ '"ldap[s]:url_server_ldap:dn_auth:password:dn_subtree" '
+ 'for LDAP authentication.')
+
+])
+def test_check_args(arg, output):
+ f = io.StringIO()
+ with contextlib.redirect_stdout(f):
+ with mock.patch('sys.argv') as m:
+ m.__getitem__.return_value = arg
+ arg_check.check()
+ assert f.getvalue().strip() == output