diff options
author | Aldo Cortesi <aldo@corte.si> | 2017-04-29 11:02:36 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@corte.si> | 2017-04-29 11:02:36 +1200 |
commit | a92017a6c1a0d7cf20f53e1cb4eb24716aaf55e6 (patch) | |
tree | 31f63c7a3badbaa0caa6678cdaceb13af527811a /test | |
parent | 7317ea134e467dd0bc8ad9129dd8a417b0a0fdfd (diff) | |
download | mitmproxy-a92017a6c1a0d7cf20f53e1cb4eb24716aaf55e6.tar.gz mitmproxy-a92017a6c1a0d7cf20f53e1cb4eb24716aaf55e6.tar.bz2 mitmproxy-a92017a6c1a0d7cf20f53e1cb4eb24716aaf55e6.zip |
Rework client and server replay
- Add client.replay [flows], client.replay.stop
- Add server.replay [flows], server.replay.stop
- The corresponding options for file loading are only read on startup, further
changes are ignored. In interactive contexts, replay is started with the
commands, not through option changes.
- Deprecate flow.replay, use replay.client instead
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/addons/test_clientplayback.py | 9 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_core.py | 10 | ||||
-rw-r--r-- | test/mitmproxy/addons/test_serverplayback.py | 1 |
3 files changed, 9 insertions, 11 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 9501fb22..25fefb5d 100644 --- a/test/mitmproxy/addons/test_core.py +++ b/test/mitmproxy/addons/test_core.py @@ -3,7 +3,6 @@ from mitmproxy.test import taddons from mitmproxy.test import tflow from mitmproxy import exceptions import pytest -from unittest import mock def test_set(): @@ -43,15 +42,6 @@ def test_mark(): assert f.marked -def test_replay(): - sa = core.Core() - with taddons.context(): - f = tflow.tflow() - with mock.patch("mitmproxy.master.Master.replay_request") as rp: - sa.replay(f) - assert rp.called - - def test_kill(): sa = core.Core() with taddons.context(): 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)]) |