summaryrefslogtreecommitdiff
path: root/roles/unix_users/subplot.py
diff options
context:
space:
mode:
Diffstat (limited to 'roles/unix_users/subplot.py')
-rw-r--r--roles/unix_users/subplot.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/roles/unix_users/subplot.py b/roles/unix_users/subplot.py
index 7bf921d..05330fd 100644
--- a/roles/unix_users/subplot.py
+++ b/roles/unix_users/subplot.py
@@ -14,7 +14,7 @@ def host_has_user(ctx, username=None):
output, exit = qemu.ssh(["getent", "passwd", username])
assert_eq(exit, 0)
output = output.decode("UTF8")
- assert f"\n{username}:" in output
+ assert f"{username}:" in output
def host_user_has_shell(ctx, username=None, shell=None):
@@ -46,3 +46,14 @@ def host_user_has_authorized_keys_containing(ctx, username=None, substring=None)
assert_eq(exit, 0)
output = output.decode("UTF8")
assert substring in output
+
+
+def host_user_is_in_group(ctx, username=None, group=None):
+ assert_eq = globals()["assert_eq"]
+ qemu = ctx["qemu"]
+ output, exit = qemu.ssh(["sudo", "-u", username, "groups"])
+ assert_eq(exit, 0)
+ output = output.decode("UTF8")
+ groups = output.split()
+ logging.debug(f"host_user_is_in_group: groups={groups}")
+ assert group in groups