Exemple #1
0
    def test_stickycookie(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        assert "Invalid" in fm.set_stickycookie("~h")
        fm.set_stickycookie(".*")
        assert fm.stickycookie_state
        fm.set_stickycookie(None)
        assert not fm.stickycookie_state

        fm.set_stickycookie(".*")
        f = tutils.tflow(resp=True)
        f.response.headers["set-cookie"] = "foo=bar"
        fm.request(f)
        fm.response(f)
        assert fm.stickycookie_state.jar
        assert "cookie" not in f.request.headers
        f = f.copy()
        fm.request(f)
        assert f.request.headers["cookie"] == "foo=bar"
Exemple #2
0
    def test_stickyauth(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        assert "Invalid" in fm.set_stickyauth("~h")
        fm.set_stickyauth(".*")
        assert fm.stickyauth_state
        fm.set_stickyauth(None)
        assert not fm.stickyauth_state

        fm.set_stickyauth(".*")
        f = tutils.tflow(resp=True)
        f.request.headers["authorization"] = "foo"
        fm.request(f)

        f = tutils.tflow(resp=True)
        assert fm.stickyauth_state.hosts
        assert "authorization" not in f.request.headers
        fm.request(f)
        assert f.request.headers["authorization"] == "foo"
Exemple #3
0
    def test_all(self):
        s = flow.State()
        fm = flow.FlowMaster(None, None, s)
        f = tutils.tflow(req=None)
        fm.clientconnect(f.client_conn)
        f.request = HTTPRequest.wrap(netlib.tutils.treq())
        fm.request(f)
        assert s.flow_count() == 1

        f.response = HTTPResponse.wrap(netlib.tutils.tresp())
        fm.response(f)
        assert s.flow_count() == 1

        fm.clientdisconnect(f.client_conn)

        f.error = Error("msg")
        fm.error(f)

        fm.shutdown()
Exemple #4
0
    def test_all(self):
        s = flow.State()
        fm = flow.FlowMaster(None, s)
        fm.anticache = True
        fm.anticomp = True
        f = tutils.tflow(req=None)
        fm.clientconnect(f.client_conn)
        f.request = HTTPRequest.wrap(netlib.tutils.treq())
        fm.request(f)
        assert s.flow_count() == 1

        f.response = HTTPResponse.wrap(netlib.tutils.tresp())
        fm.response(f)
        assert s.flow_count() == 1

        fm.clientdisconnect(f.client_conn)

        f.error = Error("msg")
        f.error.reply = controller.DummyReply()
        fm.error(f)

        fm.load_script(tutils.test_data.path("data/scripts/a.py"))
        fm.shutdown()
Exemple #5
0
 def test_create_flow(self):
     s = flow.State()
     fm = flow.FlowMaster(None, s)
     assert fm.create_request("GET", "http", "example.com", 80, "/")
Exemple #6
0
 def test_load_flows(self):
     r = self._treader()
     s = flow.State()
     fm = flow.FlowMaster(None, s)
     fm.load_flows(r)
     assert len(s.flows) == 6
Exemple #7
0
def test_command_parsing():
    s = flow.State()
    fm = flow.FlowMaster(None, s)
    absfilepath = os.path.normcase(tutils.test_data.path("scripts/a.py"))
    s = script.Script(absfilepath, script.ScriptContext(fm))
    assert os.path.isfile(s.args[0])