From fd1c905ec3b21f7fcc61f9bc827a56e3a3038381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Baumbach?= Date: Tue, 14 Jan 2020 15:10:09 +0100 Subject: [PATCH] tests: Test samba-tool user getgroups command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Björn Baumbach Reviewed-by: Andreas Schneider --- source4/setup/tests/blackbox_group.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source4/setup/tests/blackbox_group.sh b/source4/setup/tests/blackbox_group.sh index 684534483bb..bddc9748f74 100755 --- a/source4/setup/tests/blackbox_group.sh +++ b/source4/setup/tests/blackbox_group.sh @@ -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