dockerTools.tests.docker-tools: Add non-root streamLayeredImage test

This commit is contained in:
WxNzEMof 2024-02-26 19:26:07 +00:00
parent b2f19980db
commit 4733b52c6b

View file

@ -58,6 +58,20 @@ let
'';
config.Cmd = [ "${pkgs.coreutils}/bin/stat" "-c" "%u:%g" "/testfile" ];
};
nonRootTestImage =
pkgs.dockerTools.streamLayeredImage rec {
name = "non-root-test";
tag = "latest";
uid = 1000;
gid = 1000;
uname = "user";
gname = "user";
config = {
User = "user";
Cmd = [ "${pkgs.coreutils}/bin/stat" "-c" "%u:%g" "${pkgs.coreutils}/bin/stat" ];
};
};
in {
name = "docker-tools";
meta = with pkgs.lib.maintainers; {
@ -604,5 +618,11 @@ in {
"${chownTestImage} | docker load",
"docker run --rm ${chownTestImage.imageName} | diff /dev/stdin <(echo 12345:12345)"
)
with subtest("streamLayeredImage: with non-root user"):
docker.succeed(
"${nonRootTestImage} | docker load",
"docker run --rm ${chownTestImage.imageName} | diff /dev/stdin <(echo 12345:12345)"
)
'';
})