Skip to content

Commit

Permalink
admission_test.go(TestAdmitFailure): reduce code by (enchancing and) …
Browse files Browse the repository at this point in the history
…using existing function.
  • Loading branch information
php-coder committed Nov 14, 2017
1 parent d935b12 commit f51843c
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions pkg/security/admission/admission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,30 +532,8 @@ func TestAdmitFailure(t *testing.T) {

// now add an escalated scc to the group and re-run the cases that expected failure, they should
// now pass by validating against the escalated scc.
adminSCC := &securityapi.SecurityContextConstraints{
ObjectMeta: metav1.ObjectMeta{
Name: "scc-admin",
},
AllowPrivilegedContainer: true,
AllowHostNetwork: true,
AllowHostPorts: true,
AllowHostPID: true,
AllowHostIPC: true,
RunAsUser: securityapi.RunAsUserStrategyOptions{
Type: securityapi.RunAsUserStrategyRunAsAny,
},
SELinuxContext: securityapi.SELinuxContextStrategyOptions{
Type: securityapi.SELinuxStrategyRunAsAny,
},
FSGroup: securityapi.FSGroupStrategyOptions{
Type: securityapi.FSGroupStrategyRunAsAny,
},
SupplementalGroups: securityapi.SupplementalGroupsStrategyOptions{
Type: securityapi.SupplementalGroupsStrategyRunAsAny,
},
Groups: []string{"system:serviceaccounts"},
}

adminSCC := laxSCC()
adminSCC.Name = "scc-admin"
indexer.Add(adminSCC)

for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -1141,6 +1119,11 @@ func laxSCC() *securityapi.SecurityContextConstraints {
ObjectMeta: metav1.ObjectMeta{
Name: "lax",
},
AllowPrivilegedContainer: true,
AllowHostNetwork: true,
AllowHostPorts: true,
AllowHostPID: true,
AllowHostIPC: true,
RunAsUser: securityapi.RunAsUserStrategyOptions{
Type: securityapi.RunAsUserStrategyRunAsAny,
},
Expand Down

0 comments on commit f51843c

Please sign in to comment.