@@ -682,10 +682,14 @@ async fn test_detect_certificate_rotation() {
682
682
let first_tls_data_client = create_cert ( hostname1) ;
683
683
let second_tls_data_client = create_cert ( hostname1) ;
684
684
685
- std:: fs:: write ( & cert_file, tls_data1. cert ) . unwrap ( ) ;
686
- std:: fs:: write ( & key_file, tls_data1. key ) . unwrap ( ) ;
687
- std:: fs:: write ( & first_client_ca, first_tls_data_client. cert . clone ( ) ) . unwrap ( ) ;
688
- std:: fs:: write ( & second_client_ca, second_tls_data_client. cert . clone ( ) ) . unwrap ( ) ;
685
+ fs:: write ( & cert_file, tls_data1. cert ) . await . unwrap ( ) ;
686
+ fs:: write ( & key_file, tls_data1. key ) . await . unwrap ( ) ;
687
+ fs:: write ( & first_client_ca, first_tls_data_client. cert . clone ( ) )
688
+ . await
689
+ . unwrap ( ) ;
690
+ fs:: write ( & second_client_ca, second_tls_data_client. cert . clone ( ) )
691
+ . await
692
+ . unwrap ( ) ;
689
693
690
694
let mut config = default_test_config ( ) ;
691
695
config. tls_config = Some ( policy_server:: config:: TlsConfig {
@@ -728,7 +732,7 @@ async fn test_detect_certificate_rotation() {
728
732
let tls_data2 = create_cert ( hostname2) ;
729
733
730
734
// write only the cert file
731
- std :: fs:: write ( & cert_file, tls_data2. cert . clone ( ) ) . unwrap ( ) ;
735
+ fs:: write ( & cert_file, tls_data2. cert . clone ( ) ) . await . unwrap ( ) ;
732
736
733
737
// give inotify some time to ensure it detected the cert change
734
738
tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 4 ) ) . await ;
@@ -739,7 +743,7 @@ async fn test_detect_certificate_rotation() {
739
743
. expect ( "certificate should not have been changed" ) ;
740
744
741
745
// write only the key file
742
- std :: fs:: write ( & key_file, tls_data2. key . clone ( ) ) . unwrap ( ) ;
746
+ fs:: write ( & key_file, tls_data2. key . clone ( ) ) . await . unwrap ( ) ;
743
747
744
748
// give inotify some time to ensure it detected the cert change,
745
749
// also give axum some time to complete the certificate reload
@@ -752,15 +756,19 @@ async fn test_detect_certificate_rotation() {
752
756
let first_tls_data_client2 = create_cert ( hostname2) ;
753
757
754
758
// write only the cert file
755
- std:: fs:: write ( & first_client_ca, first_tls_data_client2. cert . clone ( ) ) . unwrap ( ) ;
759
+ fs:: write ( & first_client_ca, first_tls_data_client2. cert . clone ( ) )
760
+ . await
761
+ . unwrap ( ) ;
756
762
757
763
// give inotify some time to ensure it detected the cert change
758
764
tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 4 ) ) . await ;
759
765
760
766
let second_tls_data_client2 = create_cert ( hostname2) ;
761
767
762
768
// write only the cert file
763
- std:: fs:: write ( & second_client_ca, second_tls_data_client2. cert . clone ( ) ) . unwrap ( ) ;
769
+ fs:: write ( & second_client_ca, second_tls_data_client2. cert . clone ( ) )
770
+ . await
771
+ . unwrap ( ) ;
764
772
765
773
// give inotify some time to ensure it detected the cert change
766
774
tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 4 ) ) . await ;
@@ -1018,26 +1026,31 @@ async fn test_tls(
1018
1026
let key_file = certs_dir. path ( ) . join ( "policy-server-key.pem" ) ;
1019
1027
1020
1028
if let Some ( ref tls_data) = server_tls_data {
1021
- std :: fs:: write ( & cert_file, tls_data. cert . clone ( ) ) . unwrap ( ) ;
1022
- std :: fs:: write ( & key_file, tls_data. key . clone ( ) ) . unwrap ( ) ;
1029
+ fs:: write ( & cert_file, tls_data. cert . clone ( ) ) . await . unwrap ( ) ;
1030
+ fs:: write ( & key_file, tls_data. key . clone ( ) ) . await . unwrap ( ) ;
1023
1031
}
1024
1032
1025
1033
// Client CA pem file, cert data and key data
1026
1034
let clients_cas_info: Vec < ( PathBuf , String , String ) > =
1027
1035
if let Some ( ref tls_data) = client_tls_data {
1028
- tls_data
1036
+ let tls_data : Vec < ( PathBuf , String , String ) > = tls_data
1029
1037
. iter ( )
1030
1038
. enumerate ( )
1031
1039
. map ( |( i, tls_data) | {
1032
1040
let client_ca = certs_dir
1033
1041
. path ( )
1034
1042
. join ( format ! ( "client_cert_{}.pem" , i) )
1035
1043
. to_owned ( ) ;
1036
- std:: fs:: write ( & client_ca, tls_data. cert . clone ( ) )
1037
- . expect ( "failed to write client CA file" ) ;
1044
+
1038
1045
( client_ca, tls_data. cert . clone ( ) , tls_data. key . clone ( ) )
1039
1046
} )
1040
- . collect ( )
1047
+ . collect ( ) ;
1048
+
1049
+ for ( client_ca, cert, _) in & tls_data {
1050
+ fs:: write ( & client_ca, cert. clone ( ) ) . await . unwrap ( ) ;
1051
+ }
1052
+
1053
+ tls_data
1041
1054
} else {
1042
1055
vec ! [ ]
1043
1056
} ;
0 commit comments