示例#1
0
    def testBinaryDataExportDisabled(self):
        response = rdf_client_fs.BlobImageChunkDescriptor()
        response.digest = b"\x00\xff\x00\xff\x00"

        args = bigquery_plugin.BigQueryOutputPluginArgs()
        args.base64_bytes_export = False

        output = self.ProcessResponses(plugin_args=args, responses=[response])

        self.assertLen(output, 1)
        _, filedesc, _, _ = output[0]

        with gzip.GzipFile(mode="r", fileobj=filedesc) as filedesc:
            content = json.Parse(filedesc.read().decode("utf-8"))

        self.assertNotIn("digest", content)
示例#2
0
    def UploadChunk(self, chunk):
        """Uploads a single chunk to the transfer store flow.

    Args:
      chunk: A chunk to upload.

    Returns:
      A `BlobImageChunkDescriptor` object.
    """
        blob = _CompressedDataBlob(chunk)

        self._action.ChargeBytesToSession(len(chunk.data))
        self._action.SendReply(blob,
                               session_id=self._TRANSFER_STORE_SESSION_ID)

        return rdf_client_fs.BlobImageChunkDescriptor(digest=hashlib.sha256(
            chunk.data).digest(),
                                                      offset=chunk.offset,
                                                      length=len(chunk.data))