aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2017-04-27 17:05:00 +1200
committerAldo Cortesi <aldo@nullcube.com>2017-04-27 17:05:00 +1200
commit97000aa85c6d4cd52d97bda66b0c05ffed93e9da (patch)
treeb5ed172d016a6341e98d2eb765200ba39446b2c2 /test
parentb7afcb5dc2007ce451161e513d3e55d4cc91379e (diff)
downloadmitmproxy-97000aa85c6d4cd52d97bda66b0c05ffed93e9da.tar.gz
mitmproxy-97000aa85c6d4cd52d97bda66b0c05ffed93e9da.tar.bz2
mitmproxy-97000aa85c6d4cd52d97bda66b0c05ffed93e9da.zip
command: save.file flowspec path -> None
Our first user-facing command. The following commands do the obvious things: save.file @marked /tmp/flows save.file @focus /tmp/flows save.file @hidden /tmp/flows save.file "~m get" /tmp/flows
Diffstat (limited to 'test')
-rw-r--r--test/mitmproxy/addons/test_save.py21
-rw-r--r--test/mitmproxy/test_addonmanager.py4
2 files changed, 23 insertions, 2 deletions
diff --git a/test/mitmproxy/addons/test_save.py b/test/mitmproxy/addons/test_save.py
index fcd2feab..85c2a398 100644
--- a/test/mitmproxy/addons/test_save.py
+++ b/test/mitmproxy/addons/test_save.py
@@ -7,6 +7,7 @@ from mitmproxy import io
from mitmproxy import exceptions
from mitmproxy import options
from mitmproxy.addons import save
+from mitmproxy.addons import view
def test_configure(tmpdir):
@@ -42,6 +43,26 @@ def test_tcp(tmpdir):
assert rd(p)
+def test_save_command(tmpdir):
+ sa = save.Save()
+ with taddons.context() as tctx:
+ p = str(tmpdir.join("foo"))
+ sa.save([tflow.tflow(resp=True)], p)
+ assert len(rd(p)) == 1
+ sa.save([tflow.tflow(resp=True)], p)
+ assert len(rd(p)) == 1
+ sa.save([tflow.tflow(resp=True)], "+" + p)
+ assert len(rd(p)) == 2
+
+ with pytest.raises(exceptions.CommandError):
+ sa.save([tflow.tflow(resp=True)], str(tmpdir))
+
+ v = view.View()
+ tctx.master.addons.add(v)
+ tctx.master.addons.add(sa)
+ tctx.master.commands.call_args("save.file", ["@shown", p])
+
+
def test_simple(tmpdir):
sa = save.Save()
with taddons.context() as tctx:
diff --git a/test/mitmproxy/test_addonmanager.py b/test/mitmproxy/test_addonmanager.py
index 7b461580..fc1db941 100644
--- a/test/mitmproxy/test_addonmanager.py
+++ b/test/mitmproxy/test_addonmanager.py
@@ -61,9 +61,9 @@ def test_lifecycle():
a = addonmanager.AddonManager(m)
a.add(TAddon("one"))
- with pytest.raises(exceptions.AddonError):
+ with pytest.raises(exceptions.AddonManagerError):
a.add(TAddon("one"))
- with pytest.raises(exceptions.AddonError):
+ with pytest.raises(exceptions.AddonManagerError):
a.remove(TAddon("nonexistent"))
f = tflow.tflow()