From: Iker Pedrosa Date: Mon, 23 Feb 2026 13:35:28 +0000 (+0100) Subject: tests/system/tests/test_passwd.py: lock user password X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=460bd412c404b1456f116cc43142f6cce31ddafb;p=thirdparty%2Fshadow.git tests/system/tests/test_passwd.py: lock user password This is the transformation to Python of the test located in `tests/passwd/06_passwd_-l_root_lock_account/passwd.test`, which checks that `passwd` is able to lock a user's password. Signed-off-by: Iker Pedrosa --- diff --git a/tests/system/tests/test_passwd.py b/tests/system/tests/test_passwd.py index a946aa816..d01353c40 100644 --- a/tests/system/tests/test_passwd.py +++ b/tests/system/tests/test_passwd.py @@ -69,3 +69,28 @@ def test_passwd__change_password_as_root_interactive(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__lock_password(shadow: Shadow): + """ + :title: Lock user password + :setup: + 1. Create test user + :steps: + 1. Lock user password using -l flag + 2. Check the user's shadow entry + :expectedresults: + 1. User's password is locked + 2. User's shadow entry shows locked password (starts with !) + :customerscenario: False + """ + shadow.useradd("tuser") + + shadow.passwd("-l tuser") + + 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 shadow_entry.password.startswith("!"), "Password should be locked"