Skip to content

Commit 6306e71

Browse files
committed
tests/integration: Add tests for idmap mounts with userns
Signed-off-by: Francis Laniel <[email protected]>
1 parent 09f8a6a commit 6306e71

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/integration/idmap.bats

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,29 @@ function teardown() {
124124
[[ "$output" == *"=100001=100001="* ]]
125125
}
126126

127+
# It fails because it does not detect the modification to uid/gid Mappings.
128+
@test "idmap mount with userns" {
129+
update_config ' .linux.namespaces += [{"type": "user"}]
130+
| .linux.uidMappings += [{"hostID": 100000, "containerID": 0, "size": 65536}]
131+
| .linux.gidMappings += [{"hostID": 100000, "containerID": 0, "size": 65536}] '
132+
133+
runc run test_debian
134+
[ "$status" -eq 0 ]
135+
# With the user namespace, the id map mount UID 100000 is changed to 0.
136+
[[ "$output" == *"=0=0="* ]]
137+
}
138+
139+
@test "idmap mount with different userns" {
140+
update_config ' .linux.namespaces += [{"type": "user"}]
141+
| .linux.uidMappings += [{"hostID": 99999, "containerID": 0, "size": 65536}]
142+
| .linux.gidMappings += [{"hostID": 99999, "containerID": 0, "size": 65536}] '
143+
144+
runc run test_debian
145+
[ "$status" -eq 0 ]
146+
# With the user namespace, the id map mount UID 100000 is changed to 1.
147+
[[ "$output" == *"=1=1="* ]]
148+
}
149+
127150
@test "idmap mount without gidMappings fails" {
128151
update_config ' .mounts |= map((select(.source == "source-1/") | del(.gidMappings) ) // .)'
129152

0 commit comments

Comments
 (0)