mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
cut avoid unnecessary code duplications
Signed-off-by: mantuliu <240951888@qq.com>
This commit is contained in:
parent
8ca97dcde1
commit
52e7bf58cf
@ -81,9 +81,7 @@ func TestAllowlist(t *testing.T) {
|
||||
if err := w.validateSysctl(test.sysctl, test.hostNet, test.hostIPC); err != nil {
|
||||
t.Errorf("expected to be allowlisted: %+v, got: %v", test, err)
|
||||
}
|
||||
pod.Spec.HostNetwork = test.hostNet
|
||||
pod.Spec.HostIPC = test.hostIPC
|
||||
pod.Spec.SecurityContext.Sysctls = []v1.Sysctl{v1.Sysctl{test.sysctl, test.sysctl}}
|
||||
pod.Spec.SecurityContext.Sysctls = []v1.Sysctl{{test.sysctl, test.sysctl}}
|
||||
status := w.Admit(attrs)
|
||||
if !status.Admit {
|
||||
t.Errorf("expected to be allowlisted: %+v, got: %+v", test, status)
|
||||
@ -96,7 +94,7 @@ func TestAllowlist(t *testing.T) {
|
||||
}
|
||||
pod.Spec.HostNetwork = test.hostNet
|
||||
pod.Spec.HostIPC = test.hostIPC
|
||||
pod.Spec.SecurityContext.Sysctls = []v1.Sysctl{v1.Sysctl{test.sysctl, test.sysctl}}
|
||||
pod.Spec.SecurityContext.Sysctls = []v1.Sysctl{{test.sysctl, test.sysctl}}
|
||||
status := w.Admit(attrs)
|
||||
if status.Admit {
|
||||
t.Errorf("expected to be rejected: %+v", test)
|
||||
@ -104,7 +102,7 @@ func TestAllowlist(t *testing.T) {
|
||||
}
|
||||
|
||||
// test for: len(pod.Spec.SecurityContext.Sysctls) == 0
|
||||
pod.Spec.SecurityContext.Sysctls = nil
|
||||
pod.Spec.SecurityContext.Sysctls = []v1.Sysctl{}
|
||||
status := w.Admit(attrs)
|
||||
if !status.Admit {
|
||||
t.Errorf("expected to be allowlisted,got %+v", status)
|
||||
|
Loading…
Reference in New Issue
Block a user