Skip to content

Commit

Permalink
tests/integration: Add tests for idmap mounts with userns
Browse files Browse the repository at this point in the history
Signed-off-by: Francis Laniel <[email protected]>
  • Loading branch information
eiffel-fl committed Jul 21, 2023
1 parent 09f8a6a commit 6306e71
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/integration/idmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ function teardown() {
[[ "$output" == *"=100001=100001="* ]]
}

# It fails because it does not detect the modification to uid/gid Mappings.
@test "idmap mount with userns" {
update_config ' .linux.namespaces += [{"type": "user"}]
| .linux.uidMappings += [{"hostID": 100000, "containerID": 0, "size": 65536}]
| .linux.gidMappings += [{"hostID": 100000, "containerID": 0, "size": 65536}] '

runc run test_debian
[ "$status" -eq 0 ]
# With the user namespace, the id map mount UID 100000 is changed to 0.
[[ "$output" == *"=0=0="* ]]
}

@test "idmap mount with different userns" {
update_config ' .linux.namespaces += [{"type": "user"}]
| .linux.uidMappings += [{"hostID": 99999, "containerID": 0, "size": 65536}]
| .linux.gidMappings += [{"hostID": 99999, "containerID": 0, "size": 65536}] '

runc run test_debian
[ "$status" -eq 0 ]
# With the user namespace, the id map mount UID 100000 is changed to 1.
[[ "$output" == *"=1=1="* ]]
}

@test "idmap mount without gidMappings fails" {
update_config ' .mounts |= map((select(.source == "source-1/") | del(.gidMappings) ) // .)'

Expand Down

0 comments on commit 6306e71

Please sign in to comment.