summaryrefslogtreecommitdiff
path: root/tests/grouptools/groupmems/20_groupmems_user_purge_user/run_groupmems.exp
blob: 0bd4b824842ec23c7ae654a6f5f7a239f4c5dec1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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 -p\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"
send_user "# expect prompt '$ '"

expect "$ "			;# Wait for the prompt
send "echo $?\r"
expect "0\r"
expect "$ "			;# Wait for the prompt
close

puts "\nPASS"
exit 0