diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2017-03-06 08:59:35 +1300 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2017-03-06 09:07:16 +1300 |
| commit | 201c65960eb19b97e6c499f22082aa176bdaa6b1 (patch) | |
| tree | 362c899cf3f38cf991a542be6aad1380caf2be45 /test | |
| parent | 45d18ac8cba462eb4f4f73e3e63ea539b44c6f83 (diff) | |
| download | mitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.tar.gz mitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.tar.bz2 mitmproxy-201c65960eb19b97e6c499f22082aa176bdaa6b1.zip | |
Options unification: sizes
Start dealing with corner cases:
- Sizes are always stored in options as strings
- Add a new core addon that's responsible for verifying settings that don't
belong to an addon
- Add a _processed scratch space on the Options object for processed core
values to be stored in. This is pretty dirty, but less dirty than re-parsing
values every time. We'll come up with something better down the track.
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/addons/test_core.py | 13 | ||||
| -rw-r--r-- | test/mitmproxy/addons/test_streambodies.py | 7 | ||||
| -rw-r--r-- | test/mitmproxy/proxy/protocol/test_http2.py | 3 |
3 files changed, 20 insertions, 3 deletions
diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py new file mode 100644 index 00000000..95272716 --- /dev/null +++ b/test/mitmproxy/addons/test_core.py @@ -0,0 +1,13 @@ +from mitmproxy import exceptions +from mitmproxy.addons import core +from mitmproxy.test import taddons +import pytest + + +def test_simple(): + sa = core.Core() + with taddons.context() as tctx: + with pytest.raises(exceptions.OptionsError): + tctx.configure(sa, body_size_limit = "invalid") + tctx.configure(sa, body_size_limit = "1m") + assert tctx.options._processed["body_size_limit"] diff --git a/test/mitmproxy/addons/test_streambodies.py b/test/mitmproxy/addons/test_streambodies.py index b982c66d..c6ce5e81 100644 --- a/test/mitmproxy/addons/test_streambodies.py +++ b/test/mitmproxy/addons/test_streambodies.py @@ -1,13 +1,16 @@ +from mitmproxy import exceptions from mitmproxy.test import tflow from mitmproxy.test import taddons - from mitmproxy.addons import streambodies +import pytest def test_simple(): sa = streambodies.StreamBodies() with taddons.context() as tctx: - tctx.configure(sa, stream_large_bodies = 10) + with pytest.raises(exceptions.OptionsError): + tctx.configure(sa, stream_large_bodies = "invalid") + tctx.configure(sa, stream_large_bodies = "10") f = tflow.tflow() f.request.content = b"" diff --git a/test/mitmproxy/proxy/protocol/test_http2.py b/test/mitmproxy/proxy/protocol/test_http2.py index 770c6550..1f695cc5 100644 --- a/test/mitmproxy/proxy/protocol/test_http2.py +++ b/test/mitmproxy/proxy/protocol/test_http2.py @@ -499,7 +499,8 @@ class TestBodySizeLimit(_Http2Test): return True def test_body_size_limit(self): - self.config.options.body_size_limit = 20 + self.config.options.body_size_limit = "20" + self.config.options._processed["body_size_limit"] = 20 client, h2_conn = self._setup_connection() |
