summaryrefslogtreecommitdiff
path: root/testsuite/nsswitch/login.exp
blob: c2bb0e5a40aac0381b4b73ef856e880e793d05b4 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#
# @(#) Test logins using pam_winbind.so module using telnet
#

load_lib util-defs.exp
load_lib nsswitch-config.exp

#
#   @(#) Test user can login
#

spawn telnet localhost

set test_desc "telnet localhost (login)"

expect {
    "login:"    { }
    timeout     { fail "timed out in $test_desc"; return }
    eof         { fail "end of file in $test_desc"; return }
}

send "$domain/$USER\r"

set test_desc "telnet localhost (password)"

expect {
    "Password:" { }
    timeout     { fail "timed out in $test_desc"; return }
    eof         { fail "end of file in $test_desc"; return }
}

send "$PASSWORD\r"

expect {
    "$ " { }
    "Login incorrect" { fail "login incorrect"; return }
    timeout     { fail "timed out in $test_desc"; return }
    eof         { fail "end of file in $test_desc"; return }
}

pass "login $domain/$USER"

#
#   @(#) Check supplementary group membership
#

set test_desc "supplementary groups"

# Get list of groups

send "id -G\r"

expect {
    -re "((\[0-9]+ )*\[0-9]+\r)" { exp_continue; }
    "$ " { }
    timeout     { fail "timed out in $test_desc"; return }
    eof         { fail "end of file in $test_desc"; return }
}

set groups $expect_out(1,string)
set wb_groups [util_start "bin/wbinfo" "-r $domain/$USER"]

verbose "id groups are $groups"
verbose "wbinfo groups are $wb_groups"

# Check all groups from id are in wbinfo and vice-versa

set failed 0

foreach { group } $groups {
    set got_group 0
    foreach { wb_group } $wb_groups {
	if { $wb_group == $group } {
	    set got_group 1
	    break
	}
    }

    if { !$got_group } {
	fail "group $group not in output of wbinfo -r"
	set failed 1
    }
}

foreach { wb_group } $wb_groups {
    set got_group 0
    foreach { group } $groups {
	if { $group == $wb_group } {
	    set got_group 1
	    break
	}
    }

    if { !$got_group } {
	fail "group $group not in output of id -G"
	set failed 1
    }
}

if { !$failed } {
    pass "id/wbinfo groups match"
}