@@ -2892,7 +2892,7 @@ impl TryFrom<ConfigFileEncryptionProperties> for FileEncryptionProperties {
28922892 let key_metadata = encryption_props
28932893 . column_metadata_as_hex
28942894 . as_ref ( )
2895- . map ( |x| hex:: decode ( x ) )
2895+ . map ( hex:: decode)
28962896 . transpose ( )
28972897 . map_err ( |e| {
28982898 DataFusionError :: Configuration ( format ! ( "Unable to decode hex column metadata for column {column_name}: {e}" ) )
@@ -3723,27 +3723,36 @@ mod tests {
37233723 use crate :: config:: ColumnEncryptionProperties ;
37243724 use crate :: config:: ConfigFileEncryptionProperties ;
37253725 use parquet:: encryption:: encrypt:: FileEncryptionProperties ;
3726+ use std:: collections:: HashMap ;
3727+
3728+ let valid_footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
3729+
3730+ let mut enc = ConfigFileEncryptionProperties {
3731+ encrypt_footer : true ,
3732+ footer_key_as_hex : valid_footer_key_as_hex. clone ( ) ,
3733+ footer_key_metadata_as_hex : String :: new ( ) ,
3734+ column_encryption_properties : HashMap :: new ( ) ,
3735+ aad_prefix_as_hex : String :: new ( ) ,
3736+ store_aad_prefix : false ,
3737+ } ;
37263738
37273739 // Encryption: invalid footer key hex
3728- let mut enc = ConfigFileEncryptionProperties :: default ( ) ;
37293740 enc. footer_key_as_hex = "not_hex" . to_string ( ) ;
3730- let err = FileEncryptionProperties :: try_from ( enc)
3741+ let err = FileEncryptionProperties :: try_from ( enc. clone ( ) )
37313742 . unwrap_err ( )
37323743 . to_string ( ) ;
37333744 assert ! ( err. contains( "Unable to decode hex footer key" ) ) ;
3745+ enc. footer_key_as_hex = valid_footer_key_as_hex. clone ( ) ;
37343746
37353747 // Encryption: invalid footer key metadata hex
3736- let mut enc = ConfigFileEncryptionProperties :: default ( ) ;
3737- enc. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
37383748 enc. footer_key_metadata_as_hex = "zz" . to_string ( ) ;
3739- let err = FileEncryptionProperties :: try_from ( enc)
3749+ let err = FileEncryptionProperties :: try_from ( enc. clone ( ) )
37403750 . unwrap_err ( )
37413751 . to_string ( ) ;
37423752 assert ! ( err. contains( "Unable to decode hex footer key metadata" ) ) ;
3753+ enc. footer_key_metadata_as_hex = String :: new ( ) ;
37433754
37443755 // Encryption: invalid column key hex
3745- let mut enc = ConfigFileEncryptionProperties :: default ( ) ;
3746- enc. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
37473756 enc. column_encryption_properties . insert (
37483757 "col1" . to_string ( ) ,
37493758 ColumnEncryptionProperties {
@@ -3757,10 +3766,9 @@ mod tests {
37573766 assert ! (
37583767 err. contains( "Unable to decode hex encryption key metadata for column col1" )
37593768 ) ;
3769+ enc. column_encryption_properties . clear ( ) ;
37603770
37613771 // Encryption: invalid column metadata hex
3762- let mut enc = ConfigFileEncryptionProperties :: default ( ) ;
3763- enc. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
37643772 enc. column_encryption_properties . insert (
37653773 "col1" . to_string ( ) ,
37663774 ColumnEncryptionProperties {
@@ -3772,10 +3780,9 @@ mod tests {
37723780 . unwrap_err ( )
37733781 . to_string ( ) ;
37743782 assert ! ( err. contains( "Unable to decode hex column metadata for column col1" ) ) ;
3783+ enc. column_encryption_properties . clear ( ) ;
37753784
37763785 // Encryption: invalid AAD prefix hex
3777- let mut enc = ConfigFileEncryptionProperties :: default ( ) ;
3778- enc. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
37793786 enc. aad_prefix_as_hex = "zz" . to_string ( ) ;
37803787 let err = FileEncryptionProperties :: try_from ( enc)
37813788 . unwrap_err ( )
@@ -3789,10 +3796,18 @@ mod tests {
37893796 use crate :: config:: ColumnDecryptionProperties ;
37903797 use crate :: config:: ConfigFileDecryptionProperties ;
37913798 use parquet:: encryption:: decrypt:: FileDecryptionProperties ;
3799+ use std:: collections:: HashMap ;
3800+
3801+ let valid_footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
3802+
3803+ let mut dec = ConfigFileDecryptionProperties {
3804+ footer_key_as_hex : valid_footer_key_as_hex. clone ( ) ,
3805+ column_decryption_properties : HashMap :: new ( ) ,
3806+ aad_prefix_as_hex : String :: new ( ) ,
3807+ footer_signature_verification : true ,
3808+ } ;
37923809
37933810 // Decryption: invalid column key hex
3794- let mut dec = ConfigFileDecryptionProperties :: default ( ) ;
3795- dec. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
37963811 dec. column_decryption_properties . insert (
37973812 "col1" . to_string ( ) ,
37983813 ColumnDecryptionProperties {
@@ -3804,18 +3819,17 @@ mod tests {
38043819 . to_string ( ) ;
38053820 assert ! ( err. contains( "Could not decode hex column key" ) ) ;
38063821 assert ! ( err. contains( "col1" ) ) ;
3822+ dec. column_decryption_properties . clear ( ) ;
38073823
38083824 // Decryption: invalid footer key hex
3809- let mut dec = ConfigFileDecryptionProperties :: default ( ) ;
38103825 dec. footer_key_as_hex = "bad" . to_string ( ) ;
38113826 let err = FileDecryptionProperties :: try_from ( dec)
38123827 . unwrap_err ( )
38133828 . to_string ( ) ;
38143829 assert ! ( err. contains( "Could not decode hex footer key" ) ) ;
3830+ dec. footer_key_as_hex = valid_footer_key_as_hex;
38153831
38163832 // Decryption: invalid AAD prefix hex
3817- let mut dec = ConfigFileDecryptionProperties :: default ( ) ;
3818- dec. footer_key_as_hex = hex:: encode ( b"0123456789012345" ) ;
38193833 dec. aad_prefix_as_hex = "zz" . to_string ( ) ;
38203834 let err = FileDecryptionProperties :: try_from ( dec)
38213835 . unwrap_err ( )
0 commit comments