@@ -10,6 +10,7 @@ import (
10
10
corev1 "k8s.io/api/core/v1"
11
11
"k8s.io/apimachinery/pkg/api/resource"
12
12
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
+ "k8s.io/utils/pointer"
13
14
14
15
autoscalingv1 "github.com/openshift/cluster-resource-override-admission-operator/pkg/apis/autoscaling/v1"
15
16
"github.com/openshift/cluster-resource-override-admission-operator/test/helper"
@@ -41,6 +42,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
41
42
corev1 .ResourceCPU : resource .MustParse ("1000m" ),
42
43
},
43
44
},
45
+ SecurityContext : & corev1.SecurityContext {
46
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
47
+ Capabilities : & corev1.Capabilities {
48
+ Drop : []corev1.Capability {"ALL" },
49
+ },
50
+ RunAsNonRoot : pointer .BoolPtr (true ),
51
+ SeccompProfile : & corev1.SeccompProfile {
52
+ Type : "RuntimeDefault" ,
53
+ },
54
+ },
44
55
},
45
56
{
46
57
Name : "app" ,
@@ -57,6 +68,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
57
68
corev1 .ResourceCPU : resource .MustParse ("500m" ),
58
69
},
59
70
},
71
+ SecurityContext : & corev1.SecurityContext {
72
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
73
+ Capabilities : & corev1.Capabilities {
74
+ Drop : []corev1.Capability {"ALL" },
75
+ },
76
+ RunAsNonRoot : pointer .BoolPtr (true ),
77
+ SeccompProfile : & corev1.SeccompProfile {
78
+ Type : "RuntimeDefault" ,
79
+ },
80
+ },
60
81
},
61
82
},
62
83
},
@@ -101,6 +122,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
101
122
"-c" ,
102
123
"echo The app is running! && sleep 1" ,
103
124
},
125
+ SecurityContext : & corev1.SecurityContext {
126
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
127
+ Capabilities : & corev1.Capabilities {
128
+ Drop : []corev1.Capability {"ALL" },
129
+ },
130
+ RunAsNonRoot : pointer .BoolPtr (true ),
131
+ SeccompProfile : & corev1.SeccompProfile {
132
+ Type : "RuntimeDefault" ,
133
+ },
134
+ },
104
135
},
105
136
},
106
137
Containers : []corev1.Container {
@@ -118,6 +149,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
118
149
corev1 .ResourceMemory : resource .MustParse ("512Mi" ),
119
150
corev1 .ResourceCPU : resource .MustParse ("500m" )},
120
151
},
152
+ SecurityContext : & corev1.SecurityContext {
153
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
154
+ Capabilities : & corev1.Capabilities {
155
+ Drop : []corev1.Capability {"ALL" },
156
+ },
157
+ RunAsNonRoot : pointer .BoolPtr (true ),
158
+ SeccompProfile : & corev1.SeccompProfile {
159
+ Type : "RuntimeDefault" ,
160
+ },
161
+ },
121
162
},
122
163
},
123
164
},
@@ -169,6 +210,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
169
210
ContainerPort : 60100 ,
170
211
},
171
212
},
213
+ SecurityContext : & corev1.SecurityContext {
214
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
215
+ Capabilities : & corev1.Capabilities {
216
+ Drop : []corev1.Capability {"ALL" },
217
+ },
218
+ RunAsNonRoot : pointer .BoolPtr (true ),
219
+ SeccompProfile : & corev1.SeccompProfile {
220
+ Type : "RuntimeDefault" ,
221
+ },
222
+ },
172
223
},
173
224
},
174
225
},
@@ -218,6 +269,16 @@ func TestClusterResourceOverrideAdmissionWithOptIn(t *testing.T) {
218
269
corev1 .ResourceMemory : resource .MustParse ("1024Mi" ),
219
270
corev1 .ResourceCPU : resource .MustParse ("1000m" )},
220
271
},
272
+ SecurityContext : & corev1.SecurityContext {
273
+ AllowPrivilegeEscalation : pointer .BoolPtr (false ),
274
+ Capabilities : & corev1.Capabilities {
275
+ Drop : []corev1.Capability {"ALL" },
276
+ },
277
+ RunAsNonRoot : pointer .BoolPtr (true ),
278
+ SeccompProfile : & corev1.SeccompProfile {
279
+ Type : "RuntimeDefault" ,
280
+ },
281
+ },
221
282
},
222
283
},
223
284
},
0 commit comments