def test_configure(self): r = replace.Replace() updated = set(["replacements"]) r.configure(options.Options(replacements=[("one", "two", "three")]), updated) tutils.raises("invalid filter pattern", r.configure, options.Options(replacements=[("~b", "two", "three")]), updated) tutils.raises("invalid regular expression", r.configure, options.Options(replacements=[("foo", "+", "three")]), updated)
def default_addons(): return [ anticache.AntiCache(), anticomp.AntiComp(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), script.ScriptLoader(), filestreamer.FileStreamer(), replace.Replace(), setheaders.SetHeaders(), ]
def test_order(self): sa = replace.Replace() self.proxy.tmaster.addons.add(sa) self.proxy.tmaster.options.replacements = [ ("~q", "foo", "bar"), ("~q", "bar", "baz"), ("~q", "foo", "oh noes!"), ("~s", "baz", "ORLY") ] p = self.pathoc() with p.connect(): req = p.request("get:'%s/p/418:b\"foo\"'" % self.server.urlbase) assert req.content == b"ORLY" assert req.status_code == 418
def default_addons(): return [ onboarding.Onboarding(), anticache.AntiCache(), anticomp.AntiComp(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), script.ScriptLoader(), filestreamer.FileStreamer(), streambodies.StreamBodies(), replace.Replace(), setheaders.SetHeaders(), serverplayback.ServerPlayback(), clientplayback.ClientPlayback(), ]
def test_simple(self): s = state.State() o = options.Options(replacements=[ ("~q", "foo", "bar"), ("~s", "foo", "bar"), ]) m = master.FlowMaster(o, None, s) sa = replace.Replace() m.addons.add(o, sa) f = tutils.tflow() f.request.content = b"foo" self.invoke(m, "request", f) assert f.request.content == b"bar" f = tutils.tflow(resp=True) f.response.content = b"foo" self.invoke(m, "response", f) assert f.response.content == b"bar"
def test_simple(self): o = options.Options( replacements = [ ("~q", "foo", "bar"), ("~s", "foo", "bar"), ] ) m = master.Master(o, proxy.DummyServer()) sa = replace.Replace() m.addons.add(sa) f = tutils.tflow() f.request.content = b"foo" m.request(f) assert f.request.content == b"bar" f = tutils.tflow(resp=True) f.response.content = b"foo" m.response(f) assert f.response.content == b"bar"