diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-10-10 10:25:57 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-10-10 10:25:57 +0300 |
commit | d22b710477a78f40a7d61a91a8a802e704d24a07 (patch) | |
tree | b2e330f1164210d8a97bea189d72a6f64c51a054 /roles/unix_users/subplot.py | |
parent | 8be4a57cdb3851f127f1d91c56921d7ad58f36d6 (diff) | |
download | debian-ansible-d22b710477a78f40a7d61a91a8a802e704d24a07.tar.gz |
feat: verify unix_users can set shell
Diffstat (limited to 'roles/unix_users/subplot.py')
-rw-r--r-- | roles/unix_users/subplot.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/roles/unix_users/subplot.py b/roles/unix_users/subplot.py index 9b77e49..dc4e9f6 100644 --- a/roles/unix_users/subplot.py +++ b/roles/unix_users/subplot.py @@ -1,3 +1,6 @@ +import logging + + def host_does_not_have_user(ctx, username=None): assert_ne = globals()["assert_ne"] qemu = ctx["qemu"] @@ -12,3 +15,14 @@ def host_has_user(ctx, username=None): assert_eq(exit, 0) output = output.decode("UTF8") assert f"\n{username}:" in output + + +def host_user_has_shell(ctx, username=None, shell=None): + assert_eq = globals()["assert_eq"] + qemu = ctx["qemu"] + output, exit = qemu.ssh(["getent", "passwd", username]) + assert_eq(exit, 0) + for line in output.decode("UTF8").splitlines(): + if line.startswith(f"{username}:"): + logging.debug(f"host_user_has_shell: line={line!r}") + assert line.endswith(f":{shell}") |