Skip to content

Commit c14ed00

Browse files
author
Amarthya Valija
committed
Update test case to enforce security context settings
1 parent 5803bd9 commit c14ed00

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

osde2e/managed_cluster_validating_webhooks_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,41 @@ var _ = Describe("Managed Cluster Validating Webhooks", Ordered, func() {
105105
Expect(err).ToNot(HaveOccurred())
106106
})
107107

108+
It("should create a pod with the correct security context", func() {
109+
pod := &v1.Pod{
110+
ObjectMeta: metav1.ObjectMeta{
111+
Name: managedClusterValidationWebhookPodName,
112+
},
113+
Spec: v1.PodSpec{
114+
Containers: []v1.Container{
115+
{
116+
Name: "test",
117+
Image: "quay.io/jitesoft/nginx:mainline",
118+
SecurityContext: &v1.SecurityContext{
119+
AllowPrivilegeEscalation: boolPtr(false),
120+
Capabilities: &v1.Capabilities{
121+
Drop: []v1.Capability{"ALL"},
122+
},
123+
RunAsNonRoot: boolPtr(true),
124+
SeccompProfile: &v1.SeccompProfile{
125+
Type: v1.SeccompProfileTypeRuntimeDefault,
126+
},
127+
},
128+
},
129+
},
130+
},
131+
}
132+
133+
// Create the pod
134+
err := client.Create(context.TODO(), pod)
135+
Expect(err).NotTo(HaveOccurred())
136+
})
137+
138+
// Helper function to create a pointer to a bool
139+
func boolPtr(b bool) *bool {
140+
return &b
141+
}
142+
108143
Describe("sre-pod-validation", Ordered, func() {
109144
const (
110145
privilegedNamespace = "openshift-backplane"

0 commit comments

Comments
 (0)