@@ -66,28 +66,6 @@ func TestValidateRootlessMappingUid(t *testing.T) {
6666 if err := validator .Validate (config ); err == nil {
6767 t .Errorf ("Expected error to occur if no uid mappings provided" )
6868 }
69-
70- config = rootlessConfig ()
71- config .UidMappings [0 ].HostID = geteuid () + 1
72- if err := validator .Validate (config ); err == nil {
73- t .Errorf ("Expected error to occur if geteuid() != mapped uid" )
74- }
75-
76- config = rootlessConfig ()
77- config .UidMappings [0 ].Size = 1024
78- if err := validator .Validate (config ); err == nil {
79- t .Errorf ("Expected error to occur if more than one uid mapped" )
80- }
81-
82- config = rootlessConfig ()
83- config .UidMappings = append (config .UidMappings , configs.IDMap {
84- HostID : geteuid () + 1 ,
85- ContainerID : 0 ,
86- Size : 1 ,
87- })
88- if err := validator .Validate (config ); err == nil {
89- t .Errorf ("Expected error to occur if more than one uid extent mapped" )
90- }
9169}
9270
9371func TestValidateRootlessMappingGid (t * testing.T ) {
@@ -98,28 +76,6 @@ func TestValidateRootlessMappingGid(t *testing.T) {
9876 if err := validator .Validate (config ); err == nil {
9977 t .Errorf ("Expected error to occur if no gid mappings provided" )
10078 }
101-
102- config = rootlessConfig ()
103- config .GidMappings [0 ].HostID = getegid () + 1
104- if err := validator .Validate (config ); err == nil {
105- t .Errorf ("Expected error to occur if getegid() != mapped gid" )
106- }
107-
108- config = rootlessConfig ()
109- config .GidMappings [0 ].Size = 1024
110- if err := validator .Validate (config ); err == nil {
111- t .Errorf ("Expected error to occur if more than one gid mapped" )
112- }
113-
114- config = rootlessConfig ()
115- config .GidMappings = append (config .GidMappings , configs.IDMap {
116- HostID : getegid () + 1 ,
117- ContainerID : 0 ,
118- Size : 1 ,
119- })
120- if err := validator .Validate (config ); err == nil {
121- t .Errorf ("Expected error to occur if more than one gid extent mapped" )
122- }
12379}
12480
12581/* rootlessMount() */
@@ -149,6 +105,18 @@ func TestValidateRootlessMountUid(t *testing.T) {
149105 if err := validator .Validate (config ); err != nil {
150106 t .Errorf ("Expected error to not occur when setting uid=0 in mount options: %+v" , err )
151107 }
108+
109+ config .Mounts [0 ].Data = "uid=2"
110+ config .UidMappings [0 ].Size = 10
111+ if err := validator .Validate (config ); err != nil {
112+ t .Errorf ("Expected error to not occur when setting uid=2 in mount options and UidMapping[0].size is 10" )
113+ }
114+
115+ config .Mounts [0 ].Data = "uid=20"
116+ config .UidMappings [0 ].Size = 10
117+ if err := validator .Validate (config ); err == nil {
118+ t .Errorf ("Expected error to occur when setting uid=20 in mount options and UidMapping[0].size is 10" )
119+ }
152120}
153121
154122func TestValidateRootlessMountGid (t * testing.T ) {
@@ -176,6 +144,18 @@ func TestValidateRootlessMountGid(t *testing.T) {
176144 if err := validator .Validate (config ); err != nil {
177145 t .Errorf ("Expected error to not occur when setting gid=0 in mount options: %+v" , err )
178146 }
147+
148+ config .Mounts [0 ].Data = "gid=5"
149+ config .GidMappings [0 ].Size = 10
150+ if err := validator .Validate (config ); err != nil {
151+ t .Errorf ("Expected error to not occur when setting gid=5 in mount options and GidMapping[0].size is 10" )
152+ }
153+
154+ config .Mounts [0 ].Data = "gid=11"
155+ config .GidMappings [0 ].Size = 10
156+ if err := validator .Validate (config ); err == nil {
157+ t .Errorf ("Expected error to occur when setting gid=11 in mount options and GidMapping[0].size is 10" )
158+ }
179159}
180160
181161/* rootlessCgroup() */
0 commit comments