Skip to content

Commit 98f4692

Browse files
author
Ish Shah
committed
extension developer test fixed
Signed-off-by: Ish Shah <[email protected]>
1 parent 1b4f534 commit 98f4692

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

test/extension-developer-e2e/extension_developer_test.go

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
1818

1919
ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
20+
21+
"fmt"
22+
corev1 "k8s.io/api/core/v1"
23+
rbacv1 "k8s.io/api/rbac/v1"
24+
"k8s.io/apimachinery/pkg/types"
25+
"k8s.io/apimachinery/pkg/util/rand"
2026
)
2127

2228
func TestExtensionDeveloper(t *testing.T) {
@@ -27,10 +33,66 @@ func TestExtensionDeveloper(t *testing.T) {
2733

2834
require.NoError(t, catalogd.AddToScheme(scheme))
2935
require.NoError(t, ocv1alpha1.AddToScheme(scheme))
36+
require.NoError(t, corev1.AddToScheme(scheme))
37+
require.NoError(t, rbacv1.AddToScheme(scheme))
3038

3139
c, err := client.New(cfg, client.Options{Scheme: scheme})
3240
require.NoError(t, err)
3341

42+
ctx := context.Background()
43+
saName := fmt.Sprintf("serviceaccounts-%s", rand.String(8))
44+
name := types.NamespacedName{
45+
Name: saName,
46+
Namespace: "default",
47+
}
48+
49+
sa := &corev1.ServiceAccount{
50+
ObjectMeta: metav1.ObjectMeta{
51+
Name: name.Name,
52+
Namespace: name.Namespace,
53+
},
54+
}
55+
require.NoError(t, c.Create(ctx, sa))
56+
57+
cr := &rbacv1.ClusterRole{
58+
ObjectMeta: metav1.ObjectMeta{
59+
Name: name.Name,
60+
},
61+
Rules: []rbacv1.PolicyRule{
62+
{
63+
APIGroups: []string{
64+
"*",
65+
},
66+
Resources: []string{
67+
"*",
68+
},
69+
Verbs: []string{
70+
"*",
71+
},
72+
},
73+
},
74+
}
75+
require.NoError(t, c.Create(ctx, cr))
76+
77+
crb := &rbacv1.ClusterRoleBinding{
78+
ObjectMeta: metav1.ObjectMeta{
79+
Name: name.Name,
80+
},
81+
Subjects: []rbacv1.Subject{
82+
{
83+
Kind: "ServiceAccount",
84+
Name: name.Name,
85+
Namespace: name.Namespace,
86+
},
87+
},
88+
RoleRef: rbacv1.RoleRef{
89+
APIGroup: "rbac.authorization.k8s.io",
90+
Kind: "ClusterRole",
91+
Name: name.Name,
92+
},
93+
}
94+
require.NoError(t, c.Create(ctx, crb))
95+
3496
var clusterExtensions = []*ocv1alpha1.ClusterExtension{
3597
{
3698
ObjectMeta: metav1.ObjectMeta{
@@ -40,7 +102,7 @@ func TestExtensionDeveloper(t *testing.T) {
40102
PackageName: os.Getenv("REG_PKG_NAME"),
41103
InstallNamespace: "default",
42104
ServiceAccount: ocv1alpha1.ServiceAccountReference{
43-
Name: "default",
105+
Name: saName,
44106
},
45107
},
46108
},

0 commit comments

Comments
 (0)