From: Iker Pedrosa Date: Tue, 9 Sep 2025 07:23:30 +0000 (+0200) Subject: tests/system/tests/test_passwd.py: change user password as root in interactive mode X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f89a5718dce1f2dc02debe2b3f8557c52e9f1795;p=thirdparty%2Fshadow.git tests/system/tests/test_passwd.py: change user password as root in interactive mode This is the transformation to Python of the test located in `tests/passwd/18_passwd_root_change_password_user/passwd.test`, which checks that `passwd` is able to change a user's password running as root in interactive mode. Signed-off-by: Iker Pedrosa --- diff --git a/tests/system/tests/test_passwd.py b/tests/system/tests/test_passwd.py index cdb2bd9d1..a946aa816 100644 --- a/tests/system/tests/test_passwd.py +++ b/tests/system/tests/test_passwd.py @@ -40,3 +40,32 @@ def test_passwd__change_password_as_root_with_stdin(shadow: Shadow): assert shadow_entry.min_days == 0, "Incorrect min days" assert shadow_entry.max_days == 99999, "Incorrect max days" assert shadow_entry.warn_days == 7, "Incorrect warn days" + + +@pytest.mark.topology(KnownTopology.Shadow) +def test_passwd__change_password_as_root_interactive(shadow: Shadow): + """ + :title: Change user password as root in interactive mode + :setup: + 1. Create test user + :steps: + 1. Change user password as root in interactive mode + 2. Check the user's shadow entry + :expectedresults: + 1. User's password is changed + 2. User's shadow entry is correct + :customerscenario: False + """ + shadow.useradd("tuser") + + shadow.passwd("tuser", new_password="Secret123") + + shadow_entry = shadow.tools.getent.shadow("tuser") + assert shadow_entry is not None, "User should be found" + assert shadow_entry.name == "tuser", "Incorrect username" + assert shadow_entry.password is not None, "Password should not be None" + assert re.match(shadow_password_pattern(), shadow_entry.password), "Incorrect password" + assert shadow_entry.last_changed == days_since_epoch(), "Incorrect last changed" + assert shadow_entry.min_days == 0, "Incorrect min days" + assert shadow_entry.max_days == 99999, "Incorrect max days" + assert shadow_entry.warn_days == 7, "Incorrect warn days"