aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/http/http1/test_assemble.py4
-rw-r--r--test/http/http1/test_read.py6
-rw-r--r--test/http/http2/test_protocol.py12
-rw-r--r--test/http/test_models.py12
4 files changed, 16 insertions, 18 deletions
diff --git a/test/http/http1/test_assemble.py b/test/http/http1/test_assemble.py
index 47d11d33..460e22c5 100644
--- a/test/http/http1/test_assemble.py
+++ b/test/http/http1/test_assemble.py
@@ -40,7 +40,7 @@ def test_assemble_response():
)
with raises(HttpException):
- assemble_response(tresp(body=CONTENT_MISSING))
+ assemble_response(tresp(content=CONTENT_MISSING))
def test_assemble_response_head():
@@ -86,7 +86,7 @@ def test_assemble_request_headers():
def test_assemble_response_headers():
# https://github.com/mitmproxy/mitmproxy/issues/186
- r = tresp(body=b"")
+ r = tresp(content=b"")
r.headers["Transfer-Encoding"] = "chunked"
c = _assemble_response_headers(r)
assert b"Transfer-Encoding" in c
diff --git a/test/http/http1/test_read.py b/test/http/http1/test_read.py
index c3f744bf..fadfe446 100644
--- a/test/http/http1/test_read.py
+++ b/test/http/http1/test_read.py
@@ -34,7 +34,7 @@ def test_read_request_head():
r = read_request_head(rfile)
assert r.method == "GET"
assert r.headers["Content-Length"] == "4"
- assert r.body is None
+ assert r.content is None
assert rfile.reset_timestamps.called
assert r.timestamp_start == 42
assert rfile.read() == b"skip"
@@ -45,7 +45,7 @@ def test_read_response():
rfile = BytesIO(b"HTTP/1.1 418 I'm a teapot\r\n\r\nbody")
r = read_response(rfile, req)
assert r.status_code == 418
- assert r.body == b"body"
+ assert r.content == b"body"
assert r.timestamp_end
@@ -61,7 +61,7 @@ def test_read_response_head():
r = read_response_head(rfile)
assert r.status_code == 418
assert r.headers["Content-Length"] == "4"
- assert r.body is None
+ assert r.content is None
assert rfile.reset_timestamps.called
assert r.timestamp_start == 42
assert rfile.read() == b"skip"
diff --git a/test/http/http2/test_protocol.py b/test/http/http2/test_protocol.py
index a55941e0..6bda96f5 100644
--- a/test/http/http2/test_protocol.py
+++ b/test/http/http2/test_protocol.py
@@ -65,7 +65,7 @@ class TestProtocol:
class TestCheckALPNMatch(tservers.ServerTestBase):
handler = EchoHandler
ssl = dict(
- alpn_select=ALPN_PROTO_H2,
+ alpn_select=b'h2',
)
if OpenSSL._util.lib.Cryptography_HAS_ALPN:
@@ -73,7 +73,7 @@ class TestCheckALPNMatch(tservers.ServerTestBase):
def test_check_alpn(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
c.connect()
- c.convert_to_ssl(alpn_protos=[ALPN_PROTO_H2])
+ c.convert_to_ssl(alpn_protos=[b'h2'])
protocol = HTTP2Protocol(c)
assert protocol.check_alpn()
@@ -89,7 +89,7 @@ class TestCheckALPNMismatch(tservers.ServerTestBase):
def test_check_alpn(self):
c = tcp.TCPClient(("127.0.0.1", self.port))
c.connect()
- c.convert_to_ssl(alpn_protos=[ALPN_PROTO_H2])
+ c.convert_to_ssl(alpn_protos=[b'h2'])
protocol = HTTP2Protocol(c)
tutils.raises(NotImplementedError, protocol.check_alpn)
@@ -311,7 +311,7 @@ class TestReadRequest(tservers.ServerTestBase):
assert req.stream_id
assert req.headers.fields == [[':method', 'GET'], [':path', '/'], [':scheme', 'https']]
- assert req.body == b'foobar'
+ assert req.content == b'foobar'
class TestReadRequestRelative(tservers.ServerTestBase):
@@ -417,7 +417,7 @@ class TestReadResponse(tservers.ServerTestBase):
assert resp.status_code == 200
assert resp.msg == ""
assert resp.headers.fields == [[':status', '200'], ['etag', 'foobar']]
- assert resp.body == b'foobar'
+ assert resp.content == b'foobar'
assert resp.timestamp_end
@@ -444,7 +444,7 @@ class TestReadEmptyResponse(tservers.ServerTestBase):
assert resp.status_code == 200
assert resp.msg == ""
assert resp.headers.fields == [[':status', '200'], ['etag', 'foobar']]
- assert resp.body == b''
+ assert resp.content == b''
class TestAssembleRequest(object):
diff --git a/test/http/test_models.py b/test/http/test_models.py
index 3c196847..aa267944 100644
--- a/test/http/test_models.py
+++ b/test/http/test_models.py
@@ -3,9 +3,7 @@ import mock
from netlib import tutils
from netlib import utils
from netlib.odict import ODict, ODictCaseless
-from netlib.http import Request, Response, Headers, CONTENT_MISSING, HDR_FORM_URLENCODED, \
- HDR_FORM_MULTIPART
-
+from netlib.http import Request, Response, Headers, CONTENT_MISSING
class TestRequest(object):
def test_repr(self):
@@ -77,14 +75,14 @@ class TestRequest(object):
req = tutils.treq(content="foobar")
assert req.get_form_urlencoded() == ODict()
- req.headers["Content-Type"] = HDR_FORM_URLENCODED
+ req.headers["Content-Type"] = "application/x-www-form-urlencoded"
assert req.get_form_urlencoded() == ODict(utils.urldecode(req.body))
def test_get_form_multipart(self):
req = tutils.treq(content="foobar")
assert req.get_form_multipart() == ODict()
- req.headers["Content-Type"] = HDR_FORM_MULTIPART
+ req.headers["Content-Type"] = "multipart/form-data"
assert req.get_form_multipart() == ODict(
utils.multipartdecode(
req.headers,
@@ -95,7 +93,7 @@ class TestRequest(object):
def test_set_form_urlencoded(self):
req = tutils.treq()
req.set_form_urlencoded(ODict([('foo', 'bar'), ('rab', 'oof')]))
- assert req.headers["Content-Type"] == HDR_FORM_URLENCODED
+ assert req.headers["Content-Type"] == "application/x-www-form-urlencoded"
assert req.body
def test_get_path_components(self):
@@ -298,7 +296,7 @@ class TestResponse(object):
assert "unknown content type" in repr(r)
r.headers["content-type"] = "foo"
assert "foo" in repr(r)
- assert repr(tutils.tresp(body=CONTENT_MISSING))
+ assert repr(tutils.tresp(content=CONTENT_MISSING))
def test_get_cookies_none(self):
resp = tutils.tresp()