@@ -1357,8 +1357,12 @@ default_pass = {{ .Data.data.password }}
13571357 rmqUID := int64 (999 )
13581358
13591359 expectedPodSecurityContext := & corev1.PodSecurityContext {
1360- FSGroup : ptr .To (int64 (0 )),
1361- RunAsUser : & rmqUID ,
1360+ FSGroup : ptr .To (int64 (0 )),
1361+ RunAsUser : & rmqUID ,
1362+ RunAsNonRoot : ptr .To (bool (true )),
1363+ SeccompProfile : & corev1.SeccompProfile {
1364+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
1365+ },
13621366 }
13631367
13641368 Expect (statefulSet .Spec .Template .Spec .SecurityContext ).To (Equal (expectedPodSecurityContext ))
@@ -1419,6 +1423,18 @@ default_pass = {{ .Data.data.password }}
14191423 SubPath : "default_user.conf" ,
14201424 },
14211425 }),
1426+ "SecurityContext" : BeEquivalentTo (& corev1.SecurityContext {
1427+ AllowPrivilegeEscalation : ptr .To (bool (false )),
1428+ Capabilities : & corev1.Capabilities {
1429+ Drop : []corev1.Capability {"ALL" },
1430+ },
1431+ Privileged : ptr .To (bool (false )),
1432+ ReadOnlyRootFilesystem : ptr .To (bool (true )),
1433+ RunAsNonRoot : ptr .To (bool (true )),
1434+ SeccompProfile : & corev1.SeccompProfile {
1435+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
1436+ },
1437+ }),
14221438 }))
14231439 })
14241440
@@ -1518,6 +1534,35 @@ default_pass = {{ .Data.data.password }}
15181534 })
15191535 })
15201536
1537+ It ("sets the container security context" , func () {
1538+ instance .Spec .Resources = & corev1.ResourceRequirements {
1539+ Requests : corev1.ResourceList {},
1540+ Limits : corev1.ResourceList {},
1541+ }
1542+
1543+ builder = & resource.RabbitmqResourceBuilder {
1544+ Instance : & instance ,
1545+ Scheme : scheme ,
1546+ }
1547+
1548+ stsBuilder := builder .StatefulSet ()
1549+ Expect (stsBuilder .Update (statefulSet )).To (Succeed ())
1550+
1551+ container := extractContainer (statefulSet .Spec .Template .Spec .Containers , "rabbitmq" )
1552+ Expect (container .SecurityContext ).To (BeEquivalentTo (& corev1.SecurityContext {
1553+ AllowPrivilegeEscalation : ptr .To (bool (false )),
1554+ Capabilities : & corev1.Capabilities {
1555+ Drop : []corev1.Capability {"ALL" },
1556+ },
1557+ Privileged : ptr .To (bool (false )),
1558+ ReadOnlyRootFilesystem : ptr .To (bool (true )),
1559+ RunAsNonRoot : ptr .To (bool (true )),
1560+ SeccompProfile : & corev1.SeccompProfile {
1561+ Type : corev1 .SeccompProfileTypeRuntimeDefault ,
1562+ },
1563+ }))
1564+ })
1565+
15211566 It ("sets the replica count of the StatefulSet to the instance value" , func () {
15221567 instance .Spec .Replicas = ptr .To (int32 (3 ))
15231568 builder = & resource.RabbitmqResourceBuilder {
0 commit comments