From 26fb4ed5fcd9c1ac9e427ac6e0c34d0aa01125e0 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Wed, 24 Jan 2018 18:40:07 +0100 Subject: [PATCH] selinux/mustrunas_test.go(TestMustRunAsValidate): make PSP SeLinux options configurable. --- .../selinux/mustrunas_test.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/security/podsecuritypolicy/selinux/mustrunas_test.go b/pkg/security/podsecuritypolicy/selinux/mustrunas_test.go index caa0a0438c..0eca54bdc4 100644 --- a/pkg/security/podsecuritypolicy/selinux/mustrunas_test.go +++ b/pkg/security/podsecuritypolicy/selinux/mustrunas_test.go @@ -99,41 +99,49 @@ func TestMustRunAsValidate(t *testing.T) { seType := newValidOpts() seType.Type = "invalid" + validOpts := newValidOpts() + tests := map[string]struct { podSeLinux *api.SELinuxOptions + pspSeLinux *api.SELinuxOptions expectedMsg string }{ "invalid role": { podSeLinux: role, + pspSeLinux: validOpts, expectedMsg: "role: Invalid value", }, "invalid user": { podSeLinux: user, + pspSeLinux: validOpts, expectedMsg: "user: Invalid value", }, "invalid level": { podSeLinux: level, + pspSeLinux: validOpts, expectedMsg: "level: Invalid value", }, "invalid type": { podSeLinux: seType, + pspSeLinux: validOpts, expectedMsg: "type: Invalid value", }, "valid": { - podSeLinux: newValidOpts(), + podSeLinux: validOpts, + pspSeLinux: validOpts, expectedMsg: "", }, "valid with different order of categories": { podSeLinux: newValidOptsWithLevel("s0:c6,c0"), + pspSeLinux: validOpts, expectedMsg: "", }, } - opts := &extensions.SELinuxStrategyOptions{ - SELinuxOptions: newValidOpts(), - } - for name, tc := range tests { + opts := &extensions.SELinuxStrategyOptions{ + SELinuxOptions: tc.pspSeLinux, + } mustRunAs, err := NewMustRunAs(opts) if err != nil { t.Errorf("unexpected error initializing NewMustRunAs for testcase %s: %#v", name, err)