]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Tests: Add group with specified GID using -g flag
authorAkshay Sakure <asakure@redhat.com>
Tue, 23 Jun 2026 13:45:43 +0000 (19:15 +0530)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 1 Jul 2026 14:22:03 +0000 (16:22 +0200)
This is Python transformation of the test located in
`tests/grouptools/groupadd/05_groupadd_set_GID/groupadd.test`
which checks that `groupadd` can create group with sepcified GID
using -g flag

Signed-off-by: Akshay Sakure <asakure@redhat.com>
tests/system/tests/test_groupadd.py

index 0a8df92c8651ffc8a00f50e9e3b410a252007006..31c6ef5a87473779d5d54edb13e301283869a8da 100644 (file)
@@ -66,3 +66,23 @@ def test_groupadd__u_option_empty_string_clears_members(shadow: Shadow):
         assert gshadow_entry is not None, "Group should be found"
         assert gshadow_entry.name == "tgroup", "Incorrect groupname"
         assert not gshadow_entry.members, "Group should have no members"
+
+
+@pytest.mark.topology(KnownTopology.Shadow)
+def test_groupadd__set_gid(shadow: Shadow):
+    """
+    :title: Create group with specific GID using -g flag
+    :setup:
+        1. Create group with specific GID
+    :steps:
+        1. Check group entry
+    :expectedresults:
+        1. Group entry is created with the specified GID
+    :customerscenario: False
+    """
+    shadow.groupadd("-g 1500 tgroup")
+
+    group_entry = shadow.tools.getent.group("tgroup")
+    assert group_entry is not None, "Group should be found"
+    assert group_entry.name == "tgroup", "Incorrect groupname"
+    assert group_entry.gid == 1500, "Incorrect GID"