def test_config(self): sc = stickycookie.StickyCookie() o = options.Options(stickycookie = "~b") tutils.raises( "invalid filter", sc.configure, o, o.keys() )
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 default_addons(): return [ core.Core(), core_option_validation.CoreOptionValidation(), allowremote.AllowRemote(), anticache.AntiCache(), anticomp.AntiComp(), check_alpn.CheckALPN(), check_ca.CheckCA(), clientplayback.ClientPlayback(), cut.Cut(), disable_h2c.DisableH2C(), export.Export(), onboarding.Onboarding(), proxyauth.ProxyAuth(), replace.Replace(), script.ScriptLoader(), serverplayback.ServerPlayback(), setheaders.SetHeaders(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), streambodies.StreamBodies(), save.Save(), upstream_auth.UpstreamAuth(), ]
def test_request(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: tctx.configure(sc, stickycookie=".*") f = self._response(sc, "SSID=mooo", "www.google.com") assert "cookie" not in f.request.headers sc.request(f) assert "cookie" in f.request.headers
def test_config(self): sc = stickycookie.StickyCookie() with taddons.context(sc) as tctx: with pytest.raises(Exception, match="Invalid filter expression"): tctx.configure(sc, stickycookie="~b") tctx.configure(sc, stickycookie="foo") assert sc.flt tctx.configure(sc, stickycookie=None) assert not sc.flt
def test_config(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: with pytest.raises("invalid filter"): tctx.configure(sc, stickycookie="~b") tctx.configure(sc, stickycookie="foo") assert sc.flt tctx.configure(sc, stickycookie=None) assert not sc.flt
def test_response_delete(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: tctx.configure(sc, stickycookie=".*") # Test that a cookie is be deleted # by setting the expire time in the past f = self._response(sc, "duffer=zafar; Path=/", "www.google.com") f.response.headers["Set-Cookie"] = "duffer=; Expires=Thu, 01-Jan-1970 00:00:00 GMT" sc.response(f) assert not sc.jar.keys()
def test_response_multiple(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: tctx.configure(sc, stickycookie=".*") # Test setting of multiple cookies c1 = "somecookie=test; Path=/" c2 = "othercookie=helloworld; Path=/" f = self._response(sc, c1, "www.google.com") f.response.headers["Set-Cookie"] = c2 sc.response(f) googlekey = list(sc.jar.keys())[0] assert len(sc.jar[googlekey].keys()) == 2
def test_response_overwrite(self): sc = stickycookie.StickyCookie() with taddons.context(sc) as tctx: tctx.configure(sc, stickycookie=".*") # Test overwriting of a cookie value c1 = "somecookie=helloworld; Path=/" c2 = "somecookie=newvalue; Path=/" f = self._response(sc, c1, "www.google.com") f.response.headers["Set-Cookie"] = c2 sc.response(f) googlekey = list(sc.jar.keys())[0] assert len(sc.jar[googlekey]) == 1 assert sc.jar[googlekey]["somecookie"] == "newvalue"
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): sc = stickycookie.StickyCookie() with taddons.context(sc) as tctx: tctx.configure(sc, stickycookie=".*") f = tflow.tflow(resp=True) f.response.headers["set-cookie"] = "foo=bar" sc.request(f) sc.response(f) assert sc.jar assert "cookie" not in f.request.headers f = f.copy() sc.request(f) assert f.request.headers["cookie"] == "foo=bar"
def test_response(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: tctx.configure(sc, stickycookie=".*") c = "SSID=mooo; domain=.google.com, FOO=bar; Domain=.google.com; Path=/; " \ "Expires=Wed, 13-Jan-2021 22:23:01 GMT; Secure; " self._response(sc, c, "host") assert not sc.jar.keys() self._response(sc, c, "www.google.com") assert sc.jar.keys() sc.jar.clear() self._response(sc, "SSID=mooo", "www.google.com") assert list(sc.jar.keys())[0] == ('www.google.com', 80, '/')
def test_response_weird(self): sc = stickycookie.StickyCookie() with taddons.context() as tctx: tctx.configure(sc, stickycookie=".*") # Test setting of weird cookie keys f = tflow.tflow(req=ntutils.treq(host="www.google.com", port=80), resp=True) cs = [ "foo/bar=hello", "foo:bar=world", "foo@bar=fizz", ] for c in cs: f.response.headers["Set-Cookie"] = c sc.response(f) googlekey = list(sc.jar.keys())[0] assert len(sc.jar[googlekey].keys()) == len(cs)
def default_addons(): return [ onboarding.Onboarding(), proxyauth.ProxyAuth(), anticache.AntiCache(), anticomp.AntiComp(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), script.ScriptLoader(), streamfile.StreamFile(), streambodies.StreamBodies(), replace.Replace(), setheaders.SetHeaders(), serverplayback.ServerPlayback(), clientplayback.ClientPlayback(), upstream_auth.UpstreamAuth(), disable_h2c_upgrade.DisableH2CleartextUpgrade(), ]
def default_addons(): return [ core.Core(), browser.Browser(), block.Block(), anticache.AntiCache(), anticomp.AntiComp(), check_ca.CheckCA(), clientplayback.ClientPlayback(), cut.Cut(), disable_h2c.DisableH2C(), export.Export(), onboarding.Onboarding(), proxyauth.ProxyAuth(), replace.Replace(), script.ScriptLoader(), serverplayback.ServerPlayback(), setheaders.SetHeaders(), stickyauth.StickyAuth(), stickycookie.StickyCookie(), streambodies.StreamBodies(), save.Save(), upstream_auth.UpstreamAuth(), ]
def mk(self): o = options.Options(stickycookie = ".*") m = master.Master(o, proxy.DummyServer()) sc = stickycookie.StickyCookie() m.addons.add(sc) return m, sc