mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
tests: Test samba-tool user getgroups command
Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
d73a9d1a8d
commit
fd1c905ec3
@ -24,6 +24,15 @@ CONFIG="--configfile=$PREFIX/simple-dc/etc/smb.conf"
|
||||
testit "user add" $PYTHON $samba_tool user create $CONFIG --given-name="User" --surname="Tester" --initial="UT" testuser testp@ssw0Rd
|
||||
testit "user add" $PYTHON $samba_tool user create $CONFIG --given-name="User1" --surname="Tester" --initial="UT" testuser1 testp@ssw0Rd
|
||||
|
||||
# test samba-tool user getgroups command
|
||||
user_getgroups_primary_only() {
|
||||
res=$($PYTHON $samba_tool user getgroups $CONFIG testuser)
|
||||
|
||||
primary_group=$(echo $res)
|
||||
echo $primary_group | grep -q "^Domain Users$" || return 1
|
||||
}
|
||||
testit "user getgroups primary only" user_getgroups_primary_only
|
||||
|
||||
#test creation of six different groups
|
||||
testit "group add" $PYTHON $samba_tool group add $CONFIG --group-scope='Domain' --group-type='Security' --description='DomainSecurityGroup' --mail-address='dsg@samba.org' --notes='Notes' dsg
|
||||
testit "group add" $PYTHON $samba_tool group add $CONFIG --group-scope='Global' --group-type='Security' --description='GlobalSecurityGroup' --mail-address='gsg@samba.org' --notes='Notes' gsg
|
||||
@ -40,6 +49,21 @@ testit "group addmembers" $PYTHON $samba_tool group addmembers $CONFIG ddg testu
|
||||
testit "group addmembers" $PYTHON $samba_tool group addmembers $CONFIG gdg testuser,testuser1
|
||||
testit "group addmembers" $PYTHON $samba_tool group addmembers $CONFIG udg testuser,testuser1
|
||||
|
||||
# test samba-tool user getgroups command
|
||||
user_getgroups() {
|
||||
groups="dsg gsg usg ddg gdg udg"
|
||||
|
||||
res=$($PYTHON $samba_tool user getgroups $CONFIG testuser)
|
||||
for g in $groups ; do
|
||||
echo "$res" | grep -q "^${g}$" || return 1
|
||||
done
|
||||
|
||||
# the users primary group is expected in the first line
|
||||
primary_group=$(echo "$res" | head -1)
|
||||
echo $primary_group | grep -q "^Domain Users$" || return 1
|
||||
}
|
||||
testit "user getgroups" user_getgroups
|
||||
|
||||
#test removing test users from all groups by their username
|
||||
testit "group removemembers" $PYTHON $samba_tool group removemembers $CONFIG dsg testuser,testuser1
|
||||
testit "group removemembers" $PYTHON $samba_tool group removemembers $CONFIG gsg testuser,testuser1
|
||||
|
Loading…
Reference in New Issue
Block a user