From a6c42637385800f889997a2a96484764fcb9d7f3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 28 Apr 2024 18:23:20 +0300 Subject: [PATCH] Add tests for x-podman.uidmaps and x-podman.gidmaps Signed-off-by: Povilas Kanapickas --- pytests/test_container_to_args.py | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/pytests/test_container_to_args.py b/pytests/test_container_to_args.py index cc2da57..a4718f0 100644 --- a/pytests/test_container_to_args.py +++ b/pytests/test_container_to_args.py @@ -171,6 +171,50 @@ class TestContainerToArgs(unittest.IsolatedAsyncioTestCase): with self.assertRaises(ValueError): await container_to_args(c, cnt) + async def test_uidmaps_extension(self): + c = create_compose_mock() + + cnt = get_minimal_container() + cnt['x-podman.uidmaps'] = ['1000:1000:1', '1001:1001:2'] + + args = await container_to_args(c, cnt) + self.assertEqual( + args, + [ + "--name=project_name_service_name1", + "-d", + "--network=bridge", + "--network-alias=service_name", + '--uidmap', + '1000:1000:1', + '--uidmap', + '1001:1001:2', + "busybox", + ], + ) + + async def test_gidmaps_extension(self): + c = create_compose_mock() + + cnt = get_minimal_container() + cnt['x-podman.gidmaps'] = ['1000:1000:1', '1001:1001:2'] + + args = await container_to_args(c, cnt) + self.assertEqual( + args, + [ + "--name=project_name_service_name1", + "-d", + "--network=bridge", + "--network-alias=service_name", + '--gidmap', + '1000:1000:1', + '--gidmap', + '1001:1001:2', + "busybox", + ], + ) + async def test_rootfs_extension(self): c = create_compose_mock()