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