@@ -333,7 +333,7 @@ func TestIssuePrecertificate(t *testing.T) {
333333 test .AssertNotError (t , err , "Certificate request failed to parse" )
334334 issueReq := & capb.IssueCertificateRequest {Csr : testCase .csr , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 ()}
335335
336- profile := ca .certProfiles . profileByName ["legacy" ]
336+ profile := ca .certProfiles ["legacy" ]
337337 certDER , err := ca .issuePrecertificate (ctx , profile , issueReq )
338338 test .AssertNotError (t , err , "Failed to issue precertificate" )
339339
@@ -444,7 +444,7 @@ func TestMultipleIssuers(t *testing.T) {
444444 test .AssertNotError (t , err , "Failed to remake CA" )
445445
446446 // Test that an RSA CSR gets issuance from an RSA issuer.
447- profile := ca .certProfiles . profileByName ["legacy" ]
447+ profile := ca .certProfiles ["legacy" ]
448448 issuedCertDER , err := ca .issuePrecertificate (ctx , profile , & capb.IssueCertificateRequest {Csr : CNandSANCSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 ()})
449449 test .AssertNotError (t , err , "Failed to issue certificate" )
450450 cert , err := x509 .ParseCertificate (issuedCertDER )
@@ -529,7 +529,7 @@ func TestUnpredictableIssuance(t *testing.T) {
529529 req := & capb.IssueCertificateRequest {Csr : ECDSACSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 ()}
530530 seenE2 := false
531531 seenR3 := false
532- profile := ca .certProfiles . profileByName ["legacy" ]
532+ profile := ca .certProfiles ["legacy" ]
533533 for i := 0 ; i < 20 ; i ++ {
534534 precertDER , err := ca .issuePrecertificate (ctx , profile , req )
535535 test .AssertNotError (t , err , "Failed to issue test certificate" )
@@ -552,22 +552,11 @@ func TestMakeCertificateProfilesMap(t *testing.T) {
552552 testCtx := setup (t )
553553 test .AssertEquals (t , len (testCtx .certProfiles ), 2 )
554554
555- testProfile := issuance.ProfileConfig {
556- AllowMustStaple : false ,
557- MaxValidityPeriod : config.Duration {Duration : time .Hour * 24 * 90 },
558- MaxValidityBackdate : config.Duration {Duration : time .Hour },
559- }
560-
561- type nameToHash struct {
562- name string
563- hash [32 ]byte
564- }
565-
566555 testCases := []struct {
567556 name string
568557 profileConfigs map [string ]* issuance.ProfileConfig
569558 expectedErrSubstr string
570- expectedProfiles []nameToHash
559+ expectedProfiles []string
571560 }{
572561 {
573562 name : "nil profile map" ,
@@ -579,39 +568,17 @@ func TestMakeCertificateProfilesMap(t *testing.T) {
579568 profileConfigs : map [string ]* issuance.ProfileConfig {},
580569 expectedErrSubstr : "at least one certificate profile" ,
581570 },
582- {
583- name : "duplicate hash" ,
584- profileConfigs : map [string ]* issuance.ProfileConfig {
585- "default" : & testProfile ,
586- "default2" : & testProfile ,
587- },
588- expectedErrSubstr : "duplicate certificate profile hash" ,
589- },
590571 {
591572 name : "empty profile config" ,
592573 profileConfigs : map [string ]* issuance.ProfileConfig {
593574 "empty" : {},
594575 },
595- expectedProfiles : []nameToHash {
596- {
597- name : "empty" ,
598- hash : [32 ]byte {0xe4 , 0xf6 , 0xd , 0xa , 0xa6 , 0xd7 , 0xf3 , 0xd3 , 0xb6 , 0xa6 , 0x49 , 0x4b , 0x1c , 0x86 , 0x1b , 0x99 , 0xf6 , 0x49 , 0xc6 , 0xf9 , 0xec , 0x51 , 0xab , 0xaf , 0x20 , 0x1b , 0x20 , 0xf2 , 0x97 , 0x32 , 0x7c , 0x95 },
599- },
600- },
576+ expectedProfiles : []string {"empty" },
601577 },
602578 {
603- name : "default profiles from setup func" ,
604- profileConfigs : testCtx .certProfiles ,
605- expectedProfiles : []nameToHash {
606- {
607- name : "legacy" ,
608- hash : [32 ]byte {0xb7 , 0xd9 , 0x7e , 0xfc , 0x5a , 0xdd , 0xc7 , 0xfe , 0xc , 0xea , 0xed , 0x7b , 0x8c , 0xf5 , 0x4 , 0x57 , 0x71 , 0x97 , 0x42 , 0x80 , 0xbe , 0x4d , 0x14 , 0xa , 0x35 , 0x9a , 0x89 , 0xc3 , 0x7a , 0x57 , 0x41 , 0xb7 },
609- },
610- {
611- name : "modern" ,
612- hash : [32 ]byte {0x2e , 0x82 , 0x9b , 0xe4 , 0x4d , 0xac , 0xfc , 0x2d , 0x83 , 0xbf , 0x62 , 0xe5 , 0xe1 , 0x50 , 0xe8 , 0xba , 0xd2 , 0x66 , 0x1a , 0xb3 , 0xf2 , 0xe7 , 0xb5 , 0xf2 , 0x24 , 0x94 , 0x1f , 0x83 , 0xc6 , 0x57 , 0xe , 0x58 },
613- },
614- },
579+ name : "default profiles from setup func" ,
580+ profileConfigs : testCtx .certProfiles ,
581+ expectedProfiles : []string {"legacy" , "modern" },
615582 },
616583 }
617584
@@ -628,17 +595,14 @@ func TestMakeCertificateProfilesMap(t *testing.T) {
628595 }
629596
630597 if tc .expectedProfiles != nil {
631- test .AssertEquals (t , len (profiles . profileByName ), len (tc .expectedProfiles ))
598+ test .AssertEquals (t , len (profiles ), len (tc .expectedProfiles ))
632599 }
633600
634601 for _ , expected := range tc .expectedProfiles {
635- cpwid , ok := profiles .profileByName [expected .name ]
636- test .Assert (t , ok , fmt .Sprintf ("expected profile %q not found" , expected .name ))
637- test .AssertEquals (t , cpwid .hash , expected .hash )
602+ cpwid , ok := profiles [expected ]
603+ test .Assert (t , ok , fmt .Sprintf ("expected profile %q not found" , expected ))
638604
639- cpwid , ok = profiles .profileByHash [expected .hash ]
640- test .Assert (t , ok , fmt .Sprintf ("expected profile %q not found" , expected .hash ))
641- test .AssertEquals (t , cpwid .name , expected .name )
605+ test .AssertEquals (t , cpwid .name , expected )
642606 }
643607 })
644608 }
@@ -711,7 +675,7 @@ func TestInvalidCSRs(t *testing.T) {
711675 t .Run (testCase .name , func (t * testing.T ) {
712676 t .Parallel ()
713677 serializedCSR := mustRead (testCase .csrPath )
714- profile := ca .certProfiles . profileByName ["legacy" ]
678+ profile := ca .certProfiles ["legacy" ]
715679 issueReq := & capb.IssueCertificateRequest {Csr : serializedCSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 (), CertProfileName : "legacy" }
716680 _ , err = ca .issuePrecertificate (ctx , profile , issueReq )
717681
@@ -749,7 +713,7 @@ func TestRejectValidityTooLong(t *testing.T) {
749713 test .AssertNotError (t , err , "Failed to create CA" )
750714
751715 // Test that the CA rejects CSRs that would expire after the intermediate cert
752- profile := ca .certProfiles . profileByName ["legacy" ]
716+ profile := ca .certProfiles ["legacy" ]
753717 _ , err = ca .issuePrecertificate (ctx , profile , & capb.IssueCertificateRequest {Csr : CNandSANCSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 (), CertProfileName : "legacy" })
754718 test .AssertError (t , err , "Cannot issue a certificate that expires after the intermediate certificate" )
755719 test .AssertErrorIs (t , err , berrors .InternalServer )
@@ -842,7 +806,7 @@ func TestIssueCertificateForPrecertificate(t *testing.T) {
842806 testCtx .fc )
843807 test .AssertNotError (t , err , "Failed to create CA" )
844808
845- profile := ca .certProfiles . profileByName ["legacy" ]
809+ profile := ca .certProfiles ["legacy" ]
846810 issueReq := capb.IssueCertificateRequest {Csr : CNandSANCSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 (), CertProfileName : "legacy" }
847811 precertDER , err := ca .issuePrecertificate (ctx , profile , & issueReq )
848812 test .AssertNotError (t , err , "Failed to issue precert" )
@@ -905,7 +869,7 @@ func TestIssueCertificateForPrecertificateWithSpecificCertificateProfile(t *test
905869 test .AssertNotError (t , err , "Failed to create CA" )
906870
907871 selectedProfile := "modern"
908- certProfile , ok := ca .certProfiles . profileByName [selectedProfile ]
872+ certProfile , ok := ca .certProfiles [selectedProfile ]
909873 test .Assert (t , ok , "Certificate profile was expected to exist" )
910874
911875 issueReq := capb.IssueCertificateRequest {
@@ -1024,7 +988,7 @@ func TestIssueCertificateForPrecertificateDuplicateSerial(t *testing.T) {
1024988 t .Fatal (err )
1025989 }
1026990
1027- profile := ca .certProfiles . profileByName ["legacy" ]
991+ profile := ca .certProfiles ["legacy" ]
1028992 issueReq := capb.IssueCertificateRequest {Csr : CNandSANCSR , RegistrationID : mrand .Int63 (), OrderID : mrand .Int63 (), CertProfileName : "legacy" }
1029993 precertDER , err := ca .issuePrecertificate (ctx , profile , & issueReq )
1030994 test .AssertNotError (t , err , "Failed to issue precert" )
0 commit comments