def test_simple(self): r = replace.ReplaceFile() with tutils.tmpdir() as td: rp = os.path.join(td, "replacement") with open(rp, "w") as f: f.write("bar") with taddons.context() as tctx: tctx.configure( r, replacement_files = [ ("~q", "foo", rp), ("~s", "foo", rp), ("~b nonexistent", "nonexistent", "nonexistent"), ] ) f = tflow.tflow() f.request.content = b"foo" r.request(f) assert f.request.content == b"bar" f = tflow.tflow(resp=True) f.response.content = b"foo" r.response(f) assert f.response.content == b"bar" f = tflow.tflow() f.request.content = b"nonexistent" assert not tctx.master.event_log r.request(f) assert tctx.master.event_log
def default_addons(): return [ anticache.AntiCache(), anticomp.AntiComp(), check_alpn.CheckALPN(), check_ca.CheckCA(), clientplayback.ClientPlayback(), disable_h2c_upgrade.DisableH2CleartextUpgrade(), onboarding.Onboarding(), proxyauth.ProxyAuth(), replace.Replace(), replace.ReplaceFile(), script.ScriptLoader(), serverplayback.ServerPlayback(), setheaders.SetHeaders(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), streambodies.StreamBodies(), streamfile.StreamFile(), upstream_auth.UpstreamAuth(), ]