@@ -52,3 +52,69 @@ func (m *IntegrationSuite) TestGlobalRole() {
52
52
}
53
53
validateEndpoints (m .T (), endPoints , m .clientFactory )
54
54
}
55
+
56
+ func (m * IntegrationSuite ) TestGlobalRoleNoResources () {
57
+ newObj := func () * v3.GlobalRole { return & v3.GlobalRole {} }
58
+ validCreateObj := & v3.GlobalRole {
59
+ ObjectMeta : v1.ObjectMeta {
60
+ Name : "test-globalrole-no-resources" ,
61
+ },
62
+ Rules : []rbacv1.PolicyRule {
63
+ {
64
+ Verbs : []string {"GET" , "WATCH" },
65
+ APIGroups : []string {"v1" },
66
+ Resources : []string {"pods" },
67
+ },
68
+ },
69
+ }
70
+ invalidCreate := func () * v3.GlobalRole {
71
+ invalidCreate := validCreateObj .DeepCopy ()
72
+ if len (invalidCreate .Rules ) != 0 {
73
+ invalidCreate .Rules [0 ].Resources = nil
74
+ }
75
+ return invalidCreate
76
+ }
77
+ validDelete := func () * v3.GlobalRole {
78
+ return validCreateObj
79
+ }
80
+ endPoints := & endPointObjs [* v3.GlobalRole ]{
81
+ invalidCreate : invalidCreate ,
82
+ newObj : newObj ,
83
+ validCreateObj : validCreateObj ,
84
+ validDelete : validDelete ,
85
+ }
86
+ validateEndpoints (m .T (), endPoints , m .clientFactory )
87
+ }
88
+
89
+ func (m * IntegrationSuite ) TestGlobalRoleNoAPIGroups () {
90
+ newObj := func () * v3.GlobalRole { return & v3.GlobalRole {} }
91
+ validCreateObj := & v3.GlobalRole {
92
+ ObjectMeta : v1.ObjectMeta {
93
+ Name : "test-globalrole-no-apigroups" ,
94
+ },
95
+ Rules : []rbacv1.PolicyRule {
96
+ {
97
+ Verbs : []string {"GET" , "WATCH" },
98
+ APIGroups : []string {"v1" },
99
+ Resources : []string {"pods" },
100
+ },
101
+ },
102
+ }
103
+ invalidCreate := func () * v3.GlobalRole {
104
+ invalidCreate := validCreateObj .DeepCopy ()
105
+ if len (invalidCreate .Rules ) != 0 {
106
+ invalidCreate .Rules [0 ].APIGroups = nil
107
+ }
108
+ return invalidCreate
109
+ }
110
+ validDelete := func () * v3.GlobalRole {
111
+ return validCreateObj
112
+ }
113
+ endPoints := & endPointObjs [* v3.GlobalRole ]{
114
+ invalidCreate : invalidCreate ,
115
+ newObj : newObj ,
116
+ validCreateObj : validCreateObj ,
117
+ validDelete : validDelete ,
118
+ }
119
+ validateEndpoints (m .T (), endPoints , m .clientFactory )
120
+ }
0 commit comments