[v2,2/4] testsuite: fix deterministic password test in image account extension

Message ID 20261026143132.1067398-2-clara.kowalsky@siemens.com
State New
Headers show
Series [v2,1/4] testsuite: fix run_privileged_cmd in image account extension unit test | expand

Commit Message

Clara Kowalsky Oct. 26, 2026, 2:31 p.m. UTC
The test expected two process.run calls which worked for the original
crypt-based implementation. Commit 6144daf9 replaced crypt with an
openssl passwd subprocess, adding a third call, but did not update the
test.
Also mock the openssl output and verify the expected salt and password
input.

Fixes: 6144daf9 ("image-account-extension: Avoid deprecated crypt module")
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
 testsuite/unittests/test_image_account_extension.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch

diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
index 8bf5f82b..266883c1 100644
--- a/testsuite/unittests/test_image_account_extension.py
+++ b/testsuite/unittests/test_image_account_extension.py
@@ -118,11 +118,16 @@  class TestImageAccountExtensionImageCreateUsers(
         )
 
         with patch.object(process, 'run') as run_mock:
+            run_mock.return_value = (encrypted_password, '')
             image_create_users(d)
 
         password_data = f"{test_user}:{encrypted_password}".encode()
 
-        assert run_mock.call_count == 2
+        assert run_mock.call_count == 3
+        run_mock.assert_any_call([
+            'openssl', 'passwd', '-6', '--salt', 'eb2e2a12cccc88a',
+            cleartext_password,
+        ])
         assert run_mock.call_args[0][1] == password_data