]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/: extend basic usermod test
authorIker Pedrosa <ipedrosa@redhat.com>
Wed, 12 Mar 2025 08:09:28 +0000 (09:09 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 21 May 2025 08:04:42 +0000 (10:04 +0200)
Add additional checks for shadow and gshadow entries.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Reviewed-by: Dan Lavu <dlavu@redhat.com>
tests/system/tests/test_usermod.py

index 2b42363e91701f640633a1d579f9fa9dcacec0c7..f1ba8c689ed5337736a4a4b1f48e7b787dab319f 100644 (file)
@@ -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"