func ExpectSubjectHasAccessToResource(c clientset.Interface, subjectKind, subject string, resource *authv1.ResourceAttributes) {
	var sar *authv1.SubjectAccessReview
	switch subjectKind {
	case rbacv1.GroupKind:
		sar = &authv1.SubjectAccessReview{
			Spec: authv1.SubjectAccessReviewSpec{
				Groups:             []string{subject},
				ResourceAttributes: resource,
			},
		}
	case rbacv1.UserKind:
		fallthrough
	case rbacv1.ServiceAccountKind:
		sar = &authv1.SubjectAccessReview{
			Spec: authv1.SubjectAccessReviewSpec{
				User:               subject,
				ResourceAttributes: resource,
			},
		}
	default:
		framework.Failf("invalid subjectKind %s", subjectKind)
	}

	s, err := c.AuthorizationV1().SubjectAccessReviews().Create(context.TODO(), sar, metav1.CreateOptions{})
	framework.ExpectNoError(err, "error getting SubjectAccessReview for %s %s to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)

	gomega.Expect(s.Status.Allowed).Should(gomega.BeTrue(), "%s %s has no access to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
}
// ExpectSubjectHasAccessToResource expects that the subject has access to the target resource
ExpectSubjectHasAccessToResource expects that the subject has access to the target resource
// ExpectSubjectHasAccessToResource expects that the subject has access to the target resource
func ExpectSubjectHasAccessToResource(c clientset.Interface, subjectKind, subject string, resource *authv1.ResourceAttributes) {
	var sar *authv1.SubjectAccessReview
	switch subjectKind {
	case rbacv1.GroupKind:
		sar = &authv1.SubjectAccessReview{
			Spec: authv1.SubjectAccessReviewSpec{
				Groups:             []string{subject},
				ResourceAttributes: resource,
			},
		}
	case rbacv1.UserKind:
		fallthrough
	case rbacv1.ServiceAccountKind:
		sar = &authv1.SubjectAccessReview{
			Spec: authv1.SubjectAccessReviewSpec{
				User:               subject,
				ResourceAttributes: resource,
			},
		}
	default:
		framework.Failf("invalid subjectKind %s", subjectKind)
	}
	s, err := c.AuthorizationV1().SubjectAccessReviews().Create(context.TODO(), sar, metav1.CreateOptions{})
	framework.ExpectNoError(err, "error getting SubjectAccessReview for %s %s to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
	gomega.Expect(s.Status.Allowed).Should(gomega.BeTrue(), "%s %s has no access to resource %+v", subjectKind, subject, *sar.Spec.ResourceAttributes)
}
func ExpectSubjectHasAccessToResource ( c clientset . Interface , subjectKind , subject string , resource * authv1 . ResourceAttributes ) { var sar * authv1 . SubjectAccessReview switch subjectKind { case rbacv1 . GroupKind : sar = & authv1 . SubjectAccessReview { Spec : authv1 . SubjectAccessReviewSpec { Groups : [ ] string { subject } , ResourceAttributes : resource , } , } case rbacv1 . UserKind : fallthrough case rbacv1 . ServiceAccountKind : sar = & authv1 . SubjectAccessReview { Spec : authv1 . SubjectAccessReviewSpec { User : subject , ResourceAttributes : resource , } , } default : framework . Failf ( " " , subjectKind ) } s , err := c . AuthorizationV1 ( ) . SubjectAccessReviews ( ) . Create ( context . TODO ( ) , sar , metav1 . CreateOptions { } ) framework . ExpectNoError ( err , " " , subjectKind , subject , * sar . Spec . ResourceAttributes ) gomega . Expect ( s . Status . Allowed ) . Should ( gomega . BeTrue ( ) , " " , subjectKind , subject , * sar . Spec . ResourceAttributes ) }
ExpectSubjectHasAccessToResource expects that the subject has access to the target resource
ExpectSubjectHasAccessToResource expects that the subject has access to the target resource