This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[ira/wip.git] / testsuite / nsswitch / login.exp
1 #
2 # @(#) Test logins using pam_winbind.so module using telnet
3 #
4
5 load_lib util-defs.exp
6 load_lib nsswitch-config.exp
7
8 #
9 #   @(#) Test user can login
10 #
11
12 spawn telnet localhost
13
14 set test_desc "telnet localhost (login)"
15
16 expect {
17     "login:"    { }
18     timeout     { fail "timed out in $test_desc"; return }
19     eof         { fail "end of file in $test_desc"; return }
20 }
21
22 send "$domain/$USER\r"
23
24 set test_desc "telnet localhost (password)"
25
26 expect {
27     "Password:" { }
28     timeout     { fail "timed out in $test_desc"; return }
29     eof         { fail "end of file in $test_desc"; return }
30 }
31
32 send "$PASSWORD\r"
33
34 expect {
35     "$ " { }
36     "Login incorrect" { fail "login incorrect"; return }
37     timeout     { fail "timed out in $test_desc"; return }
38     eof         { fail "end of file in $test_desc"; return }
39 }
40
41 pass "login $domain/$USER"
42
43 #
44 #   @(#) Check supplementary group membership
45 #
46
47 set test_desc "supplementary groups"
48
49 # Get list of groups
50
51 send "id -G\r"
52
53 expect {
54     -re "((\[0-9]+ )*\[0-9]+\r)" { exp_continue; }
55     "$ " { }
56     timeout     { fail "timed out in $test_desc"; return }
57     eof         { fail "end of file in $test_desc"; return }
58 }
59
60 set groups $expect_out(1,string)
61 set wb_groups [util_start "bin/wbinfo" "-r $domain/$USER"]
62
63 verbose "id groups are $groups"
64 verbose "wbinfo groups are $wb_groups"
65
66 # Check all groups from id are in wbinfo and vice-versa
67
68 set failed 0
69
70 foreach { group } $groups {
71     set got_group 0
72     foreach { wb_group } $wb_groups {
73         if { $wb_group == $group } {
74             set got_group 1
75             break
76         }
77     }
78
79     if { !$got_group } {
80         fail "group $group not in output of wbinfo -r"
81         set failed 1
82     }
83 }
84
85 foreach { wb_group } $wb_groups {
86     set got_group 0
87     foreach { group } $groups {
88         if { $group == $wb_group } {
89             set got_group 1
90             break
91         }
92     }
93
94     if { !$got_group } {
95         fail "group $group not in output of id -G"
96         set failed 1
97     }
98 }
99
100 if { !$failed } {
101     pass "id/wbinfo groups match"
102 }