From faeb9678f1e59dc19fc8a34d9d5bb262de4b6d63 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 3 Feb 2021 19:12:55 +0100 Subject: [PATCH] test dumpfiles: .bin -> .mitm --- .gitattributes | 3 ++- test/mitmproxy/addons/test_clientplayback.py | 4 ++-- .../{dumpfile-010.bin => dumpfile-010.mitm} | Bin .../{dumpfile-011.bin => dumpfile-011.mitm} | 0 .../{dumpfile-018.bin => dumpfile-018.mitm} | 0 .../{dumpfile-019.bin => dumpfile-019.mitm} | Bin .../data/{dumpfile-7.bin => dumpfile-7.mitm} | 0 test/mitmproxy/io/test_compat.py | 16 ++++++++-------- .../mitmproxy/tools/console/test_integration.py | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) rename test/mitmproxy/data/{dumpfile-010.bin => dumpfile-010.mitm} (100%) rename test/mitmproxy/data/{dumpfile-011.bin => dumpfile-011.mitm} (100%) rename test/mitmproxy/data/{dumpfile-018.bin => dumpfile-018.mitm} (100%) rename test/mitmproxy/data/{dumpfile-019.bin => dumpfile-019.mitm} (100%) rename test/mitmproxy/data/{dumpfile-7.bin => dumpfile-7.mitm} (100%) diff --git a/.gitattributes b/.gitattributes index 7e6d229fe..c9ddda7d9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ mitmproxy/tools/web/static/**/* -diff linguist-vendored web/src/js/filt/filt.js -diff -*.bin binary \ No newline at end of file +*.bin binary +*.mitm binary diff --git a/test/mitmproxy/addons/test_clientplayback.py b/test/mitmproxy/addons/test_clientplayback.py index b6f38e788..668639953 100644 --- a/test/mitmproxy/addons/test_clientplayback.py +++ b/test/mitmproxy/addons/test_clientplayback.py @@ -120,7 +120,7 @@ async def test_start_stop(tdata): def test_load(tdata): cp = ClientPlayback() with taddons.context(cp): - cp.load_file(tdata.path("mitmproxy/data/dumpfile-018.bin")) + cp.load_file(tdata.path("mitmproxy/data/dumpfile-018.mitm")) assert cp.count() == 1 with pytest.raises(CommandError): @@ -132,7 +132,7 @@ def test_configure(tdata): cp = ClientPlayback() with taddons.context(cp) as tctx: assert cp.count() == 0 - tctx.configure(cp, client_replay=[tdata.path("mitmproxy/data/dumpfile-018.bin")]) + tctx.configure(cp, client_replay=[tdata.path("mitmproxy/data/dumpfile-018.mitm")]) assert cp.count() == 1 tctx.configure(cp, client_replay=[]) with pytest.raises(OptionsError): diff --git a/test/mitmproxy/data/dumpfile-010.bin b/test/mitmproxy/data/dumpfile-010.mitm similarity index 100% rename from test/mitmproxy/data/dumpfile-010.bin rename to test/mitmproxy/data/dumpfile-010.mitm diff --git a/test/mitmproxy/data/dumpfile-011.bin b/test/mitmproxy/data/dumpfile-011.mitm similarity index 100% rename from test/mitmproxy/data/dumpfile-011.bin rename to test/mitmproxy/data/dumpfile-011.mitm diff --git a/test/mitmproxy/data/dumpfile-018.bin b/test/mitmproxy/data/dumpfile-018.mitm similarity index 100% rename from test/mitmproxy/data/dumpfile-018.bin rename to test/mitmproxy/data/dumpfile-018.mitm diff --git a/test/mitmproxy/data/dumpfile-019.bin b/test/mitmproxy/data/dumpfile-019.mitm similarity index 100% rename from test/mitmproxy/data/dumpfile-019.bin rename to test/mitmproxy/data/dumpfile-019.mitm diff --git a/test/mitmproxy/data/dumpfile-7.bin b/test/mitmproxy/data/dumpfile-7.mitm similarity index 100% rename from test/mitmproxy/data/dumpfile-7.bin rename to test/mitmproxy/data/dumpfile-7.mitm diff --git a/test/mitmproxy/io/test_compat.py b/test/mitmproxy/io/test_compat.py index 47d5e1777..80772dc06 100644 --- a/test/mitmproxy/io/test_compat.py +++ b/test/mitmproxy/io/test_compat.py @@ -4,21 +4,21 @@ from mitmproxy import io from mitmproxy import exceptions -@pytest.mark.parametrize("dumpfile, url", [ - ["dumpfile-011.bin", "https://example.com/"], - ["dumpfile-018.bin", "https://www.example.com/"], - ["dumpfile-019.bin", "https://webrv.rtb-seller.com/"], +@pytest.mark.parametrize("dumpfile, url, count", [ + ["dumpfile-011.mitm", "https://example.com/", 1], + ["dumpfile-018.mitm", "https://www.example.com/", 1], + ["dumpfile-019.mitm", "https://webrv.rtb-seller.com/", 1], ]) -def test_load(tdata, dumpfile, url): +def test_load(tdata, dumpfile, url, count): with open(tdata.path("mitmproxy/data/" + dumpfile), "rb") as f: flow_reader = io.FlowReader(f) flows = list(flow_reader.stream()) - assert len(flows) == 1 - assert flows[0].request.url.startswith(url) + assert len(flows) == count + assert flows[-1].request.url.startswith(url) def test_cannot_convert(tdata): - with open(tdata.path("mitmproxy/data/dumpfile-010.bin"), "rb") as f: + with open(tdata.path("mitmproxy/data/dumpfile-010.mitm"), "rb") as f: flow_reader = io.FlowReader(f) with pytest.raises(exceptions.FlowReadException): list(flow_reader.stream()) diff --git a/test/mitmproxy/tools/console/test_integration.py b/test/mitmproxy/tools/console/test_integration.py index 2bea2349a..21813e0a7 100644 --- a/test/mitmproxy/tools/console/test_integration.py +++ b/test/mitmproxy/tools/console/test_integration.py @@ -40,6 +40,6 @@ def console(monkeypatch): def test_integration(tdata, console): - console.type(f":view.flows.load {tdata.path('mitmproxy/data/dumpfile-7.bin')}") + console.type(f":view.flows.load {tdata.path('mitmproxy/data/dumpfile-7.mitm')}") console.type("") console.type("") # view second flow