@@ -15,7 +15,6 @@ import (
15
15
. "github.com/onsi/ginkgo/v2"
16
16
. "github.com/onsi/gomega"
17
17
. "github.com/onsi/gomega/gstruct"
18
- "github.com/stretchr/testify/assert"
19
18
"github.com/stretchr/testify/require"
20
19
appsv1 "k8s.io/api/apps/v1"
21
20
authorizationv1 "k8s.io/api/authorization/v1"
@@ -1887,6 +1886,7 @@ var _ = Describe("Install Plan", func() {
1887
1886
1888
1887
By (`If the CSV is succeeded, we successfully rolled out the RBAC changes` )
1889
1888
})
1889
+
1890
1890
It ("AttenuatePermissions" , func () {
1891
1891
1892
1892
defer func () {
@@ -2017,7 +2017,33 @@ var _ = Describe("Install Plan", func() {
2017
2017
_ , err = fetchCSV (crc , generatedNamespace .GetName (), mainCSV .GetName (), csvSucceededChecker )
2018
2018
require .NoError (GinkgoT (), err )
2019
2019
2020
- By (`Update CatalogSource with a new CSV with more permissions` )
2020
+ By ("Wait for ServiceAccount to have access" )
2021
+ err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
2022
+ res , err := c .KubernetesInterface ().AuthorizationV1 ().SubjectAccessReviews ().Create (context .Background (), & authorizationv1.SubjectAccessReview {
2023
+ Spec : authorizationv1.SubjectAccessReviewSpec {
2024
+ User : "system:serviceaccount:" + generatedNamespace .GetName () + ":" + serviceAccountName ,
2025
+ ResourceAttributes : & authorizationv1.ResourceAttributes {
2026
+ Group : "cluster.com" ,
2027
+ Version : "v1alpha1" ,
2028
+ Resource : crdPlural ,
2029
+ Verb : rbac .VerbAll ,
2030
+ },
2031
+ },
2032
+ }, metav1.CreateOptions {})
2033
+ if err != nil {
2034
+ return false , err
2035
+ }
2036
+ if res == nil {
2037
+ return false , nil
2038
+ }
2039
+ GinkgoT ().Log ("checking serviceaccount for permission" )
2040
+
2041
+ By ("should be allowed" )
2042
+ return res .Status .Allowed , nil
2043
+ })
2044
+ Expect (err ).NotTo (HaveOccurred ())
2045
+
2046
+ By (`Update CatalogSource with a new CSV with fewer permissions` )
2021
2047
updatedPermissions := []operatorsv1alpha1.StrategyDeploymentPermissions {
2022
2048
{
2023
2049
ServiceAccountName : serviceAccountName ,
@@ -2043,9 +2069,6 @@ var _ = Describe("Install Plan", func() {
2043
2069
},
2044
2070
}
2045
2071
2046
- oldSecrets , err := c .KubernetesInterface ().CoreV1 ().Secrets (generatedNamespace .GetName ()).List (context .Background (), metav1.ListOptions {})
2047
- require .NoError (GinkgoT (), err , "error listing secrets" )
2048
-
2049
2072
By (`Create the catalog sources` )
2050
2073
updatedNamedStrategy := newNginxInstallStrategy (genName ("dep-" ), updatedPermissions , updatedClusterPermissions )
2051
2074
updatedCSV := newCSV (mainPackageStable + "-next" , generatedNamespace .GetName (), mainCSV .GetName (), semver .MustParse ("0.2.0" ), []apiextensionsv1.CustomResourceDefinition {mainCRD }, nil , & updatedNamedStrategy )
@@ -2077,15 +2100,6 @@ var _ = Describe("Install Plan", func() {
2077
2100
_ , err = fetchCSV (crc , generatedNamespace .GetName (), updatedCSV .GetName (), csvSucceededChecker )
2078
2101
require .NoError (GinkgoT (), err )
2079
2102
2080
- newSecrets , err := c .KubernetesInterface ().CoreV1 ().Secrets (generatedNamespace .GetName ()).List (context .Background (), metav1.ListOptions {})
2081
- require .NoError (GinkgoT (), err , "error listing secrets" )
2082
-
2083
- By (`Assert that the number of secrets is not increased from updating service account as part of the install plan,` )
2084
- assert .EqualValues (GinkgoT (), len (oldSecrets .Items ), len (newSecrets .Items ))
2085
-
2086
- By (`And that the secret list is indeed updated.` )
2087
- assert .Equal (GinkgoT (), oldSecrets .Items , newSecrets .Items )
2088
-
2089
2103
By (`Wait for ServiceAccount to not have access anymore` )
2090
2104
err = wait .Poll (pollInterval , pollDuration , func () (bool , error ) {
2091
2105
res , err := c .KubernetesInterface ().AuthorizationV1 ().SubjectAccessReviews ().Create (context .Background (), & authorizationv1.SubjectAccessReview {
0 commit comments