summaryrefslogtreecommitdiff
path: root/smoketest/scripts
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-02-02 10:05:05 +0100
committerGitHub <noreply@github.com>2024-02-02 10:05:05 +0100
commit4b0a78b0d2e4e0ea813e93b0842ae3aed15d1a43 (patch)
tree04aa9fc0f5571f1b96b006211bbda02fac89ce96 /smoketest/scripts
parentf2de4378b5048fb4fc3a493aa2a214a320dd8d48 (diff)
parentfaa4c87d93c7808c6a4edd8eddd29049ec8ec3fa (diff)
downloadvyos-1x-4b0a78b0d2e4e0ea813e93b0842ae3aed15d1a43.tar.gz
vyos-1x-4b0a78b0d2e4e0ea813e93b0842ae3aed15d1a43.zip
Merge pull request #2927 from ishioni/T5955
container: T5955: add uid/gid settings
Diffstat (limited to 'smoketest/scripts')
-rwxr-xr-xsmoketest/scripts/cli/test_container.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_container.py b/smoketest/scripts/cli/test_container.py
index cdf46a6e1..9094e27dd 100755
--- a/smoketest/scripts/cli/test_container.py
+++ b/smoketest/scripts/cli/test_container.py
@@ -188,5 +188,27 @@ class TestContainer(VyOSUnitTestSHIM.TestCase):
self.assertEqual(c['NetworkSettings']['Networks'][net_name]['Gateway'] , str(ip_interface(prefix4).ip + 1))
self.assertEqual(c['NetworkSettings']['Networks'][net_name]['IPAddress'] , str(ip_interface(prefix4).ip + ii))
+ def test_uid_gid(self):
+ cont_name = 'uid-test'
+ gid = '100'
+ uid = '1001'
+
+ self.cli_set(base_path + ['name', cont_name, 'allow-host-networks'])
+ self.cli_set(base_path + ['name', cont_name, 'image', cont_image])
+ self.cli_set(base_path + ['name', cont_name, 'gid', gid])
+
+ # verify() - GID can only be set if UID is set
+ with self.assertRaises(ConfigSessionError):
+ self.cli_commit()
+ self.cli_set(base_path + ['name', cont_name, 'uid', uid])
+
+ self.cli_commit()
+
+ # verify
+ tmp = cmd(f'sudo podman exec -it {cont_name} id -u')
+ self.assertEqual(tmp, uid)
+ tmp = cmd(f'sudo podman exec -it {cont_name} id -g')
+ self.assertEqual(tmp, gid)
+
if __name__ == '__main__':
unittest.main(verbosity=2)