@@ -17,6 +17,12 @@ import (
17
17
catalogd "github.com/operator-framework/catalogd/api/core/v1alpha1"
18
18
19
19
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"
20
26
)
21
27
22
28
func TestExtensionDeveloper (t * testing.T ) {
@@ -27,10 +33,66 @@ func TestExtensionDeveloper(t *testing.T) {
27
33
28
34
require .NoError (t , catalogd .AddToScheme (scheme ))
29
35
require .NoError (t , ocv1alpha1 .AddToScheme (scheme ))
36
+ require .NoError (t , corev1 .AddToScheme (scheme ))
37
+ require .NoError (t , rbacv1 .AddToScheme (scheme ))
30
38
31
39
c , err := client .New (cfg , client.Options {Scheme : scheme })
32
40
require .NoError (t , err )
33
41
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
+
34
96
var clusterExtensions = []* ocv1alpha1.ClusterExtension {
35
97
{
36
98
ObjectMeta : metav1.ObjectMeta {
@@ -40,7 +102,7 @@ func TestExtensionDeveloper(t *testing.T) {
40
102
PackageName : os .Getenv ("REG_PKG_NAME" ),
41
103
InstallNamespace : "default" ,
42
104
ServiceAccount : ocv1alpha1.ServiceAccountReference {
43
- Name : "default" ,
105
+ Name : saName ,
44
106
},
45
107
},
46
108
},
0 commit comments