Skip to content

Commit 4ad2c35

Browse files
Merge pull request #30406 from everettraven/oidc/ensure-clientconfigs-happy
NO-JIRA: oidc: ensure console and cli OIDC clients are available when enabling OIDC
2 parents 30400d6 + 58ac6f2 commit 4ad2c35

File tree

1 file changed

+30
-0
lines changed
  • test/extended/authentication

1 file changed

+30
-0
lines changed

test/extended/authentication/oidc.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
corev1 "k8s.io/api/core/v1"
2020
"k8s.io/apimachinery/pkg/api/equality"
2121
apierrors "k8s.io/apimachinery/pkg/api/errors"
22+
"k8s.io/apimachinery/pkg/api/meta"
2223
"k8s.io/apimachinery/pkg/util/errors"
2324

2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -116,6 +117,7 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
116117
o.Expect(err).NotTo(o.HaveOccurred(), "should not encounter an error configuring OIDC authentication")
117118

118119
waitForRollout(ctx, oc)
120+
waitForHealthyOIDCClients(ctx, oc)
119121
})
120122

121123
g.Describe("external IdP is configured", g.Ordered, func() {
@@ -283,6 +285,7 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
283285
o.Expect(err).NotTo(o.HaveOccurred(), "should not encounter an error configuring OIDC authentication")
284286

285287
waitForRollout(ctx, oc)
288+
waitForHealthyOIDCClients(ctx, oc)
286289
})
287290

288291
g.It("should default UID to the 'sub' claim in the access token from the IdP", func() {
@@ -322,6 +325,7 @@ var _ = g.Describe("[sig-auth][Suite:openshift/auth/external-oidc][Serial][Slow]
322325
o.Expect(err).NotTo(o.HaveOccurred(), "should not encounter an error configuring OIDC authentication")
323326

324327
waitForRollout(ctx, oc)
328+
waitForHealthyOIDCClients(ctx, oc)
325329
})
326330

327331
g.Describe("checking cluster identity mapping", g.Ordered, func() {
@@ -485,6 +489,14 @@ func generateOIDCProvider(ctx context.Context, client *exutil.CLI, namespace, oi
485489
Name: oidcClientSecret,
486490
},
487491
},
492+
{
493+
ComponentName: "cli",
494+
ComponentNamespace: "openshift-console",
495+
ClientID: "openshift-cli-oidc-client",
496+
ClientSecret: configv1.SecretNameReference{
497+
Name: oidcClientSecret,
498+
},
499+
},
488500
},
489501
}, nil
490502
}
@@ -601,3 +613,21 @@ func checkKubeAPIServerCondition(ctx context.Context, kasCli operatorv1client.Ku
601613

602614
return nil
603615
}
616+
617+
func waitForHealthyOIDCClients(ctx context.Context, client *exutil.CLI) {
618+
o.Eventually(func(gomega o.Gomega) {
619+
authn, err := client.AdminConfigClient().ConfigV1().Authentications().Get(ctx, "cluster", metav1.GetOptions{})
620+
gomega.Expect(err).NotTo(o.HaveOccurred())
621+
622+
for _, client := range authn.Status.OIDCClients {
623+
// ignore clients that aren't OpenShift default clients
624+
if client.ComponentNamespace != "openshift-console" && !(client.ComponentName == "console" || client.ComponentName == "cli") {
625+
continue
626+
}
627+
628+
availableCondition := meta.FindStatusCondition(client.Conditions, "Available")
629+
gomega.Expect(availableCondition).NotTo(o.BeNil(), fmt.Sprintf("oidc client %s/%s should have an Available condition", client.ComponentNamespace, client.ComponentName))
630+
gomega.Expect(availableCondition.Status).To(o.Equal(metav1.ConditionTrue), fmt.Sprintf("oidc client %s/%s should be available but was not", client.ComponentNamespace, client.ComponentName), availableCondition)
631+
}
632+
}).WithTimeout(10*time.Minute).WithPolling(20*time.Second).Should(o.Succeed(), "should eventually have healthy OIDC client configurations")
633+
}

0 commit comments

Comments
 (0)