Skip to content

Commit f7b970e

Browse files
awgreenestevekuznetsov
authored andcommittedNov 7, 2023
Fix Image Update test
This change grants the serviceAccount used by the catalogSource permissions to pull from the internal registry. Signed-off-by: Alexander Greene <[email protected]>
1 parent 82d4ae9 commit f7b970e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎test/e2e/catalog_e2e_test.go

+27
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/gomega"
2626
appsv1 "k8s.io/api/apps/v1"
2727
corev1 "k8s.io/api/core/v1"
28+
rbacv1 "k8s.io/api/rbac/v1"
2829
"k8s.io/apimachinery/pkg/api/meta"
2930
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3031
"k8s.io/apimachinery/pkg/labels"
@@ -923,6 +924,32 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
923924
Expect(registryPods).ShouldNot(BeNil(), "nil registry pods")
924925
Expect(registryPods.Items).To(HaveLen(1), "unexpected number of registry pods found")
925926

927+
By("Granting the ServiceAccount used by the registry pod permissions to pull from the internal registry")
928+
roleBinding := &rbacv1.RoleBinding{
929+
ObjectMeta: metav1.ObjectMeta{
930+
Namespace: generatedNamespace.GetName(),
931+
GenerateName: "registry-v1-viewer-",
932+
},
933+
Subjects: []rbacv1.Subject{
934+
{
935+
Kind: "ServiceAccount",
936+
Name: registryPods.Items[0].Spec.ServiceAccountName,
937+
APIGroup: "",
938+
},
939+
},
940+
RoleRef: rbacv1.RoleRef{
941+
Kind: "ClusterRole",
942+
Name: "registry-viewer",
943+
APIGroup: "rbac.authorization.k8s.io",
944+
},
945+
}
946+
_, err = c.CreateRoleBinding(roleBinding)
947+
Expect(err).ToNot(HaveOccurred(), "error granting registry-viewer permissions")
948+
defer func() {
949+
err := c.DeleteRoleBinding(roleBinding.GetNamespace(), roleBinding.GetName(), &metav1.DeleteOptions{})
950+
Expect(err).ShouldNot(HaveOccurred())
951+
}()
952+
926953
By("Create a Subscription for package")
927954
subscriptionName := genName("sub-")
928955
cleanupSubscription := createSubscriptionForCatalog(crc, source.GetNamespace(), subscriptionName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)

0 commit comments

Comments
 (0)
Please sign in to comment.