def default_addons(): return [ core.Core(), browser.Browser(), block.Block(), anticache.AntiCache(), anticomp.AntiComp(), check_ca.CheckCA(), clientplayback.ClientPlayback(), command_history.CommandHistory(), cut.Cut(), disable_h2c.DisableH2C(), export.Export(), onboarding.Onboarding(), proxyauth.ProxyAuth(), script.ScriptLoader(), serverplayback.ServerPlayback(), mapremote.MapRemote(), modifybody.ModifyBody(), modifyheaders.ModifyHeaders(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), streambodies.StreamBodies(), save.Save(), upstream_auth.UpstreamAuth(), ]
def default_addons(): return [ core.Core(), browser.Browser(), block.Block(), blocklist.BlockList(), anticache.AntiCache(), anticomp.AntiComp(), clientplayback.ClientPlayback(), command_history.CommandHistory(), comment.Comment(), cut.Cut(), disable_h2c.DisableH2C(), export.Export(), onboarding.Onboarding(), proxyauth.ProxyAuth(), proxyserver.Proxyserver(), script.ScriptLoader(), next_layer.NextLayer(), serverplayback.ServerPlayback(), mapremote.MapRemote(), maplocal.MapLocal(), modifybody.ModifyBody(), modifyheaders.ModifyHeaders(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), save.Save(), tlsconfig.TlsConfig(), upstream_auth.UpstreamAuth(), ]
def test_is_killed(self): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tctx.configure(mr, map_remote=[":example.org:mitmproxy.org"]) f = tflow.tflow() f.request.url = b"https://example.org/images/test.jpg" f.kill() mr.request(f) assert f.request.url == "https://example.org/images/test.jpg"
def test_simple(self, tmpdir): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tmpfile = tmpdir.join("replacement") tmpfile.write("mitmproxy.org") tctx.configure(mr, map_remote=["|example.org|@" + str(tmpfile)]) f = tflow.tflow() f.request.url = b"https://example.org/test" mr.request(f) assert f.request.url == "https://mitmproxy.org/test"
def test_simple(self): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tctx.configure(mr, map_remote=[ ":example.org/images/:mitmproxy.org/img/", ]) f = tflow.tflow() f.request.url = b"https://example.org/images/test.jpg" mr.request(f) assert f.request.url == "https://mitmproxy.org/img/test.jpg"
async def test_nonexistent(self, tmpdir): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: with pytest.raises(Exception, match="Invalid file path"): tctx.configure(mr, map_remote=[":~q:example.org:@nonexistent"]) tmpfile = tmpdir.join("replacement") tmpfile.write("mitmproxy.org") tctx.configure(mr, map_remote=["|example.org|@" + str(tmpfile)]) tmpfile.remove() f = tflow.tflow() f.request.url = b"https://example.org/test" mr.request(f) assert await tctx.master.await_log("could not read")
def test_configure(self): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tctx.configure(mr, map_remote=["one/two/three"]) with pytest.raises( Exception, match="Cannot parse map_remote .* Invalid number"): tctx.configure(mr, map_remote=["/"]) with pytest.raises( Exception, match="Cannot parse map_remote .* Invalid filter"): tctx.configure(mr, map_remote=["/~b/two/three"]) with pytest.raises( Exception, match= "Cannot parse map_remote .* Invalid regular expression"): tctx.configure(mr, map_remote=["/foo/+/three"]) tctx.configure(mr, map_remote=["/a/b/c/"])
def test_configure(self): mr = mapremote.MapRemote() with taddons.context(mr) as tctx: tctx.configure(mr, map_remote=["one/two/three"]) with pytest.raises(Exception, match="Invalid regular expression"): tctx.configure(mr, map_remote=["/foo/+/three"])