drsuapi.idl: add drsuapi_DrsMoreOptions with DRSUAPI_DRS_GET_TGT
[Samba.git] / source3 / script / tests / test_ntlm_auth_s3.sh
blob2b5e4353557390666a43dedc92bfc7538e19ecb1
1 #!/bin/sh
3 if [ $# -lt 2 ]; then
4 cat <<EOF
5 Usage: test_ntlm_auth_s3.sh PYTHON SRC3DIR NTLM_AUTH
6 EOF
7 exit 1;
8 fi
10 PYTHON=$1
11 SRC3DIR=$2
12 NTLM_AUTH=$3
13 DOMAIN=$4
14 USERNAME=$5
15 PASSWORD=$6
16 shift 6
17 ADDARGS="$*"
19 incdir=`dirname $0`/../../../testprogs/blackbox
20 . $incdir/subunit.sh
22 SID=`eval $BINDIR/wbinfo -n $USERNAME | cut -d ' ' -f1`
23 BADSID=`eval $BINDIR/wbinfo -n $USERNAME | cut -d ' ' -f1 | sed 's/..$//'`
25 failed=0
27 test_plaintext_check_output_stdout()
29 tmpfile=$PREFIX/ntlm_commands
31 cat > $tmpfile <<EOF
32 $DOMAIN/$USERNAME $PASSWORD
33 EOF
34 cmd='$NTLM_AUTH "$@" --require-membership-of=$SID --helper-protocol=squid-2.5-basic < $tmpfile 2>&1'
35 eval echo "$cmd"
36 out=`eval $cmd`
37 ret=$?
38 rm -f $tmpfile
40 if [ $ret != 0 ] ; then
41 echo "$out"
42 echo "command failed"
43 false
44 return
47 echo "$out" | grep "OK" >/dev/null 2>&1
49 if [ $? = 0 ] ; then
50 # authenticated .. succeed
51 true
52 else
53 echo failed to get successful authentication
54 false
58 test_plaintext_check_output_fail()
60 tmpfile=$PREFIX/ntlm_commands
62 cat > $tmpfile <<EOF
63 $DOMAIN\\$USERNAME $PASSWORD
64 EOF
65 cmd='$NTLM_AUTH "$@" --require-membership-of=$BADSID --helper-protocol=squid-2.5-basic < $tmpfile 2>&1'
66 eval echo "$cmd"
67 out=`eval $cmd`
68 ret=$?
69 rm -f $tmpfile
71 if [ $ret != 0 ] ; then
72 echo "$out"
73 echo "command failed"
74 false
75 return
78 echo "$out" | grep "ERR" >/dev/null 2>&1
80 if [ $? = 0 ] ; then
81 # failed to authenticate .. success
82 true
83 else
84 echo "incorrectly gave a successful authentication"
85 false
89 test_ntlm_server_1_check_output()
91 tmpfile=$PREFIX/ntlm_commands
93 cat > $tmpfile <<EOF
94 LANMAN-Challenge: 0123456789abcdef
95 NT-Response: 25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6
96 NT-Domain: TEST
97 Username: testuser
98 Request-User-Session-Key: Yes
101 cmd='$NTLM_AUTH "$@" --helper-protocol=ntlm-server-1 --password=SecREt01< $tmpfile 2>&1'
102 eval echo "$cmd"
103 out=`eval $cmd`
104 ret=$?
105 rm -f $tmpfile
107 if [ $ret != 0 ] ; then
108 echo "$out"
109 echo "command failed"
110 false
111 return
114 echo "$out" | grep "User-Session-Key: 3F373EA8E4AF954F14FAA506F8EEBDC4" >/dev/null 2>&1
116 if [ $? = 0 ] ; then
117 # authenticated .. succeed
118 true
119 else
120 echo failed to get successful authentication
121 false
125 test_ntlm_server_1_check_output_fail()
127 tmpfile=$PREFIX/ntlm_commands
129 # Break the password with a leading A on the challenge
130 cat > $tmpfile <<EOF
131 LANMAN-Challenge: A123456789abcdef
132 NT-Response: 25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6
133 NT-Domain: TEST
134 Username: testuser
135 Request-User-Session-Key: Yes
138 cmd='$NTLM_AUTH "$@" --helper-protocol=ntlm-server-1 --password=SecREt01 < $tmpfile 2>&1'
139 eval echo "$cmd"
140 out=`eval $cmd`
141 ret=$?
142 rm -f $tmpfile
144 if [ $ret != 0 ] ; then
145 echo "$out"
146 echo "command failed"
147 false
148 return
151 echo "$out" | grep "Authenticated: No" >/dev/null 2>&1
153 if [ $? = 0 ] ; then
154 # failed to authenticate .. success
155 true
156 else
157 echo "incorrectly gave a successful authentication"
158 false
162 test_ntlm_server_1_check_winbind_output()
164 tmpfile=$PREFIX/ntlm_commands
166 # This isn't the correct password
167 cat > $tmpfile <<EOF
168 Password: $PASSWORD
169 NT-Domain: $DOMAIN
170 Username: $USERNAME
171 Request-User-Session-Key: Yes
174 cmd='$NTLM_AUTH "$@" --helper-protocol=ntlm-server-1 --require-membership-of=$SID < $tmpfile 2>&1'
175 eval echo "$cmd"
176 out=`eval $cmd`
177 ret=$?
178 rm -f $tmpfile
180 if [ $ret != 0 ] ; then
181 echo "$out"
182 echo "command failed"
183 false
184 return
187 echo "$out" | grep "Authenticated: Yes" >/dev/null 2>&1
189 if [ $? = 0 ] ; then
190 # authenticated .. success
191 true
192 else
193 echo "Failed to authenticate the user or match with SID $SID"
194 false
198 test_ntlm_server_1_check_winbind_output_wrong_sid()
200 tmpfile=$PREFIX/ntlm_commands
202 # This isn't the correct password
203 cat > $tmpfile <<EOF
204 Password: $PASSWORD
205 NT-Domain: $DOMAIN
206 Username: $USERNAME
207 Request-User-Session-Key: Yes
210 cmd='$NTLM_AUTH "$@" --helper-protocol=ntlm-server-1 --require-membership-of=$BADSID < $tmpfile 2>&1'
211 eval echo "$cmd"
212 out=`eval $cmd`
213 ret=$?
214 rm -f $tmpfile
216 if [ $ret != 0 ] ; then
217 echo "$out"
218 echo "command failed"
219 false
220 return
223 echo "$out" | grep "Authenticated: No" >/dev/null 2>&1
225 if [ $? = 0 ] ; then
226 # failed to authenticate .. success
227 true
228 else
229 echo "incorrectly gave a successful authentication"
230 false
234 test_ntlm_server_1_check_winbind_output_fail()
236 tmpfile=$PREFIX/ntlm_commands
238 # This isn't the correct password
239 cat > $tmpfile <<EOF
240 LANMAN-Challenge: 0123456789abcdef
241 NT-Response: 25a98c1c31e81847466b29b2df4680f39958fb8c213a9cc6
242 NT-Domain: $DOMAIN
243 Username: $USERNAME
244 Request-User-Session-Key: Yes
247 cmd='$NTLM_AUTH "$@" --helper-protocol=ntlm-server-1 < $tmpfile 2>&1'
248 eval echo "$cmd"
249 out=`eval $cmd`
250 ret=$?
251 rm -f $tmpfile
253 if [ $ret != 0 ] ; then
254 echo "$out"
255 echo "command failed"
256 false
257 return
260 echo "$out" | grep "Authenticated: No" >/dev/null 2>&1
262 if [ $? = 0 ] ; then
263 # failed to authenticate .. success
264 true
265 else
266 echo "incorrectly gave a successful authentication"
267 false
271 testit "ntlm_auth" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS || failed=`expr $failed + 1`
272 # This should work even with NTLMv2
273 testit "ntlm_auth with specified domain" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo || failed=`expr $failed + 1`
274 testit "ntlm_auth against winbindd" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd $ADDARGS || failed=`expr $failed + 1`
275 testit "ntlm_auth with NTLMSSP client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=ntlmssp-client-1 --server-helper=gss-spnego || failed=`expr $failed + 1`
276 testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-domain=fOo --server-domain=fOo --client-helper=gss-spnego-client --server-helper=gss-spnego || failed=`expr $failed + 1`
277 testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server against winbind" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd --client-helper=gss-spnego-client --server-helper=gss-spnego $ADDARGS || failed=`expr $failed + 1`
279 testit "wbinfo store cached credentials" $BINDIR/wbinfo --ccache-save=$DOMAIN/$USERNAME%$PASSWORD || failed=`expr $failed + 1`
280 testit "ntlm_auth ccached credentials with NTLMSSP client and gss-spnego server" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH $ADDARGS --client-username=$USERNAME --client-domain=$DOMAIN --client-use-cached-creds --client-helper=ntlmssp-client-1 --server-helper=gss-spnego --server-use-winbindd || failed=`expr $failed + 1`
282 testit "ntlm_auth against winbindd with require-membership-of" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd $ADDARGS --require-membership-of=$SID || failed=`expr $failed + 1`
283 testit "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server against winbind with require-membership-of" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd --client-helper=gss-spnego-client --server-helper=gss-spnego $ADDARGS --require-membership-of=$SID || failed=`expr $failed + 1`
285 testit_expect_failure "ntlm_auth against winbindd with failed require-membership-of" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd $ADDARGS --require-membership-of=$BADSID && failed=`expr $failed + 1`
286 testit_expect_failure "ntlm_auth with NTLMSSP gss-spnego-client and gss-spnego server against winbind with failed require-membership-of" $PYTHON $SRC3DIR/torture/test_ntlm_auth.py $NTLM_AUTH --client-username=$USERNAME --client-domain=$DOMAIN --client-password=$PASSWORD --server-use-winbindd --client-helper=gss-spnego-client --server-helper=gss-spnego $ADDARGS --require-membership-of=$BADSID && failed=`expr $failed + 1`
288 testit "ntlm_auth plaintext authentication with require-membership-of" test_plaintext_check_output_stdout || failed=`expr $failed + 1`
289 testit "ntlm_auth plaintext authentication with failed require-membership-of" test_plaintext_check_output_fail || failed=`expr $failed + 1`
291 testit "ntlm_auth ntlm-server-1 with fixed password" test_ntlm_server_1_check_output || failed=`expr $failed + 1`
292 testit "ntlm_auth ntlm-server-1 with incorrect fixed password" test_ntlm_server_1_check_output_fail || failed=`expr $failed + 1`
293 testit "ntlm_auth ntlm-server-1 with plaintext password against winbind" test_ntlm_server_1_check_winbind_output || failed=`expr $failed + 1`
294 testit "ntlm_auth ntlm-server-1 with plaintext password against winbind but wrong sid" test_ntlm_server_1_check_winbind_output_wrong_sid || failed=`expr $failed + 1`
295 testit "ntlm_auth ntlm-server-1 with incorrect fixed password against winbind" test_ntlm_server_1_check_winbind_output_fail || failed=`expr $failed + 1`
297 testok $0 $failed