s4:kdc: Implement KDC plugin hardware authentication policy
[samba.git] / source3 / script / tests / test_smb2_not_casesensitive.sh
1 #!/bin/sh
2 #
3 # Blackbox test for SMB2 case insensitivity
4 #
5
6 if [ $# -lt 6 ]; then
7         cat <<EOF
8 Usage: test_smb2_not_casesensitive SERVER SERVER_IP USERNAME PASSWORD LOCAL_PATH SMBCLIENT
9 EOF
10         exit 1
11 fi
12
13 SERVER=${1}
14 SERVER_IP=${2}
15 USERNAME=${3}
16 PASSWORD=${4}
17 LOCAL_PATH=${5}
18 SMBCLIENT=${6}
19
20 incdir=$(dirname $0)/../../../testprogs/blackbox
21 . $incdir/subunit.sh
22
23 failed=0
24
25 # Test a file with different case works over SMB2 and later
26 test_access_with_different_case()
27 {
28         tmpfile=$LOCAL_PATH/testfile.txt
29         echo "foobar" >$tmpfile
30
31         cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -mSMB3 -U$USERNAME%$PASSWORD "$SERVER" -I $SERVER_IP -c "ls TeStFiLe.TxT" 2>&1'
32         out=$(eval $cmd)
33         ret=$?
34
35         rm -f $tmpfile
36
37         if [ $ret = 0 ]; then
38                 return 0
39         else
40                 echo "$out"
41                 echo "failed to get file with different case"
42                 return 1
43         fi
44 }
45
46 # Test that a rename causes a conflict works when target name exists in
47 # different case
48 test_rename()
49 {
50         set -x
51         tmpfile=$LOCAL_PATH/torename.txt
52         echo "foobar" >$tmpfile
53         targetfile=$LOCAL_PATH/target.txt
54         touch $targetfile
55
56         cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -mSMB3 -U$USERNAME%$PASSWORD "$SERVER" -I $SERVER_IP -c "rename ToReNaMe.TxT TaRgEt.txt" 2>&1'
57         out=$(eval $cmd)
58         ret=$?
59
60         rm -f $tmpfile
61         rm -f $targetfile
62         rm -f $LOCAL_PATH/TaRgEt.txt
63
64         if [ $ret = 1 -a -z "${out##*COLLISION*}" ]; then
65                 return 0
66         else
67                 echo "$out"
68                 echo "failed to get file with different case"
69                 return 1
70         fi
71 }
72
73 testit "accessing a file with different case succeeds" \
74         test_access_with_different_case ||
75         failed=$(expr $failed + 1)
76
77 testit "renaming a file with different case succeeds" \
78         test_rename ||
79         failed=$(expr $failed + 1)
80
81 exit $failed