diff options
| author | Aldo Cortesi <aldo@corte.si> | 2017-04-29 11:23:19 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-04-29 11:23:19 +1200 |
| commit | c7247e026d3fb57ea063cfe4e5335b914ad15a15 (patch) | |
| tree | 31f63c7a3badbaa0caa6678cdaceb13af527811a /test | |
| parent | 139c4e6db38677050d423d056bbd877985bfa475 (diff) | |
| parent | a92017a6c1a0d7cf20f53e1cb4eb24716aaf55e6 (diff) | |
| download | mitmproxy-c7247e026d3fb57ea063cfe4e5335b914ad15a15.tar.gz mitmproxy-c7247e026d3fb57ea063cfe4e5335b914ad15a15.tar.bz2 mitmproxy-c7247e026d3fb57ea063cfe4e5335b914ad15a15.zip | |
Merge pull request #2287 from cortesi/cmdmark
commands: marking
Diffstat (limited to 'test')
| -rw-r--r-- | test/mitmproxy/addons/test_clientplayback.py | 9 | ||||
| -rw-r--r-- | test/mitmproxy/addons/test_core.py | 24 | ||||
| -rw-r--r-- | test/mitmproxy/addons/test_serverplayback.py | 1 | ||||
| -rw-r--r-- | test/mitmproxy/test_command.py | 6 |
4 files changed, 39 insertions, 1 deletions
diff --git a/test/mitmproxy/addons/test_clientplayback.py b/test/mitmproxy/addons/test_clientplayback.py index f71662f0..843d7409 100644 --- a/test/mitmproxy/addons/test_clientplayback.py +++ b/test/mitmproxy/addons/test_clientplayback.py @@ -26,7 +26,7 @@ class TestClientPlayback: with taddons.context() as tctx: assert cp.count() == 0 f = tflow.tflow(resp=True) - cp.load([f]) + cp.start_replay([f]) assert cp.count() == 1 RP = "mitmproxy.proxy.protocol.http_replay.RequestReplayThread" with mock.patch(RP) as rp: @@ -44,13 +44,20 @@ class TestClientPlayback: cp.tick() assert cp.current_thread is None + cp.start_replay([f]) + cp.stop_replay() + assert not cp.flows + def test_configure(self, tmpdir): cp = clientplayback.ClientPlayback() with taddons.context() as tctx: path = str(tmpdir.join("flows")) tdump(path, [tflow.tflow()]) tctx.configure(cp, client_replay=[path]) + cp.configured = False tctx.configure(cp, client_replay=[]) + cp.configured = False tctx.configure(cp) + cp.configured = False with pytest.raises(exceptions.OptionsError): tctx.configure(cp, client_replay=["nonexistent"]) diff --git a/test/mitmproxy/addons/test_core.py b/test/mitmproxy/addons/test_core.py index 39aac935..25fefb5d 100644 --- a/test/mitmproxy/addons/test_core.py +++ b/test/mitmproxy/addons/test_core.py @@ -26,3 +26,27 @@ def test_resume(): f.intercept() sa.resume([f]) assert not f.reply.state == "taken" + + +def test_mark(): + sa = core.Core() + with taddons.context(): + f = tflow.tflow() + assert not f.marked + sa.mark([f], True) + assert f.marked + + sa.mark_toggle([f]) + assert not f.marked + sa.mark_toggle([f]) + assert f.marked + + +def test_kill(): + sa = core.Core() + with taddons.context(): + f = tflow.tflow() + f.intercept() + assert f.killable + sa.kill([f]) + assert not f.killable diff --git a/test/mitmproxy/addons/test_serverplayback.py b/test/mitmproxy/addons/test_serverplayback.py index 29de48a0..e0c025fe 100644 --- a/test/mitmproxy/addons/test_serverplayback.py +++ b/test/mitmproxy/addons/test_serverplayback.py @@ -22,6 +22,7 @@ def test_config(tmpdir): fpath = str(tmpdir.join("flows")) tdump(fpath, [tflow.tflow(resp=True)]) tctx.configure(s, server_replay=[fpath]) + s.configured = False with pytest.raises(exceptions.OptionsError): tctx.configure(s, server_replay=[str(tmpdir)]) diff --git a/test/mitmproxy/test_command.py b/test/mitmproxy/test_command.py index 306650c7..96d79dba 100644 --- a/test/mitmproxy/test_command.py +++ b/test/mitmproxy/test_command.py @@ -76,10 +76,16 @@ def test_parsearg(): with taddons.context() as tctx: tctx.master.addons.add(DummyConsole()) assert command.parsearg(tctx.master.commands, "foo", str) == "foo" + assert command.parsearg(tctx.master.commands, "1", int) == 1 with pytest.raises(exceptions.CommandError): command.parsearg(tctx.master.commands, "foo", int) + assert command.parsearg(tctx.master.commands, "true", bool) is True + assert command.parsearg(tctx.master.commands, "false", bool) is False + with pytest.raises(exceptions.CommandError): + command.parsearg(tctx.master.commands, "flobble", bool) + assert len(command.parsearg( tctx.master.commands, "2", typing.Sequence[flow.Flow] )) == 2 |
