@@ -573,7 +573,10 @@ mod tests {
573
573
use std:: path:: PathBuf ;
574
574
use std:: time:: Duration ;
575
575
576
- use pcs:: { DcapArtifactIssuer , EnclaveIdentity , Fmspc , PckID , Platform , TcbEvaluationDataNumbers , RawTcbEvaluationDataNumbers } ;
576
+ use pcs:: {
577
+ DcapArtifactIssuer , EnclaveIdentity , Fmspc , PckID , Platform , RawTcbEvaluationDataNumbers ,
578
+ TcbEvaluationDataNumbers ,
579
+ } ;
577
580
578
581
use crate :: provisioning_client:: {
579
582
test_helpers, IntelProvisioningClientBuilder , PcsVersion , ProvisioningClient ,
@@ -585,10 +588,12 @@ mod tests {
585
588
const OUTPUT_TEST_DIR : & str = "./tests/data/" ;
586
589
const TIME_RETRY_TIMEOUT : Duration = Duration :: from_secs ( 180 ) ;
587
590
588
- fn pcs_api_key ( ) -> String {
589
- let api_key = std:: env:: var ( "PCS_API_KEY" ) . expect ( "PCS_API_KEY must be set" ) ;
591
+ fn pcs_api_key ( ) -> Option < String > {
592
+ let api_key_option = std:: env:: var ( "PCS_API_KEY" ) . ok ( ) ;
593
+ if let Some ( api_key) = api_key_option. as_ref ( ) {
590
594
assert ! ( !api_key. is_empty( ) , "Empty string in PCS_API_KEY" ) ;
591
- api_key
595
+ }
596
+ api_key_option
592
597
}
593
598
594
599
#[ test]
@@ -597,7 +602,13 @@ mod tests {
597
602
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
598
603
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
599
604
if api_version == PcsVersion :: V3 {
600
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
605
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
606
+ intel_builder. set_api_key ( pcs_api_key) ;
607
+ } else {
608
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
609
+ // So we no longer force to test it.
610
+ continue ;
611
+ }
601
612
}
602
613
let client = intel_builder. build ( reqwest_client ( ) ) ;
603
614
@@ -624,7 +635,13 @@ mod tests {
624
635
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
625
636
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
626
637
if api_version == PcsVersion :: V3 {
627
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
638
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
639
+ intel_builder. set_api_key ( pcs_api_key) ;
640
+ } else {
641
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
642
+ // So we no longer force to test it.
643
+ continue ;
644
+ }
628
645
}
629
646
let client = intel_builder. build ( reqwest_client ( ) ) ;
630
647
@@ -677,7 +694,13 @@ mod tests {
677
694
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
678
695
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
679
696
if api_version == PcsVersion :: V3 {
680
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
697
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
698
+ intel_builder. set_api_key ( pcs_api_key) ;
699
+ } else {
700
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
701
+ // So we no longer force to test it.
702
+ continue ;
703
+ }
681
704
}
682
705
let client = intel_builder. build ( reqwest_client ( ) ) ;
683
706
for pckid in PckID :: parse_file ( & PathBuf :: from ( PCKID_TEST_FILE ) . as_path ( ) )
@@ -709,11 +732,25 @@ mod tests {
709
732
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
710
733
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
711
734
if api_version == PcsVersion :: V3 {
712
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
735
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
736
+ intel_builder. set_api_key ( pcs_api_key) ;
737
+ } else {
738
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
739
+ // So we no longer force to test it.
740
+ continue ;
741
+ }
713
742
}
714
743
let client = intel_builder. build ( reqwest_client ( ) ) ;
715
- let crl_processor = client. pckcrl ( DcapArtifactIssuer :: PCKProcessorCA ) . unwrap ( ) . crl_as_pem ( ) . to_owned ( ) ;
716
- let crl_platform = client. pckcrl ( DcapArtifactIssuer :: PCKPlatformCA ) . unwrap ( ) . crl_as_pem ( ) . to_owned ( ) ;
744
+ let crl_processor = client
745
+ . pckcrl ( DcapArtifactIssuer :: PCKProcessorCA )
746
+ . unwrap ( )
747
+ . crl_as_pem ( )
748
+ . to_owned ( ) ;
749
+ let crl_platform = client
750
+ . pckcrl ( DcapArtifactIssuer :: PCKPlatformCA )
751
+ . unwrap ( )
752
+ . crl_as_pem ( )
753
+ . to_owned ( ) ;
717
754
for pckid in PckID :: parse_file ( & PathBuf :: from ( PCKID_TEST_FILE ) . as_path ( ) )
718
755
. unwrap ( )
719
756
. iter ( )
@@ -727,7 +764,9 @@ mod tests {
727
764
None ,
728
765
)
729
766
. unwrap ( ) ;
730
- let pck = pck. clone ( ) . verify ( & root_cas, Some ( & crl_processor) )
767
+ let pck = pck
768
+ . clone ( )
769
+ . verify ( & root_cas, Some ( & crl_processor) )
731
770
. or ( pck. clone ( ) . verify ( & root_cas, Some ( & crl_platform) ) )
732
771
. unwrap ( ) ;
733
772
@@ -797,7 +836,13 @@ mod tests {
797
836
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
798
837
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
799
838
if api_version == PcsVersion :: V3 {
800
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
839
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
840
+ intel_builder. set_api_key ( pcs_api_key) ;
841
+ } else {
842
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
843
+ // So we no longer force to test it.
844
+ continue ;
845
+ }
801
846
}
802
847
let client = intel_builder. build ( reqwest_client ( ) ) ;
803
848
for pckid in PckID :: parse_file ( & PathBuf :: from ( PCKID_TEST_FILE ) . as_path ( ) )
@@ -829,7 +874,11 @@ mod tests {
829
874
. unwrap ( ) ;
830
875
let fmspc = pckcerts. fmspc ( ) . unwrap ( ) ;
831
876
832
- let evaluation_data_numbers = client. tcb_evaluation_data_numbers ( ) . unwrap ( ) . evaluation_data_numbers ( ) . unwrap ( ) ;
877
+ let evaluation_data_numbers = client
878
+ . tcb_evaluation_data_numbers ( )
879
+ . unwrap ( )
880
+ . evaluation_data_numbers ( )
881
+ . unwrap ( ) ;
833
882
834
883
for number in evaluation_data_numbers. numbers ( ) {
835
884
assert ! ( client
@@ -846,7 +895,13 @@ mod tests {
846
895
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
847
896
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
848
897
if api_version == PcsVersion :: V3 {
849
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
898
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
899
+ intel_builder. set_api_key ( pcs_api_key) ;
900
+ } else {
901
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
902
+ // So we no longer force to test it.
903
+ continue ;
904
+ }
850
905
}
851
906
let client = intel_builder. build ( reqwest_client ( ) ) ;
852
907
for pckid in PckID :: parse_file ( & PathBuf :: from ( PCKID_TEST_FILE ) . as_path ( ) )
@@ -867,7 +922,10 @@ mod tests {
867
922
868
923
let ( cached_tcb_info, _) = {
869
924
let mut hasher = DefaultHasher :: new ( ) ;
870
- let input = client. tcbinfo_service . pcs_service ( ) . build_input ( & fmspc, None ) ;
925
+ let input = client
926
+ . tcbinfo_service
927
+ . pcs_service ( )
928
+ . build_input ( & fmspc, None ) ;
871
929
input. hash ( & mut hasher) ;
872
930
873
931
cache
@@ -889,12 +947,21 @@ mod tests {
889
947
890
948
#[ test]
891
949
pub fn pckcrl ( ) {
892
- for ca in [ DcapArtifactIssuer :: PCKProcessorCA , DcapArtifactIssuer :: PCKPlatformCA ] {
950
+ for ca in [
951
+ DcapArtifactIssuer :: PCKProcessorCA ,
952
+ DcapArtifactIssuer :: PCKPlatformCA ,
953
+ ] {
893
954
for api_version in [ PcsVersion :: V3 , PcsVersion :: V4 ] {
894
955
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
895
956
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
896
957
if api_version == PcsVersion :: V3 {
897
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
958
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
959
+ intel_builder. set_api_key ( pcs_api_key) ;
960
+ } else {
961
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
962
+ // So we no longer force to test it.
963
+ continue ;
964
+ }
898
965
}
899
966
let client = intel_builder. build ( reqwest_client ( ) ) ;
900
967
assert ! ( client
@@ -907,12 +974,21 @@ mod tests {
907
974
908
975
#[ test]
909
976
pub fn pckcrl_cached ( ) {
910
- for ca in [ DcapArtifactIssuer :: PCKProcessorCA , DcapArtifactIssuer :: PCKPlatformCA ] {
977
+ for ca in [
978
+ DcapArtifactIssuer :: PCKProcessorCA ,
979
+ DcapArtifactIssuer :: PCKPlatformCA ,
980
+ ] {
911
981
for api_version in [ PcsVersion :: V3 , PcsVersion :: V4 ] {
912
982
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
913
983
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
914
984
if api_version == PcsVersion :: V3 {
915
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
985
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
986
+ intel_builder. set_api_key ( pcs_api_key) ;
987
+ } else {
988
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
989
+ // So we no longer force to test it.
990
+ continue ;
991
+ }
916
992
}
917
993
let client = intel_builder. build ( reqwest_client ( ) ) ;
918
994
let pckcrl = client. pckcrl ( ca) . unwrap ( ) ;
@@ -951,7 +1027,13 @@ mod tests {
951
1027
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
952
1028
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
953
1029
if api_version == PcsVersion :: V3 {
954
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
1030
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
1031
+ intel_builder. set_api_key ( pcs_api_key) ;
1032
+ } else {
1033
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
1034
+ // So we no longer force to test it.
1035
+ continue ;
1036
+ }
955
1037
}
956
1038
let client = intel_builder. build ( reqwest_client ( ) ) ;
957
1039
let qe_id = client. qe_identity ( None ) ;
@@ -966,7 +1048,13 @@ mod tests {
966
1048
let mut intel_builder = IntelProvisioningClientBuilder :: new ( api_version)
967
1049
. set_retry_timeout ( TIME_RETRY_TIMEOUT ) ;
968
1050
if api_version == PcsVersion :: V3 {
969
- intel_builder. set_api_key ( pcs_api_key ( ) ) ;
1051
+ if let Some ( pcs_api_key) = pcs_api_key ( ) {
1052
+ intel_builder. set_api_key ( pcs_api_key) ;
1053
+ } else {
1054
+ // Intel SGX PCS version 3 is scheduled to end of life not later than October 31, 2025.
1055
+ // So we no longer force to test it.
1056
+ continue ;
1057
+ }
970
1058
}
971
1059
let client = intel_builder. build ( reqwest_client ( ) ) ;
972
1060
let qe_id = client. qe_identity ( None ) . unwrap ( ) ;
@@ -1013,9 +1101,11 @@ mod tests {
1013
1101
assert_eq ! ( eval_numbers, eval_numbers2) ;
1014
1102
1015
1103
let fmspc = Fmspc :: try_from ( "90806f000000" ) . unwrap ( ) ;
1016
- let eval_numbers: TcbEvaluationDataNumbers = eval_numbers. verify ( & root_cas, Platform :: SGX ) . unwrap ( ) ;
1104
+ let eval_numbers: TcbEvaluationDataNumbers =
1105
+ eval_numbers. verify ( & root_cas, Platform :: SGX ) . unwrap ( ) ;
1017
1106
for number in eval_numbers. numbers ( ) . map ( |n| n. number ( ) ) {
1018
- let qe_id = client. qe_identity ( Some ( number) )
1107
+ let qe_id = client
1108
+ . qe_identity ( Some ( number) )
1019
1109
. unwrap ( )
1020
1110
. verify ( & root_cas, EnclaveIdentity :: QE )
1021
1111
. unwrap ( ) ;
0 commit comments