From: Iker Pedrosa Date: Wed, 12 Mar 2025 08:09:28 +0000 (+0100) Subject: tests/: extend basic usermod test X-Git-Tag: 4.18.0-rc1~87 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1791d8a638fbd4d9a4fc6dc6043c764c6f997f82;p=thirdparty%2Fshadow.git tests/: extend basic usermod test Add additional checks for shadow and gshadow entries. Signed-off-by: Iker Pedrosa Reviewed-by: Dan Lavu --- diff --git a/tests/system/tests/test_usermod.py b/tests/system/tests/test_usermod.py index 2b42363e9..f1ba8c689 100644 --- a/tests/system/tests/test_usermod.py +++ b/tests/system/tests/test_usermod.py @@ -18,26 +18,39 @@ def test_usermod__rename_user(shadow: Shadow): 1. Create user 2. Rename user :steps: - 1. User exists with new name and GID is 1000 - 2. Group exists and GID is 1000 - 3. Home folder exists + 1. Check passwd entry + 2. Check shadow entry + 3. Check group entry + 4. Check gshadow entry + 5. Check home folder :expectedresults: - 1. User is found and UID matches - 2. Group is found and GID matches - 3. Home folder is found + 1. passwd entry for the user exists and the attributes are correct + 2. shadow entry for the user exists and the attributes are correct + 3. group entry for the user exists and the attributes are correct + 4. gshadow entry for the user exists and the attributes are correct + 5. Home folder exists :customerscenario: False """ shadow.useradd("tuser1") shadow.usermod("-l tuser2 tuser1") - result = shadow.tools.id("tuser2") + result = shadow.tools.getent.passwd("tuser2") assert result is not None, "User should be found" - assert result.user.name == "tuser2", "Incorrect username" - assert result.user.id == 1000, "Incorrect UID" + assert result.name == "tuser2", "Incorrect username" + assert result.uid == 1000, "Incorrect UID" + + result = shadow.tools.getent.shadow("tuser2") + assert result is not None, "User should be found" + assert result.name == "tuser2", "Incorrect username" result = shadow.tools.getent.group("tuser1") assert result is not None, "Group should be found" assert result.name == "tuser1", "Incorrect groupname" assert result.gid == 1000, "Incorrect GID" + if shadow.host.features["gshadow"]: + result = shadow.tools.getent.gshadow("tuser1") + assert result is not None, "User should be found" + assert result.name == "tuser1", "Incorrect username" + assert shadow.fs.exists("/home/tuser1"), "Home folder should be found"