コード例 #1
0
    def test_rejects_unsolicited_transfers(self):
        self.station.set_real_id(True)

        object_body = "foo bar baz butts lol"

        git_pb = GitObject()
        git_pb.data = object_body
        git_pb.type = pygit2.GIT_OBJ_BLOB
        self.station.payload = git_pb.SerializeToString()
        self.assertRaises(UnsolicitedTransfer, handle_transfer, self.station)
コード例 #2
0
def handle_fetchobject(self):
    log.info("Handling FETCHOBJECT")
    git_obj = self.station[self.payload]
    git_pb = GitObject()

    git_pb.type = git_obj.type
    git_pb.data = git_obj.read_raw()

    response = self._Response(self.id, "TRANSFER", git_pb.SerializeToString())
    self.stream.enqueue(response)
    self.TERMINATE()
コード例 #3
0
    def test_rejects_invalid_transfers(self):
        self.station.set_real_id(True)

        object_body = "foo bar baz butts lol"

        req = MockRequest(self.station.id)
        req.payload = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef"

        self.station.station.registry.register(req)

        git_pb = GitObject()
        git_pb.data = object_body
        git_pb.type = pygit2.GIT_OBJ_BLOB
        self.station.payload = git_pb.SerializeToString()
        self.assertRaises(AssertionError, handle_transfer, self.station)
コード例 #4
0
    def test_transfer_object(self):
        self.station.set_real_id(True)

        object_body = "foo bar baz butts lol"
        oid = pygit2.hash(object_body)

        req = MockRequest(self.station.id)
        req.payload = oid2hex(oid)

        self.station.station.registry.register(req)

        git_pb = GitObject()
        git_pb.data = object_body
        git_pb.type = pygit2.GIT_OBJ_BLOB
        self.station.payload = git_pb.SerializeToString()
        handle_transfer(self.station)

        self.assertTrue(self.station.station[oid2hex(oid)], object_body)