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)
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)
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)