aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYoann L <yoann.lamouroux@data-impact.fr>2019-10-28 17:51:59 +0100
committerYoann L <yoann.lamouroux@data-impact.fr>2019-10-28 17:51:59 +0100
commit33707403614642ae63d7ed24f36c80a3f58ce7ac (patch)
treeb060b880b65dc69ae331cb042048051ea27063eb /test
parenteb7ed1dc40025dd9eada5b01852fc20106a4a204 (diff)
downloadmitmproxy-33707403614642ae63d7ed24f36c80a3f58ce7ac.tar.gz
mitmproxy-33707403614642ae63d7ed24f36c80a3f58ce7ac.tar.bz2
mitmproxy-33707403614642ae63d7ed24f36c80a3f58ce7ac.zip
several fixes on command exports has several problems: #3676
* authority can usually rely on actual URL. as `:authority` headers will break curl command. (advise if it's better to change them to Host, or if it should be reported on curl side) * `content-length`: 0 is added for each request. if it's found in the curl argument list, it'll try to fetch an empty body (and crash). also trying to guess on accept-encoding header to add the `--compress` option when fetching potentially compressed content. * ditto for httpie
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_export.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/test/mitmproxy/addons/test_export.py b/test/mitmproxy/addons/test_export.py
index f4bb0f64..c86e0c7d 100644
--- a/test/mitmproxy/addons/test_export.py
+++ b/test/mitmproxy/addons/test_export.py
@@ -14,29 +14,23 @@ from unittest import mock
@pytest.fixture
def get_request():
return tflow.tflow(
- req=tutils.treq(
- method=b'GET',
- content=b'',
- path=b"/path?a=foo&a=bar&b=baz"
- )
- )
+ req=tutils.treq(method=b'GET', content=b'', path=b"/path?a=foo&a=bar&b=baz"))
@pytest.fixture
def post_request():
return tflow.tflow(
- req=tutils.treq(
- method=b'POST',
- headers=(),
- content=bytes(range(256))
- )
- )
+ req=tutils.treq(method=b'POST', headers=(), content=bytes(range(256))))
@pytest.fixture
def patch_request():
return tflow.tflow(
- req=tutils.treq(method=b'PATCH', path=b"/path?query=param")
+ req=tutils.treq(
+ method=b'PATCH',
+ content=b'content',
+ path=b"/path?query=param"
+ )
)
@@ -47,7 +41,7 @@ def tcp_flow():
class TestExportCurlCommand:
def test_get(self, get_request):
- result = """curl -H 'header:qvalue' -H 'content-length:0' 'http://address:22/path?a=foo&a=bar&b=baz'"""
+ result = """curl -H 'header:qvalue' 'http://address:22/path?a=foo&a=bar&b=baz'"""
assert export.curl_command(get_request) == result
def test_post(self, post_request):
@@ -67,7 +61,7 @@ class TestExportCurlCommand:
class TestExportHttpieCommand:
def test_get(self, get_request):
- result = """http GET http://address:22/path?a=foo&a=bar&b=baz 'header:qvalue' 'content-length:0'"""
+ result = """http GET http://address:22/path?a=foo&a=bar&b=baz 'header:qvalue'"""
assert export.httpie_command(get_request) == result
def test_post(self, post_request):