@@ -32,7 +32,6 @@ import (
32
32
33
33
. "github.com/onsi/ginkgo/v2"
34
34
. "github.com/onsi/gomega"
35
- . "github.com/onsi/gomega/gstruct"
36
35
"golang.org/x/sys/unix"
37
36
internalapi "k8s.io/cri-api/pkg/apis"
38
37
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
@@ -640,14 +639,16 @@ var _ = framework.KubeDescribe("Security Context", func() {
640
639
// - 1000: self
641
640
// - 1234: SupplementalGroups
642
641
// - 50000: groups defined in the container image (/etc/group)
643
- g .Expect (containerStatus .User ).To (PointTo (MatchFields (IgnoreExtras , Fields {
644
- "Linux" : PointTo (MatchFields (IgnoreExtras , Fields {
645
- "Uid" : Equal (imagePredefinedGroupUID ),
646
- "Gid" : Equal (imagePredefinedGroupUID ),
647
- // we can not assume the order of gids
648
- "SupplementalGroups" : And (ContainElements (imagePredefinedGroupUID , supplementalGroup , imagePredefinedGroupGID ), HaveLen (3 )),
649
- })),
650
- })))
642
+ if containerStatus .User != nil && containerStatus .User .Linux != nil {
643
+ slices .Sort (containerStatus .User .Linux .SupplementalGroups )
644
+ }
645
+ g .Expect (containerStatus .User ).To (BeEquivalentTo (& runtimeapi.ContainerUser {
646
+ Linux : & runtimeapi.LinuxContainerUser {
647
+ Uid : imagePredefinedGroupUID ,
648
+ Gid : imagePredefinedGroupUID ,
649
+ SupplementalGroups : []int64 {imagePredefinedGroupUID , supplementalGroup , imagePredefinedGroupGID },
650
+ },
651
+ }))
651
652
g .Expect (parseLogLine (podConfig , logPath )).NotTo (BeEmpty ())
652
653
}, time .Minute , time .Second * 4 ).Should (Succeed ())
653
654
@@ -706,14 +707,16 @@ var _ = framework.KubeDescribe("Security Context", func() {
706
707
// - supplementary groups
707
708
// - 1000: self
708
709
// - 1234: SupplementalGroups
709
- g .Expect (containerStatus .User ).To (PointTo (MatchFields (IgnoreExtras , Fields {
710
- "Linux" : PointTo (MatchFields (IgnoreExtras , Fields {
711
- "Uid" : Equal (imagePredefinedGroupUID ),
712
- "Gid" : Equal (imagePredefinedGroupUID ),
713
- // we can not assume the order of gids
714
- "SupplementalGroups" : And (ContainElements (imagePredefinedGroupUID , supplementalGroup ), HaveLen (2 )),
715
- })),
716
- })))
710
+ if containerStatus .User != nil && containerStatus .User .Linux != nil {
711
+ slices .Sort (containerStatus .User .Linux .SupplementalGroups )
712
+ }
713
+ g .Expect (containerStatus .User ).To (BeEquivalentTo (& runtimeapi.ContainerUser {
714
+ Linux : & runtimeapi.LinuxContainerUser {
715
+ Uid : imagePredefinedGroupUID ,
716
+ Gid : imagePredefinedGroupUID ,
717
+ SupplementalGroups : []int64 {imagePredefinedGroupUID , supplementalGroup },
718
+ },
719
+ }))
717
720
g .Expect (parseLogLine (podConfig , logPath )).NotTo (BeEmpty ())
718
721
}, time .Minute , time .Second * 4 ).Should (Succeed ())
719
722
0 commit comments