Skip to content

Commit

Permalink
chore: ditto for global roles (previous was role templates)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-kupries committed Feb 1, 2024
1 parent 0b32a46 commit 142fd5c
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions tests/integration/globalRole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,69 @@ func (m *IntegrationSuite) TestGlobalRole() {
}
validateEndpoints(m.T(), endPoints, m.clientFactory)
}

func (m *IntegrationSuite) TestGlobalRoleNoResources() {
newObj := func() *v3.GlobalRole { return &v3.GlobalRole{} }
validCreateObj := &v3.GlobalRole{
ObjectMeta: v1.ObjectMeta{
Name: "test-globalrole-no-resources",
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{"GET", "WATCH"},
APIGroups: []string{"v1"},
Resources: []string{"pods"},
},
},
}
invalidCreate := func() *v3.GlobalRole {
invalidCreate := validCreateObj.DeepCopy()
if len(invalidCreate.Rules) != 0 {
invalidCreate.Rules[0].Resources = nil
}
return invalidCreate
}
validDelete := func() *v3.GlobalRole {
return validCreateObj
}
endPoints := &endPointObjs[*v3.GlobalRole]{
invalidCreate: invalidCreate,
newObj: newObj,
validCreateObj: validCreateObj,
validDelete: validDelete,
}
validateEndpoints(m.T(), endPoints, m.clientFactory)
}

func (m *IntegrationSuite) TestGlobalRoleNoAPIGroups() {
newObj := func() *v3.GlobalRole { return &v3.GlobalRole{} }
validCreateObj := &v3.GlobalRole{
ObjectMeta: v1.ObjectMeta{
Name: "test-globalrole-no-apigroups",
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{"GET", "WATCH"},
APIGroups: []string{"v1"},
Resources: []string{"pods"},
},
},
}
invalidCreate := func() *v3.GlobalRole {
invalidCreate := validCreateObj.DeepCopy()
if len(invalidCreate.Rules) != 0 {
invalidCreate.Rules[0].APIGroups = nil
}
return invalidCreate
}
validDelete := func() *v3.GlobalRole {
return validCreateObj
}
endPoints := &endPointObjs[*v3.GlobalRole]{
invalidCreate: invalidCreate,
newObj: newObj,
validCreateObj: validCreateObj,
validDelete: validDelete,
}
validateEndpoints(m.T(), endPoints, m.clientFactory)
}

0 comments on commit 142fd5c

Please sign in to comment.