]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Tests: Verify user creation succeeds with large valid UIDs
authoraborah-sudo <aborah@redhat.com>
Tue, 7 Apr 2026 10:20:51 +0000 (15:50 +0530)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 10 Apr 2026 08:55:43 +0000 (10:55 +0200)
This is the transformation to Python of the test located in
`tests/usertools/01/25_useradd_specified_large_UID2.test`,
which checks that `useradd` can add a new user with large UID

tests/system/tests/test_useradd.py

index d1f89631056b34d8547bba32982e7373fe977a8c..d50d14828a1ea997eb8fb7a0d7e9d0dbea6eb358 100644 (file)
@@ -454,26 +454,34 @@ def test_useradd__invalid_uid(shadow: Shadow, uid_value: int, expected_error: st
 
 
 @pytest.mark.topology(KnownTopology.Shadow)
-def test_useradd__specific_large_uid(shadow: Shadow):
+@pytest.mark.parametrize(
+    "uid_value",
+    [
+        pytest.param(2147483647, id="maximum_signed_32bit_uid"),
+        pytest.param(4294967294, id="maximum_unsigned_32bit_uid"),
+    ],
+)
+def test_useradd__successful_large_uid(shadow: Shadow, uid_value: int):
     """
-    :title: Verify user creation at the upper boundary for UID
+    :title: Verify user creation succeeds with large valid UIDs
     :steps:
-        1. Create user with UID 2147483647 (2^31 - 1, maximum signed 32-bit integer)
+        1. Create user with UID {uid_value}
         2. Check passwd entry
         3. Check group entry
     :expectedresults:
         1. User is created successfully
-        2. Passwd entry exists with correct UID 2147483647
+        2. Passwd entry exists with correct UID {uid_value}
         3. Group entry exists
     :customerscenario: False
     """
-    shadow.useradd("test1 -u 2147483647")
+    shadow.useradd(f"test1 -u {uid_value}")
 
     passwd_entry = shadow.tools.getent.passwd("test1")
     assert passwd_entry is not None, "User test1 should be found in passwd"
     assert passwd_entry.name == "test1", "Incorrect username"
-    assert passwd_entry.uid == 2147483647, f"Incorrect UID, expected 2147483647, got {passwd_entry.uid}"
+    assert passwd_entry.uid == uid_value, f"Incorrect UID, expected {uid_value}, got {passwd_entry.uid}"
 
     group_entry = shadow.tools.getent.group("test1")
     assert group_entry is not None, "Group test1 should be found"
     assert group_entry.name == "test1", "Incorrect group name"
+