Esempio n. 1
0
 def _flowfile(self, path):
     f = open(path, "w")
     fw = flow.FlowWriter(f)
     t = tutils.tflow_full()
     t.response = tutils.tresp(t.request)
     fw.add(t)
     f.close()
Esempio n. 2
0
    def __init__(self, server, options, sessionFactory):
        FlowMaster.__init__(self, server, flow.State())

        self.sessionFactory = sessionFactory
        self.o = options
        self.flows = FlowCollection()
        self.anticache = options.anticache
        self.anticomp = options.anticomp

        if options.stickycookie:
            self.set_stickycookie(options.stickycookie)

        if options.stickyauth:
            self.set_stickyauth(options.stickyauth)

        if options.wfile:
            path = os.path.abspath(os.path.expanduser(options.wfile))
            directory = os.path.split(path)[0]
            if not os.path.exists(directory):
                os.makedirs(directory)
            try:
                f = file(path, "wb")
                self.fwriter = flow.FlowWriter(f)
            except IOError, v:
                raise Exception(v.strerror)
Esempio n. 3
0
    def test_replay(self):
        cs = StringIO()

        o = dump.Options(server_replay="nonexistent", kill=True)
        libpry.raises(dump.DumpError, dump.DumpMaster, None, o, None, outfile=cs)

        t = self.tmpdir()
        p = os.path.join(t, "rep")
        f = open(p, "w")
        fw = flow.FlowWriter(f)
        t = tutils.tflow_full()
        t.response = tutils.tresp(t.request)
        fw.add(t)
        f.close()

        o = dump.Options(server_replay=p, kill=True)
        m = dump.DumpMaster(None, o, None, outfile=cs)
        
        self._cycle(m, "content")
        self._cycle(m, "content")

        o = dump.Options(server_replay=p, kill=False)
        m = dump.DumpMaster(None, o, None, outfile=cs)
        self._cycle(m, "nonexistent")

        o = dump.Options(client_replay=p, kill=False)
        m = dump.DumpMaster(None, o, None, outfile=cs)
Esempio n. 4
0
    def test_roundtrip(self):
        sio = StringIO()
        f = tutils.tflow()
        w = flow.FlowWriter(sio)
        w.add(f)

        sio.seek(0)
        r = flow.FlowReader(sio)
        l = list(r.stream())
        assert len(l) == 1
        assert l[0] == f
Esempio n. 5
0
    def _treader(self):
        sio = StringIO()
        w = flow.FlowWriter(sio)
        for i in range(3):
            f = tutils.tflow(resp=True)
            w.add(f)
        for i in range(3):
            f = tutils.tflow(err=True)
            w.add(f)

        sio.seek(0)
        return flow.FlowReader(sio)
Esempio n. 6
0
    def _treader(self):
        sio = StringIO()
        w = flow.FlowWriter(sio)
        for i in range(3):
            f = tutils.tflow_full()
            w.add(f)
        for i in range(3):
            f = tutils.tflow_err()
            w.add(f)

        sio.seek(0)
        return flow.FlowReader(sio)
Esempio n. 7
0
    def test_roundtrip(self):
        sio = StringIO()
        f = tutils.tflow()
        f.request.content = "".join(chr(i) for i in range(255))
        w = flow.FlowWriter(sio)
        w.add(f)

        sio.seek(0)
        r = flow.FlowReader(sio)
        l = list(r.stream())
        assert len(l) == 1

        f2 = l[0]
        assert f2._get_state() == f._get_state()
        assert f2.request.assemble() == f.request.assemble()
Esempio n. 8
0
 def _flowfile(self, path):
     f = open(path, "wb")
     fw = flow.FlowWriter(f)
     t = tutils.tflow(resp=True)
     fw.add(t)
     f.close()