Change:
<ins> // +build windows /* Copyright 2020 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package kuberuntime import ( "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/stretchr/testify/assert" "testing" ) func TestVerifyRunAsNonRoot(t *testing.T) { pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ UID:       "12345678", Name:      "bar", Namespace: "new", }, Spec: v1.PodSpec{ Containers: []v1.Container{ { Name:            "foo", Image:           "windows", ImagePullPolicy: v1.PullIfNotPresent, Command:         []string{"testCommand"}, WorkingDir:      "testWorkingDir", }, }, }, } rootUser := "ContainerAdministrator" anyUser := "anyone" runAsNonRootTrue := true runAsNonRootFalse := false for _, test := range []struct { desc     string sc       *v1.SecurityContext uid      *int64 username string fail     bool }{ { desc:     "Pass if SecurityContext is not set", sc:       nil, username: rootUser, fail:     false, }, { desc: "Pass if RunAsNonRoot is not set", sc: &v1.SecurityContext{ RunAsNonRoot: nil, }, username: rootUser, fail:     false, }, { desc: "Pass if RunAsNonRoot is false (image user is root)", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootFalse, }, username: rootUser, fail:     false, }, { desc: "Pass if RunAsNonRoot is false (WindowsOptions RunAsUserName is root)", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootFalse, WindowsOptions: &v1.WindowsSecurityContextOptions{ RunAsUserName: &rootUser, }, }, username: rootUser, fail:     false, }, { desc: "Fail if container's RunAsUser is root and RunAsNonRoot is true", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootTrue, WindowsOptions: &v1.WindowsSecurityContextOptions{ RunAsUserName: &rootUser, }, }, username: rootUser, fail:     true, }, { desc: "Fail if image's user is root and RunAsNonRoot is true", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootTrue, }, username: rootUser, fail:     true, }, { desc: "Pass if image's user is non-root and RunAsNonRoot is true", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootTrue, }, username: anyUser, fail:     false, }, { desc: "Pass if container's user and image's user aren't set and RunAsNonRoot is true", sc: &v1.SecurityContext{ RunAsNonRoot: &runAsNonRootTrue, }, fail: false, }, } { pod.Spec.Containers[0].SecurityContext = test.sc err := verifyRunAsNonRoot(pod, &pod.Spec.Containers[0], test.uid, test.username) if test.fail { assert.Error(t, err, test.desc) } else { assert.NoError(t, err, test.desc) } } } </ins>

Discussion:
Hello, What happened: When we apply PodSecurityPolicy with rule: WIndows containers are still blocked instead we put: the pod is still blocked with logs: What you expected to happen: the Container should start How to reproduce it (as minimally and precisely as possible): Create Psp disableling Root Users: Create a pod Windows with runAsUserName: Anything else we need to know?: Environment: Kubernetes version (use ): v1.18.3 Cloud provider or hardware configuration: OS (e.g: ): CentOS Linux 7 (Core) / windows server 2019 version 1809 Kernel (e.g. ): 3.10.0-514.10.2.el7.x86_64 Others: /sig windows
/sig windows
/assign I will test it and then post the test results
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale