From: Iker Pedrosa Date: Tue, 19 Nov 2024 09:19:09 +0000 (+0100) Subject: tests: delete user and homedir X-Git-Tag: 4.17.3~83 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=3e9293508ac0c00a244cc57af6544df0bbe37f33;p=thirdparty%2Fshadow.git tests: delete user and homedir 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 --- diff --git a/tests/system/tests/test_userdel.py b/tests/system/tests/test_userdel.py new file mode 100644 index 000000000..c92b645c5 --- /dev/null +++ b/tests/system/tests/test_userdel.py @@ -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"