Skip to content

Commit 537e296

Browse files
committed
apacheGH-51351: [Python][Parquet] Update encryption tests for default KMS configuration
1 parent 0feea24 commit 537e296

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎python/pyarrow/tests/parquet/test_encryption.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,14 @@ def test_key_rotation_reads_kms_url_from_file(reusable_tempdir, data_table,
763763
rotation_config, path, read_kms_url=read_kms_url)
764764

765765
if read_kms_url:
766-
# The empty config provided is used to wrap new keys,
767-
# and the config from the file was used to unwrap the original keys.
768-
assert created_configs == [("", ""), (KMS_INSTANCE_ID, KMS_INSTANCE_URL)]
766+
# Defaults are used to wrap new keys, and the config from the file
767+
# is used to unwrap the original keys.
768+
assert created_configs == [
769+
("DEFAULT", "DEFAULT"), (KMS_INSTANCE_ID, KMS_INSTANCE_URL)]
769770
else:
770771
# The default URL is used when unwrapping the original keys.
771-
assert created_configs == [("", ""), (KMS_INSTANCE_ID, "DEFAULT")]
772+
assert created_configs == [
773+
("DEFAULT", "DEFAULT"), (KMS_INSTANCE_ID, "DEFAULT")]
772774

773775
# New key material always uses the provided KMS connection configuration
774776
rotated_keys = read_external_keys_to_dict(path)

‎python/pyarrow/tests/test_dataset_encryption.py‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ def assert_decrypts(
133133
encrypt_kms_connection_config = create_kms_connection_config(write_keys)
134134
decrypt_kms_connection_config = create_kms_connection_config(read_keys)
135135

136-
crypto_factory = pe.CryptoFactory(kms_factory)
136+
encrypt_crypto_factory = pe.CryptoFactory(kms_factory)
137+
# Keep the writer's cached keys out of the reader's configuration.
138+
decrypt_crypto_factory = pe.CryptoFactory(kms_factory)
137139
parquet_encryption_cfg = ds.ParquetEncryptionConfig(
138-
crypto_factory, encrypt_kms_connection_config, encryption_config
140+
encrypt_crypto_factory, encrypt_kms_connection_config, encryption_config
139141
)
140142
parquet_decryption_cfg = ds.ParquetDecryptionConfig(
141-
crypto_factory, decrypt_kms_connection_config, decryption_config
143+
decrypt_crypto_factory, decrypt_kms_connection_config, decryption_config
142144
)
143145

144146
# create write_options with dataset encryption config
@@ -176,7 +178,7 @@ def assert_decrypts(
176178
assert table.select(read_columns).equals(dataset.to_table(read_columns))
177179

178180
# set decryption properties for parquet fragment scan options
179-
decryption_properties = crypto_factory.file_decryption_properties(
181+
decryption_properties = decrypt_crypto_factory.file_decryption_properties(
180182
decrypt_kms_connection_config, decryption_config)
181183
pq_scan_opts = ds.ParquetFragmentScanOptions(
182184
decryption_properties=decryption_properties

0 commit comments

Comments
 (0)