stages(users): add small unit test that passwd is called correctly
This commit is contained in:
parent
b722bef9cb
commit
af7485b406
1 changed files with 22 additions and 0 deletions
|
|
@ -82,3 +82,25 @@ def test_users_mock_bin(tmp_path, stage_module, user_opts, expected_args):
|
||||||
stage_module.main(tmp_path, options)
|
stage_module.main(tmp_path, options)
|
||||||
assert len(mocked_chroot.call_args_list) == 1
|
assert len(mocked_chroot.call_args_list) == 1
|
||||||
assert mocked_chroot.call_args_list[0][2:] == expected_args + ["foo"]
|
assert mocked_chroot.call_args_list[0][2:] == expected_args + ["foo"]
|
||||||
|
|
||||||
|
|
||||||
|
# separate test right now as it results in two binaries being called
|
||||||
|
# (adduser,passwd) which our parameter tests cannot do yet
|
||||||
|
def test_users_with_expire_date(tmp_path, stage_module):
|
||||||
|
with mock_command("chroot", "") as mocked_chroot:
|
||||||
|
make_fake_tree(tmp_path, {
|
||||||
|
"/etc/passwd": "",
|
||||||
|
})
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"users": {
|
||||||
|
"foo": {
|
||||||
|
"force_password_reset": True,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage_module.main(tmp_path, options)
|
||||||
|
assert len(mocked_chroot.call_args_list) == 2
|
||||||
|
assert mocked_chroot.call_args_list[0][1:] == ["useradd", "foo"]
|
||||||
|
assert mocked_chroot.call_args_list[1][1:] == ["passwd", "--expire", "foo"]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue