]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests: delete user and homedir
authorIker Pedrosa <ipedrosa@redhat.com>
Tue, 19 Nov 2024 09:19:09 +0000 (10:19 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sat, 11 Jan 2025 02:21:07 +0000 (20:21 -0600)
This is the transformation to Python of the test located in
`tests/usertools/01/18_userdel_remove_homedir.test`, which checks that
`userdel` is able to delete a user and its homedir. The test checks that
the user, the group and the home folder don't exist.

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
tests/system/tests/test_userdel.py [new file with mode: 0644]

diff --git a/tests/system/tests/test_userdel.py b/tests/system/tests/test_userdel.py
new file mode 100644 (file)
index 0000000..c92b645
--- /dev/null
@@ -0,0 +1,39 @@
+"""
+Test userdel
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from framework.roles.shadow import Shadow
+from framework.topology import KnownTopology
+
+
+@pytest.mark.topology(KnownTopology.Shadow)
+def test_userdel__homedir_removed(shadow: Shadow):
+    """
+    :title: Delete user and homedir
+    :setup:
+        1. Create user
+        2. Delete the user and the homedir
+    :steps:
+        1. User doesn't exist
+        2. Group doesn't exist
+        3. Home folder doesn't exist
+    :expectedresults:
+        1. User is not found
+        2. Group is not found
+        3. Home folder is not found
+    :customerscenario: False
+    """
+    shadow.useradd("tuser")
+    shadow.userdel("-r tuser")
+
+    result = shadow.tools.id("tuser")
+    assert result is None, "User should not be found"
+
+    result = shadow.tools.getent.group("tuser")
+    assert result is None, "Group should not be found"
+
+    assert not shadow.fs.exists("/home/tuser"), "Home folder should not exist"