Skip to content

Commit bc42787

Browse files
CarstenGrohmannphilpep
authored andcommitted
Add propery Group.user_list
This property contains all users that are members of this group.
1 parent 2c4cc7a commit bc42787

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

testinfra/modules/group.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,13 @@ def exists(self):
3737
def gid(self):
3838
return int(self.check_output("getent group %s | cut -d':' -f3", self.name))
3939

40+
@property
41+
def user_list(self):
42+
"""Return all users that are members of this group."""
43+
users = self.check_output("getent group %s | cut -d':' -f4", self.name)
44+
if users:
45+
return users.split(",")
46+
return []
47+
4048
def __repr__(self):
4149
return "<group {}>".format(self.name)

0 commit comments

Comments
 (0)