Skip to content

Commit 45a4a78

Browse files
xuezhaojunclaude
andcommitted
fix test: expect CRD validation to reject empty subjects in ClusterRoleBinding
With the upgraded envtest (K8s 1.31), CRD CEL validation rules are now properly enforced. Creating a ClusterPermission with an empty Subjects array in ClusterRoleBinding is correctly rejected by the XValidation rule defined in clusterpermission_types.go. Update the test assertion from Should(Succeed()) to ShouldNot(Succeed()). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: xuezhaojun <zxue@redhat.com>
1 parent 03bfc51 commit 45a4a78

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

controllers/clusterpermission_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ var _ = Describe("ClusterPermission controller", func() {
672672
},
673673
}))).Should(Equal(1))
674674

675-
By("Create ClusterPermission with ClusterRoleBinding that has no subject or subjects")
675+
By("Create ClusterPermission with ClusterRoleBinding that has no subject or subjects should be rejected by CRD validation")
676676
clusterPermissionMissingSubjectSubjects := cpv1alpha1.ClusterPermission{
677677
ObjectMeta: metav1.ObjectMeta{
678678
Name: "clusterpermission-no-subject-subjects",
@@ -690,7 +690,7 @@ var _ = Describe("ClusterPermission controller", func() {
690690
},
691691
}
692692

693-
Expect(k8sClient.Create(ctx, &clusterPermissionMissingSubjectSubjects)).Should(Succeed())
693+
Expect(k8sClient.Create(ctx, &clusterPermissionMissingSubjectSubjects)).ShouldNot(Succeed())
694694

695695
By("Create ClusterPermission with Role and ClusterRole that doesn't exist validate should have error status")
696696
clusterPermissionRoleClusterRoleNotExistValidate := cpv1alpha1.ClusterPermission{

0 commit comments

Comments
 (0)