shadow/tests/grouptools/groupmems/28_groupmems_user_add_user-already_member_in_gshadow/run_groupmems.exp
Serge Hallyn b999d48941 Add tests from the old svn tree
We're losing the svn history (which we could probably keep if we tried
hard enough) but don't consider that worthwhile.

Note these tests are destructive, so run them only in a throwaway
environment like a chroot, container, or vm.

The tests/run.all script should be the one which launches all the tests.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-09-17 14:42:55 -05:00

49 lines
1.3 KiB
Plaintext
Executable File

#!/usr/bin/expect
set timeout 2
expect_after default {puts "\nFAIL"; exit 1}
if {$argc != 0} {
puts "usage: run_groupmems.exp"
exit 1
}
# First, switch to the testsuite user
# (otherwise, no password will be asked)
send_user "# switch to the 'myuser' user\n"
send_user "# and expect a '$ ' prompt\n"
spawn /bin/su myuser
expect "$ " ;# Wait for the prompt
send_user "\n# make sure we are now 'myuser'"
send_user "\n# id should return 'uid=424242(myuser) gid=424242(myuser) groups=424242(myuser),99(groupmems)'"
send "\r" ;# restore the prompt for the logs
send "id\r" ;# Verify we are really testsuite
expect "uid=424242(myuser) gid=424242(myuser) groups=424242(myuser),99(groupmems)"
expect "$ " ;# Wait for the prompt
send_user "\n\n"
send_user "# now add user utest1 to the myuser group\n"
send_user "# and expect a password prompt"
send "\r" ;# restore the prompt for the logs
send "/usr/sbin/groupmems -a utest1\r" ;#
expect "Password: " ;# Wait for the Password: prompt
# Wait a little bit more (it is not ready to receive the password)
sleep 0.1
send "myuserF00barbaz\r" ;# Send the password
send_user "\n# password 'myuserF00barbaz' sent\n\n"
expect "$ " ;# Wait for the prompt
send "echo $?\r"
expect "0\r"
expect "$ " ;# Wait for the prompt
close
puts "\nPASS"
exit 0