mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Merge pull request #56579 from php-coder/rm_unused_member_from_tests
Automatic merge from submit-queue (batch tested with PRs 56579, 55236, 56512, 56549, 56538). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. security_context_test.go(TestVerifyRunAsNonRoot): remove unused variables **What this PR does / why we need it**: This PR removed unused member and related variables from the test. **Special notes for your reviewer**: It's better to review this PR in the mode that ignore whitespace-related changes: https://github.com/kubernetes/kubernetes/pull/56579/files?w=1 **Release note**: ```release-note NONE ``` CC @simo5
This commit is contained in:
commit
e8d7835bc6
@ -47,35 +47,29 @@ func TestVerifyRunAsNonRoot(t *testing.T) {
|
|||||||
rootUser := int64(0)
|
rootUser := int64(0)
|
||||||
runAsNonRootTrue := true
|
runAsNonRootTrue := true
|
||||||
runAsNonRootFalse := false
|
runAsNonRootFalse := false
|
||||||
imageRootUser := int64(0)
|
|
||||||
imageNonRootUser := int64(123)
|
|
||||||
for _, test := range []struct {
|
for _, test := range []struct {
|
||||||
desc string
|
desc string
|
||||||
sc *v1.SecurityContext
|
sc *v1.SecurityContext
|
||||||
imageUser int64
|
fail bool
|
||||||
fail bool
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
desc: "Pass if SecurityContext is not set",
|
desc: "Pass if SecurityContext is not set",
|
||||||
sc: nil,
|
sc: nil,
|
||||||
imageUser: imageRootUser,
|
fail: false,
|
||||||
fail: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Pass if RunAsNonRoot is not set",
|
desc: "Pass if RunAsNonRoot is not set",
|
||||||
sc: &v1.SecurityContext{
|
sc: &v1.SecurityContext{
|
||||||
RunAsUser: &rootUser,
|
RunAsUser: &rootUser,
|
||||||
},
|
},
|
||||||
imageUser: imageRootUser,
|
fail: false,
|
||||||
fail: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Pass if RunAsNonRoot is false (image user is root)",
|
desc: "Pass if RunAsNonRoot is false (image user is root)",
|
||||||
sc: &v1.SecurityContext{
|
sc: &v1.SecurityContext{
|
||||||
RunAsNonRoot: &runAsNonRootFalse,
|
RunAsNonRoot: &runAsNonRootFalse,
|
||||||
},
|
},
|
||||||
imageUser: imageRootUser,
|
fail: false,
|
||||||
fail: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Pass if RunAsNonRoot is false (RunAsUser is root)",
|
desc: "Pass if RunAsNonRoot is false (RunAsUser is root)",
|
||||||
@ -83,8 +77,7 @@ func TestVerifyRunAsNonRoot(t *testing.T) {
|
|||||||
RunAsNonRoot: &runAsNonRootFalse,
|
RunAsNonRoot: &runAsNonRootFalse,
|
||||||
RunAsUser: &rootUser,
|
RunAsUser: &rootUser,
|
||||||
},
|
},
|
||||||
imageUser: imageNonRootUser,
|
fail: false,
|
||||||
fail: false,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Fail if container's RunAsUser is root and RunAsNonRoot is true",
|
desc: "Fail if container's RunAsUser is root and RunAsNonRoot is true",
|
||||||
@ -92,16 +85,14 @@ func TestVerifyRunAsNonRoot(t *testing.T) {
|
|||||||
RunAsNonRoot: &runAsNonRootTrue,
|
RunAsNonRoot: &runAsNonRootTrue,
|
||||||
RunAsUser: &rootUser,
|
RunAsUser: &rootUser,
|
||||||
},
|
},
|
||||||
imageUser: imageNonRootUser,
|
fail: true,
|
||||||
fail: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
desc: "Fail if image's user is root and RunAsNonRoot is true",
|
desc: "Fail if image's user is root and RunAsNonRoot is true",
|
||||||
sc: &v1.SecurityContext{
|
sc: &v1.SecurityContext{
|
||||||
RunAsNonRoot: &runAsNonRootTrue,
|
RunAsNonRoot: &runAsNonRootTrue,
|
||||||
},
|
},
|
||||||
imageUser: imageRootUser,
|
fail: true,
|
||||||
fail: true,
|
|
||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
pod.Spec.Containers[0].SecurityContext = test.sc
|
pod.Spec.Containers[0].SecurityContext = test.sc
|
||||||
|
Loading…
Reference in New Issue
Block a user