Skip to content

Commit 142fd5c

Browse files
chore: ditto for global roles (previous was role templates)
1 parent 0b32a46 commit 142fd5c

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

tests/integration/globalRole_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,69 @@ func (m *IntegrationSuite) TestGlobalRole() {
5252
}
5353
validateEndpoints(m.T(), endPoints, m.clientFactory)
5454
}
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

Comments
 (0)