@@ -133,6 +133,32 @@ def test_encrypted_parquet_write_read(tempdir, data_table):
133
133
assert data_table .equals (result_table )
134
134
135
135
136
+ def test_uniform_encrypted_parquet_write_read (tempdir , data_table ):
137
+ """Write an encrypted parquet, verify it's encrypted, and then read it."""
138
+ path = tempdir / PARQUET_NAME
139
+
140
+ # Encrypt the footer and all columns with the footer key,
141
+ encryption_config = pe .EncryptionConfiguration (
142
+ footer_key = FOOTER_KEY_NAME ,
143
+ uniform_encryption = True ,
144
+ encryption_algorithm = "AES_GCM_V1" ,
145
+ cache_lifetime = timedelta (minutes = 5.0 ),
146
+ data_key_length_bits = 256 )
147
+
148
+ kms_connection_config , crypto_factory = write_encrypted_file (
149
+ path , data_table , FOOTER_KEY_NAME , COL_KEY_NAME , FOOTER_KEY , b"" ,
150
+ encryption_config )
151
+
152
+ verify_file_encrypted (path )
153
+
154
+ # Read with decryption properties
155
+ decryption_config = pe .DecryptionConfiguration (
156
+ cache_lifetime = timedelta (minutes = 5.0 ))
157
+ result_table = read_encrypted_parquet (
158
+ path , decryption_config , kms_connection_config , crypto_factory )
159
+ assert data_table .equals (result_table )
160
+
161
+
136
162
def write_encrypted_parquet (path , table , encryption_config ,
137
163
kms_connection_config , crypto_factory ):
138
164
file_encryption_properties = crypto_factory .file_encryption_properties (
@@ -241,6 +267,26 @@ def test_encrypted_parquet_write_no_col_key(tempdir, data_table):
241
267
FOOTER_KEY , b"" , encryption_config )
242
268
243
269
270
+ def test_encrypted_parquet_write_col_key_and_uniform_encryption (tempdir , data_table ):
271
+ """Write an encrypted parquet, but give only footer key,
272
+ without column key."""
273
+ path = tempdir / 'encrypted_table_col_key_and_uniform_encryption.in_mem.parquet'
274
+
275
+ # Encrypt the footer with the footer key
276
+ encryption_config = pe .EncryptionConfiguration (
277
+ footer_key = FOOTER_KEY_NAME ,
278
+ column_keys = {
279
+ COL_KEY_NAME : ["a" , "b" ],
280
+ },
281
+ uniform_encryption = True )
282
+
283
+ with pytest .raises (OSError ,
284
+ match = r"Cannot set both column_keys and uniform_encryption" ):
285
+ # Write with encryption properties
286
+ write_encrypted_file (path , data_table , FOOTER_KEY_NAME , COL_KEY_NAME ,
287
+ FOOTER_KEY , b"" , encryption_config )
288
+
289
+
244
290
def test_encrypted_parquet_write_kms_error (tempdir , data_table ,
245
291
basic_encryption_config ):
246
292
"""Write an encrypted parquet, but raise KeyError in KmsClient."""
0 commit comments