@@ -39,8 +39,10 @@ const (
39
39
// helloOpenShiftResponse is the HTTP response from hello-openshift example pod.
40
40
// https://github.com/kubernetes/kubernetes/blob/88dfcb225d41326113990e87b11137641c121a32/test/images/agnhost/netexec/netexec.go#L266-L269
41
41
helloOpenShiftResponse = "NOW:"
42
- // defaultCertificateCN is the CommonName of router default certificate.
43
- defaultCertificateCN = "ingress-operator"
42
+ // selfManagedDefaultCertificateCN is the CommonName of router default certificate for SelfManaged cluster profile.
43
+ selfManagedDefaultCertificateCN = "ingress-operator"
44
+ // hypershiftDefaultCertificateCN is the CommonName of router default certificate for HyperShift cluster profile.
45
+ hypershiftDefaultCertificateCN = "root-ca"
44
46
)
45
47
46
48
var _ = g .Describe ("[sig-network][OCPFeatureGate:RouteExternalCertificate][Feature:Router][apigroup:route.openshift.io]" , func () {
@@ -459,7 +461,7 @@ var _ = g.Describe("[sig-network][OCPFeatureGate:RouteExternalCertificate][Featu
459
461
err = waitForRouterOKResponseExec (oc .Namespace (), execPod .Name , routerURL , hostName , changeTimeoutSeconds )
460
462
o .Expect (err ).NotTo (o .HaveOccurred ())
461
463
} else {
462
- resp , err := verifyRouteServesDefaultCert (hostName )
464
+ resp , err := verifyRouteServesDefaultCert (oc , hostName )
463
465
o .Expect (err ).NotTo (o .HaveOccurred ())
464
466
o .Expect (resp ).Should (o .ContainSubstring (helloOpenShiftResponse ))
465
467
}
@@ -624,7 +626,18 @@ func httpsGetCallWithExecPod(oc *exutil.CLI, url string, rootCertPEM []byte) (st
624
626
}
625
627
626
628
// verifyRouteServesDefaultCert checks that the given hostname serves the default certificate.
627
- func verifyRouteServesDefaultCert (hostname string ) (string , error ) {
629
+ func verifyRouteServesDefaultCert (oc * exutil.CLI , hostname string ) (string , error ) {
630
+ defaultCertificateCN := selfManagedDefaultCertificateCN
631
+
632
+ // change the expected defaultCertificateCN if it's a HyperShift cluster.
633
+ isHypershift , err := exutil .IsHypershift (context .Background (), oc .AdminConfigClient ())
634
+ if err != nil {
635
+ return "" , fmt .Errorf ("failed to verify HyperShift cluster: %w" , err )
636
+ }
637
+ if isHypershift {
638
+ defaultCertificateCN = hypershiftDefaultCertificateCN
639
+ }
640
+
628
641
client := & http.Client {
629
642
Transport : & http.Transport {
630
643
TLSClientConfig : & tls.Config {
@@ -635,7 +648,7 @@ func verifyRouteServesDefaultCert(hostname string) (string, error) {
635
648
url := fmt .Sprintf ("https://%s" , hostname )
636
649
637
650
var body string
638
- err : = wait .PollUntilContextTimeout (context .Background (), time .Second , changeTimeoutSeconds * time .Second , false , func (ctx context.Context ) (bool , error ) {
651
+ err = wait .PollUntilContextTimeout (context .Background (), time .Second , changeTimeoutSeconds * time .Second , false , func (ctx context.Context ) (bool , error ) {
639
652
var err error
640
653
var resp * http.Response
641
654
resp , body , err = sendHttpRequestWithRetry (url , client )
@@ -646,7 +659,7 @@ func verifyRouteServesDefaultCert(hostname string) (string, error) {
646
659
// check that the route is serving the default certificate.
647
660
for _ , cert := range resp .TLS .PeerCertificates {
648
661
if ! strings .Contains (cert .Issuer .CommonName , defaultCertificateCN ) {
649
- e2e .Logf ("Unexpected Issuer CommonName: %v, retrying..." , cert .Issuer .CommonName )
662
+ e2e .Logf ("Unexpected Issuer CommonName: expected %v, but got %v, retrying..." , defaultCertificateCN , cert .Issuer .CommonName )
650
663
return false , nil
651
664
}
652
665
}
0 commit comments