diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-03-23 11:48:36 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-03-24 09:37:17 +1300 |
commit | 0d3e2c6adff0479c42dc28880cd0258d32958fc2 (patch) | |
tree | 0504d1303377c4f25d69216346032e415b1468c5 /test | |
parent | eb66456d16a7d36957e922bf530b5913473b509b (diff) | |
download | mitmproxy-0d3e2c6adff0479c42dc28880cd0258d32958fc2.tar.gz mitmproxy-0d3e2c6adff0479c42dc28880cd0258d32958fc2.tar.bz2 mitmproxy-0d3e2c6adff0479c42dc28880cd0258d32958fc2.zip |
optmanager: make serialization and loading more robust
Also handle errors in console options manager.
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_optmanager.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py index 01636640..31b6e52b 100644 --- a/test/mitmproxy/test_optmanager.py +++ b/test/mitmproxy/test_optmanager.py @@ -296,6 +296,20 @@ def test_saving(tmpdir): with pytest.raises(exceptions.OptionsError): optmanager.load_paths(o, dst) + with open(dst, 'wb') as f: + f.write(b"\x01\x02\x03") + with pytest.raises(exceptions.OptionsError): + optmanager.load_paths(o, dst) + with pytest.raises(exceptions.OptionsError): + optmanager.save(o, dst) + + with open(dst, 'wb') as f: + f.write(b"\xff\xff\xff") + with pytest.raises(exceptions.OptionsError): + optmanager.load_paths(o, dst) + with pytest.raises(exceptions.OptionsError): + optmanager.save(o, dst) + def test_merge(): m = TM() |