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)
Beispiel #2
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)
Beispiel #3
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()
Beispiel #4
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()
    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)
Beispiel #6
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)
Beispiel #7
0
def handle_transfer(self):
    git_pb = GitObject()
    git_pb.ParseFromString(self.payload)
    log.info("Handling TRANSFER of %s" % (git_pb.type))

    try:
        req = self.station.get_request(self.id)
    except KeyError:
        raise UnsolicitedTransfer

    if git_pb.type == pygit2.GIT_OBJ_BLOB:
        data_hash = utils.oid2hex(pygit2.hash(git_pb.data))
        assert req.payload == data_hash, \
            "Attempted to be sent invalid object for %s; got %s" % (req.payload, data_hash)
    ret = self.station.store.write(git_pb.type, git_pb.data)
    log.info("Wrote object %s into local db" % logger.fix_oid(ret))
    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)
Beispiel #9
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)