@@ -814,4 +814,57 @@ var _ = Describe("ManagedControlPlane Controller", func() {
814814 Expect (cr .Spec .WaitForClusterDeletion ).To (PointTo (BeTrue ()))
815815 })
816816
817+ It ("should correctly handle an MCP without OIDC providers" , func () {
818+ rec , env := defaultTestSetup ("testdata" , "test-01" )
819+
820+ mcp := & corev2alpha1.ManagedControlPlaneV2 {}
821+ mcp .SetName ("mcp-03" )
822+ mcp .SetNamespace ("test" )
823+ Expect (env .Client (onboarding ).Get (env .Ctx , client .ObjectKeyFromObject (mcp ), mcp )).To (Succeed ())
824+ env .ShouldReconcile (mcpRec , testutils .RequestFromObject (mcp ))
825+
826+ platformNamespace , err := libutils .StableMCPNamespace (mcp .Name , mcp .Namespace )
827+ Expect (err ).ToNot (HaveOccurred ())
828+
829+ cr := & clustersv1alpha1.ClusterRequest {}
830+ cr .SetName (mcp .Name )
831+ cr .SetNamespace (platformNamespace )
832+ Expect (env .Client (platform ).Get (env .Ctx , client .ObjectKeyFromObject (cr ), cr )).To (Succeed ())
833+
834+ // fake ClusterRequest ready status and Cluster resource
835+ By ("fake: ClusterRequest readiness" )
836+ cluster := & clustersv1alpha1.Cluster {}
837+ cluster .SetName ("cluster-01" )
838+ cluster .SetNamespace (platformNamespace )
839+ cluster .Spec .Purposes = []string {rec .Config .MCPClusterPurpose }
840+ Expect (env .Client (platform ).Create (env .Ctx , cluster )).To (Succeed ())
841+ cluster .Status .Conditions = []metav1.Condition {
842+ {
843+ Type : "TestCondition1" ,
844+ Status : metav1 .ConditionTrue ,
845+ Reason : "TestReason" ,
846+ Message : "This is a test condition" ,
847+ LastTransitionTime : metav1 .Now (),
848+ ObservedGeneration : 1 ,
849+ },
850+ {
851+ Type : "TestCondition2" ,
852+ Status : metav1 .ConditionFalse ,
853+ Reason : "TestReason" ,
854+ Message : "This is another test condition" ,
855+ LastTransitionTime : metav1 .Now (),
856+ ObservedGeneration : 1 ,
857+ },
858+ }
859+ Expect (env .Client (platform ).Status ().Update (env .Ctx , cluster )).To (Succeed ())
860+ cr .Status .Phase = clustersv1alpha1 .REQUEST_GRANTED
861+ cr .Status .Cluster = & commonapi.ObjectReference {
862+ Name : cluster .Name ,
863+ Namespace : cluster .Namespace ,
864+ }
865+ Expect (env .Client (platform ).Status ().Update (env .Ctx , cr )).To (Succeed ())
866+
867+ env .ShouldReconcile (mcpRec , testutils .RequestFromObject (mcp ))
868+ })
869+
817870})
0 commit comments