aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-07-31 00:04:46 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-07-31 01:58:31 +0200
commit1b09002edc984d4ead3cce118ed583c3ceca0b99 (patch)
treeeb83c1bec226b12a33313b537715179c92e6689e /test
parent826513ef278739b51d4d25eefef0ab6217df74ab (diff)
downloadmitmproxy-1b09002edc984d4ead3cce118ed583c3ceca0b99.tar.gz
mitmproxy-1b09002edc984d4ead3cce118ed583c3ceca0b99.tar.bz2
mitmproxy-1b09002edc984d4ead3cce118ed583c3ceca0b99.zip
remove OptManager._processed
Instead of having the core addon do postprocessing on body_size_limit, we add a cache to the parsing function. First, this avoids any potential issues with options and _processed getting out of sync. As anecdotal evidence, the previous implementation did not clear _processed when body_size_limit was reset to None. Second, it achieves the same end result without introducing a new concept of a "_processed" scratch space. Third, it works even if addons aren't present, and does not require workarounds as previously present in test_http2.py. refs https://github.com/mitmproxy/mitmproxy/pull/2484#pullrequestreview-53101507
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_core_option_validation.py1
-rw-r--r--test/mitmproxy/proxy/protocol/test_http2.py3
-rw-r--r--test/mitmproxy/utils/test_human.py1
3 files changed, 1 insertions, 4 deletions
diff --git a/test/mitmproxy/addons/test_core_option_validation.py b/test/mitmproxy/addons/test_core_option_validation.py
index 6d6d5ba4..cd5d4dfa 100644
--- a/test/mitmproxy/addons/test_core_option_validation.py
+++ b/test/mitmproxy/addons/test_core_option_validation.py
@@ -11,7 +11,6 @@ def test_simple():
with pytest.raises(exceptions.OptionsError):
tctx.configure(sa, body_size_limit = "invalid")
tctx.configure(sa, body_size_limit = "1m")
- assert tctx.master.options._processed["body_size_limit"]
with pytest.raises(exceptions.OptionsError, match="mutually exclusive"):
tctx.configure(
diff --git a/test/mitmproxy/proxy/protocol/test_http2.py b/test/mitmproxy/proxy/protocol/test_http2.py
index 5e6fa701..4f161ef5 100644
--- a/test/mitmproxy/proxy/protocol/test_http2.py
+++ b/test/mitmproxy/proxy/protocol/test_http2.py
@@ -507,9 +507,6 @@ class TestBodySizeLimit(_Http2Test):
def test_body_size_limit(self):
self.options.body_size_limit = "20"
- # FIXME: This should not be required?
- self.options._processed["body_size_limit"] = 20
-
h2_conn = self.setup_connection()
self._send_request(
diff --git a/test/mitmproxy/utils/test_human.py b/test/mitmproxy/utils/test_human.py
index 76dc2f88..e8ffaad4 100644
--- a/test/mitmproxy/utils/test_human.py
+++ b/test/mitmproxy/utils/test_human.py
@@ -22,6 +22,7 @@ def test_parse_size():
human.parse_size("1f")
with pytest.raises(ValueError):
human.parse_size("ak")
+ assert human.parse_size(None) is None
def test_pretty_size():