Skip to content

Commit

Permalink
selinux/mustrunas_test.go(TestMustRunAsValidate): make SCC SeLinux op…
Browse files Browse the repository at this point in the history
…tions configurable.
  • Loading branch information
php-coder committed Jan 25, 2018
1 parent 9844542 commit 0f4ea61
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pkg/security/securitycontextconstraints/selinux/mustrunas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,49 @@ func TestMustRunAsValidate(t *testing.T) {
seType := newValidOpts()
seType.Type = "invalid"

validOpts := newValidOpts()

tests := map[string]struct {
podSeLinux *api.SELinuxOptions
sccSeLinux *api.SELinuxOptions
expectedMsg string
}{
"invalid role": {
podSeLinux: role,
sccSeLinux: validOpts,
expectedMsg: "role: Invalid value",
},
"invalid user": {
podSeLinux: user,
sccSeLinux: validOpts,
expectedMsg: "user: Invalid value",
},
"invalid level": {
podSeLinux: level,
sccSeLinux: validOpts,
expectedMsg: "level: Invalid value",
},
"invalid type": {
podSeLinux: seType,
sccSeLinux: validOpts,
expectedMsg: "type: Invalid value",
},
"valid": {
podSeLinux: newValidOpts(),
podSeLinux: validOpts,
sccSeLinux: validOpts,
expectedMsg: "",
},
"valid with different order of categories": {
podSeLinux: newValidOptsWithLevel("s0:c6,c0"),
sccSeLinux: validOpts,
expectedMsg: "",
},
}

opts := &securityapi.SELinuxContextStrategyOptions{
SELinuxOptions: newValidOpts(),
}

for name, tc := range tests {
opts := &securityapi.SELinuxContextStrategyOptions{
SELinuxOptions: tc.sccSeLinux,
}
mustRunAs, err := NewMustRunAs(opts)
if err != nil {
t.Errorf("unexpected error initializing NewMustRunAs for testcase %s: %#v", name, err)
Expand Down

0 comments on commit 0f4ea61

Please sign in to comment.