selinux/mustrunas_test.go(TestMustRunAsValidate): add more test cases to improve code coverage.

This commit is contained in:
Slava Semushin 2018-01-24 18:52:11 +01:00
parent 26fb4ed5fc
commit 09333b3a5d

View File

@ -93,9 +93,6 @@ func TestMustRunAsValidate(t *testing.T) {
user := newValidOpts() user := newValidOpts()
user.User = "invalid" user.User = "invalid"
level := newValidOpts()
level.Level = "invalid"
seType := newValidOpts() seType := newValidOpts()
seType.Type = "invalid" seType.Type = "invalid"
@ -116,15 +113,20 @@ func TestMustRunAsValidate(t *testing.T) {
pspSeLinux: validOpts, pspSeLinux: validOpts,
expectedMsg: "user: Invalid value", expectedMsg: "user: Invalid value",
}, },
"invalid level": { "levels are not equal": {
podSeLinux: level, podSeLinux: newValidOptsWithLevel("s0"),
pspSeLinux: validOpts, pspSeLinux: newValidOptsWithLevel("s0:c1,c2"),
expectedMsg: "level: Invalid value", expectedMsg: "level: Invalid value",
}, },
"invalid type": { "levels differ by sensitivity": {
podSeLinux: seType, podSeLinux: newValidOptsWithLevel("s0:c6"),
pspSeLinux: validOpts, pspSeLinux: newValidOptsWithLevel("s1:c6"),
expectedMsg: "type: Invalid value", expectedMsg: "level: Invalid value",
},
"levels differ by categories": {
podSeLinux: newValidOptsWithLevel("s0:c0,c8"),
pspSeLinux: newValidOptsWithLevel("s0:c1,c7"),
expectedMsg: "level: Invalid value",
}, },
"valid": { "valid": {
podSeLinux: validOpts, podSeLinux: validOpts,