1#
2# @(#) Test logins using pam_winbind.so module using telnet
3#
4
5load_lib util-defs.exp
6load_lib nsswitch-config.exp
7
8#
9#   @(#) Test user can login
10#
11
12spawn telnet localhost
13
14set test_desc "telnet localhost (login)"
15
16expect {
17    "login:"    { }
18    timeout     { fail "timed out in $test_desc"; return }
19    eof         { fail "end of file in $test_desc"; return }
20}
21
22send "$domain/$USER\r"
23
24set test_desc "telnet localhost (password)"
25
26expect {
27    "Password:" { }
28    timeout     { fail "timed out in $test_desc"; return }
29    eof         { fail "end of file in $test_desc"; return }
30}
31
32send "$PASSWORD\r"
33
34expect {
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
41pass "login $domain/$USER"
42
43#
44#   @(#) Check supplementary group membership
45#
46
47set test_desc "supplementary groups"
48
49# Get list of groups
50
51send "id -G\r"
52
53expect {
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
60set groups $expect_out(1,string)
61set wb_groups [util_start "bin/wbinfo" "-r $domain/$USER"]
62
63verbose "id groups are $groups"
64verbose "wbinfo groups are $wb_groups"
65
66# Check all groups from id are in wbinfo and vice-versa
67
68set failed 0
69
70foreach { 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
85foreach { 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
100if { !$failed } {
101    pass "id/wbinfo groups match"
102}
103