diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-06-18 16:16:40 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-06-18 16:16:40 +1200 |
commit | 274d0333f8bbd0bf88214747beeead991f36b72a (patch) | |
tree | 590d684d8ab9277cab441ffb07a79cc36412e4c7 /test/test_pathoc_cmdline.py | |
parent | 78cb5fe573ffcc06e700bb2193f9aef212be267e (diff) | |
parent | 408b4ffef0a784bea7ec08c252e757bca6e28134 (diff) | |
download | mitmproxy-274d0333f8bbd0bf88214747beeead991f36b72a.tar.gz mitmproxy-274d0333f8bbd0bf88214747beeead991f36b72a.tar.bz2 mitmproxy-274d0333f8bbd0bf88214747beeead991f36b72a.zip |
Merge pull request #27 from Kriechi/http2-wip
HTTP/2: add initial support
Diffstat (limited to 'test/test_pathoc_cmdline.py')
-rw-r--r-- | test/test_pathoc_cmdline.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/test/test_pathoc_cmdline.py b/test/test_pathoc_cmdline.py new file mode 100644 index 00000000..6c070aed --- /dev/null +++ b/test/test_pathoc_cmdline.py @@ -0,0 +1,64 @@ +from libpathod import pathoc_cmdline as cmdline +import tutils +import cStringIO +import mock + + +@mock.patch("argparse.ArgumentParser.error") +def test_pathoc(perror): + assert cmdline.args_pathoc(["pathoc", "foo.com", "get:/"]) + s = cStringIO.StringIO() + tutils.raises( + SystemExit, cmdline.args_pathoc, [ + "pathoc", "--show-uas"], s, s) + + a = cmdline.args_pathoc(["pathoc", "foo.com:8888", "get:/"]) + assert a.port == 8888 + + a = cmdline.args_pathoc(["pathoc", "foo.com:xxx", "get:/"]) + assert perror.called + perror.reset_mock() + + a = cmdline.args_pathoc(["pathoc", "-I", "10, 20", "foo.com:8888", "get:/"]) + assert a.ignorecodes == [10, 20] + + a = cmdline.args_pathoc(["pathoc", "-I", "xx, 20", "foo.com:8888", "get:/"]) + assert perror.called + perror.reset_mock() + + a = cmdline.args_pathoc(["pathoc", "-c", "foo:10", "foo.com:8888", "get:/"]) + assert a.connect_to == ["foo", 10] + + a = cmdline.args_pathoc(["pathoc", "foo.com", "get:/", "--http2"]) + assert a.use_http2 == True + assert a.ssl == True + + a = cmdline.args_pathoc(["pathoc", "foo.com", "get:/", "--http2-skip-connection-preface"]) + assert a.use_http2 == True + assert a.ssl == True + assert a.http2_skip_connection_preface == True + + a = cmdline.args_pathoc(["pathoc", "-c", "foo", "foo.com:8888", "get:/"]) + assert perror.called + perror.reset_mock() + + a = cmdline.args_pathoc( + ["pathoc", "-c", "foo:bar", "foo.com:8888", "get:/"]) + assert perror.called + perror.reset_mock() + + a = cmdline.args_pathoc( + [ + "pathoc", + "foo.com:8888", + tutils.test_data.path("data/request") + ] + ) + assert len(list(a.requests)) == 1 + + tutils.raises( + SystemExit, + cmdline.args_pathoc, + ["pathoc", "foo.com", "invalid"], + s, s + ) |