From: aborah-sudo Date: Tue, 7 Apr 2026 10:20:51 +0000 (+0530) Subject: Tests: Verify user creation succeeds with large valid UIDs X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9ea73bcfdc1901b2eb99e1c1ed7a67601268f35a;p=thirdparty%2Fshadow.git Tests: Verify user creation succeeds with large valid UIDs 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 --- diff --git a/tests/system/tests/test_useradd.py b/tests/system/tests/test_useradd.py index d1f896310..d50d14828 100644 --- a/tests/system/tests/test_useradd.py +++ b/tests/system/tests/test_useradd.py @@ -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" +