public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH 1/2] testsuite: fix run_privileged_cmd in image account extension unit test
@ 2026-10-26 12:18 'Clara Kowalsky' via isar-users
  2026-10-26 12:18 ` [PATCH 2/2] testsuite: fix deterministic password test in image account extension 'Clara Kowalsky' via isar-users
  0 siblings, 1 reply; 3+ messages in thread
From: 'Clara Kowalsky' via isar-users @ 2026-10-26 12:18 UTC (permalink / raw)
  To: isar-users; +Cc: Clara Kowalsky

The account functions use run_privileged_cmd which BitBake provides
through base.bbclass. The tests load the functions in isolation, so the
helper is undefined and the tests fail with:

NameError: name 'run_privileged_cmd' is not defined

Fix this by providing a stub for the helper in the test namespace.

Fixes: 14acf490 ("introduce wrappers for privileged execution")
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
 testsuite/unittests/test_image_account_extension.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
index ff0e47e0..ecadc15f 100644
--- a/testsuite/unittests/test_image_account_extension.py
+++ b/testsuite/unittests/test_image_account_extension.py
@@ -18,8 +18,15 @@ from bb import process
 from bb.data_smart import DataSmart
 
 file_name = 'meta/classes-recipe/image-account-extension.bbclass'
-image_create_users = load_function(file_name, 'image_create_users')
-image_create_groups = load_function(file_name, 'image_create_groups')
+
+
+def run_privileged_cmd(d):
+    return 'sudo -E'
+
+
+namespace = {'run_privileged_cmd': run_privileged_cmd}
+image_create_users = load_function(file_name, 'image_create_users', namespace)
+image_create_groups = load_function(file_name, 'image_create_groups', namespace)
 
 
 class TestImageAccountExtensionCommon(unittest.TestCase):
-- 
2.55.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026121844.663746-1-clara.kowalsky%40siemens.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] testsuite: fix deterministic password test in image account extension
  2026-10-26 12:18 [PATCH 1/2] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
@ 2026-10-26 12:18 ` 'Clara Kowalsky' via isar-users
  2026-10-26 12:41   ` 'Moessbauer, Felix' via isar-users
  0 siblings, 1 reply; 3+ messages in thread
From: 'Clara Kowalsky' via isar-users @ 2026-10-26 12:18 UTC (permalink / raw)
  To: isar-users; +Cc: Clara Kowalsky

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(-)

diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
index ecadc15f..fcc23506 100644
--- a/testsuite/unittests/test_image_account_extension.py
+++ b/testsuite/unittests/test_image_account_extension.py
@@ -117,11 +117,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
 
 
-- 
2.55.0

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026121844.663746-2-clara.kowalsky%40siemens.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] testsuite: fix deterministic password test in image account extension
  2026-10-26 12:18 ` [PATCH 2/2] testsuite: fix deterministic password test in image account extension 'Clara Kowalsky' via isar-users
@ 2026-10-26 12:41   ` 'Moessbauer, Felix' via isar-users
  0 siblings, 0 replies; 3+ messages in thread
From: 'Moessbauer, Felix' via isar-users @ 2026-10-26 12:41 UTC (permalink / raw)
  To: Kowalsky, Clara, isar-users

On Mon, 2026-10-26 at 13:18 +0100, 'Clara Kowalsky' via isar-users
wrote:
> 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.

Hi,

the changes itself are fine. But we need to ensure these tests are also
executed via our testsuite. Please add a third commit that registers
them with the "fast" tests.

Felix

> 
> 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(-)
> 
> diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
> index ecadc15f..fcc23506 100644
> --- a/testsuite/unittests/test_image_account_extension.py
> +++ b/testsuite/unittests/test_image_account_extension.py
> @@ -117,11 +117,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
>  
>  
> -- 
> 2.55.0
> 
> -- 
> You received this message because you are subscribed to the Google Groups "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/isar-users/20261026121844.663746-2-clara.kowalsky%40siemens.com.

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/e5b90d1a714e2f04b29138a1fd516a9f532a5b9c.camel%40siemens.com.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-26 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-26 12:18 [PATCH 1/2] testsuite: fix run_privileged_cmd in image account extension unit test 'Clara Kowalsky' via isar-users
2026-10-26 12:18 ` [PATCH 2/2] testsuite: fix deterministic password test in image account extension 'Clara Kowalsky' via isar-users
2026-10-26 12:41   ` 'Moessbauer, Felix' via isar-users

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox