Skip to content

Commit 25270fc

Browse files
author
Amarthya Valija
committed
Fix test case for security context enforcement
1 parent c14ed00 commit 25270fc

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

osde2e/managed_cluster_validating_webhooks_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
108108
It("should create a pod with the correct security context", func() {
109109
pod := &v1.Pod{
110110
ObjectMeta: metav1.ObjectMeta{
111-
Name: managedClusterValidationWebhookPodName,
111+
Name: "testpod",
112112
},
113113
Spec: v1.PodSpec{
114114
Containers: []v1.Container{
@@ -135,7 +135,7 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
135135
Expect(err).NotTo(HaveOccurred())
136136
})
137137

138-
// Helper function to create a pointer to a bool
138+
139139
func boolPtr(b bool) *bool {
140140
return &b
141141
}
@@ -161,18 +161,17 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
161161
Containers: []v1.Container{
162162
{
163163
Name: "test",
164-
Image: "registry.access.redhat.com/ubi8/ubi-minimal",
165-
},
166-
},
167-
Tolerations: []v1.Toleration{
168-
{
169-
Key: "node-role.kubernetes.io/master",
170-
Value: "toleration-key-value",
171-
Effect: v1.TaintEffectNoSchedule,
172-
}, {
173-
Key: "node-role.kubernetes.io/infra",
174-
Value: "toleration-key-value2",
175-
Effect: v1.TaintEffectNoSchedule,
164+
Image: "quay.io/jitesoft/nginx:mainline",
165+
SecurityContext: &v1.SecurityContext{
166+
AllowPrivilegeEscalation: boolPtr(false),
167+
Capabilities: &v1.Capabilities{
168+
Drop: []v1.Capability{"ALL"},
169+
},
170+
RunAsNonRoot: boolPtr(true),
171+
SeccompProfile: &v1.SeccompProfile{
172+
Type: v1.SeccompProfileTypeRuntimeDefault,
173+
},
174+
},
176175
},
177176
},
178177
},
@@ -200,7 +199,7 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
200199

201200
err := client.Get(ctx, saName, namespaceName, sa)
202201

203-
if err == nil {
202+
if (err == nil) {
204203
err = client.Delete(ctx, sa)
205204
Expect(err).ToNot(HaveOccurred(), "Failed to delete existing Service Account")
206205
}

0 commit comments

Comments
 (0)