pitrou commented on code in PR #39623:
URL: https://github.com/apache/arrow/pull/39623#discussion_r1521652024


##########
python/pyarrow/tests/test_dataset_encryption.py:
##########
@@ -151,3 +155,61 @@ def test_write_dataset_parquet_without_encryption():
 
     with pytest.raises(NotImplementedError):
         _ = pformat.make_write_options(encryption_config="some value")
+
+
[email protected](
+    encryption_unavailable, reason="Parquet Encryption is not currently 
enabled"
+)
+def test_large_row_encryption_decryption():
+    """Test encryption and decryption of a large number of rows."""
+
+    class NoOpKmsClient(pe.KmsClient):
+        def __init__(self):
+            super().__init__()
+
+        def wrap_key(self, key_bytes: bytes, _: str) -> bytes:
+            b = base64.b64encode(key_bytes)
+            return b
+
+        def unwrap_key(self, wrapped_key: bytes, _: str) -> bytes:
+            b = base64.b64decode(wrapped_key)
+            return b
+
+    row_count = pow(2, 15) + 1
+    table = pa.Table.from_arrays(
+        [pa.array(np.random.rand(row_count), type=pa.float32())], names=["foo"]
+    )
+
+    kms_config = pe.KmsConnectionConfig()
+    crypto_factory = pe.CryptoFactory(lambda _: NoOpKmsClient())
+    encryption_config = pe.EncryptionConfiguration(
+        footer_key="UNIMPORTANT_KEY",
+        column_keys={"UNIMPORTANT_KEY": ["foo"]},
+        double_wrapping=True,
+        plaintext_footer=False,
+        data_key_length_bits=128,
+    )
+    pqe_config = ds.ParquetEncryptionConfig(
+        crypto_factory, kms_config, encryption_config
+    )
+    pqd_config = ds.ParquetDecryptionConfig(
+        crypto_factory, kms_config, pe.DecryptionConfiguration()
+    )
+    scan_options = ds.ParquetFragmentScanOptions(decryption_config=pqd_config)
+    file_format = 
ds.ParquetFileFormat(default_fragment_scan_options=scan_options)
+    write_options = 
file_format.make_write_options(encryption_config=pqe_config)
+    file_decryption_properties = 
crypto_factory.file_decryption_properties(kms_config)
+
+    with tempfile.TemporaryDirectory() as tempdir:

Review Comment:
   No problem a priori with this, but within tests we tend to use the `tmpdir` 
fixture provided by pytest:
   https://docs.pytest.org/en/6.2.x/tmpdir.html#the-tmpdir-fixture
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to