mirror of
https://github.com/containers/podman.git
synced 2025-10-31 01:50:50 +08:00
test: check that kube generate/play restores the userns
validate that a "podman generate" and "podman play" cycle restores the specified user namespace. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -1037,3 +1037,33 @@ spec:
|
||||
run_podman kube down $fname
|
||||
run_podman rmi $imgname
|
||||
}
|
||||
|
||||
@test "podman kube restore user namespace" {
|
||||
if ! is_rootless; then
|
||||
grep -E -q "^containers:" /etc/subuid || skip "no IDs allocated for user 'containers'"
|
||||
fi
|
||||
|
||||
run_podman pod create --userns auto --name usernspod
|
||||
run_podman create --pod usernspod $IMAGE true
|
||||
|
||||
run_podman pod inspect --format {{.InfraContainerID}} usernspod
|
||||
infraID="$output"
|
||||
|
||||
run_podman inspect --format '{{index .Config.Annotations "io.podman.annotations.userns"}}' $infraID
|
||||
assert "$output" == "auto" "user namespace should be kept"
|
||||
|
||||
YAML=$PODMAN_TMPDIR/test.yml
|
||||
|
||||
# Make sure the same setting is restored if the pod is recreated from the yaml
|
||||
run_podman kube generate usernspod -f $YAML
|
||||
cat $YAML
|
||||
run_podman kube play --replace $YAML
|
||||
|
||||
run_podman pod inspect --format {{.InfraContainerID}} usernspod
|
||||
infraID="$output"
|
||||
|
||||
run_podman inspect --format '{{index .Config.Annotations "io.podman.annotations.userns"}}' $infraID
|
||||
assert "$output" == "auto" "user namespace should be kept"
|
||||
|
||||
run_podman pod rm -f usernspod
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user