5 Usage: test_smbclient_basic.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD
18 incdir=`dirname $0`/../../../testprogs/blackbox
20 . $incdir/common_test_fns.inc
22 samba_bindir="$BINDIR"
23 samba_vlp="$samba_bindir/vlp"
24 samba_smbspool="$samba_bindir/smbspool"
25 samba_smbspool_krb5="$samba_bindir/smbspool_krb5_wrapper"
27 test_smbspool_noargs()
34 if [ $ret != 0 ]; then
36 echo "failed to execute $1"
39 echo "$out" | grep 'network smb "Unknown" "Windows Printer via SAMBA"'
41 if [ $ret != 0 ] ; then
47 test_smbspool_authinforequired_none()
49 cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1'
51 AUTH_INFO_REQUIRED="none"
52 export AUTH_INFO_REQUIRED
56 unset AUTH_INFO_REQUIRED
58 if [ $ret != 0 ]; then
60 echo "failed to execute $smbspool_krb5"
63 echo "$out" | grep 'ATTR: auth-info-required=negotiate'
65 if [ $ret != 0 ] ; then
72 # The test enviornment uses 'vlp' (virtual lp) as the printing backend.
74 # When using the vlp backend the print job is only written to the database.
75 # The job needs to removed manually using 'vlp lprm' command!
77 # This calls the 'vlp' command to check if the print job has been successfully
78 # added to the database and also makes sure the temorary print file has been
81 # The function removes the print job from the vlp database if successful.
85 tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb"
86 if [ ! -w $tdbfile ]; then
87 echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!"
91 cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
95 if [ $ret != 0 ]; then
96 echo "failed to get print queue with $samba_vlp"
100 jobid=$(echo "$out" | awk '/[0-9]+/ { print $1 };')
101 if [ $jobid -lt 1000 || $jobid -gt 2000 ]; then
102 echo "failed to get jobid"
107 file=$(echo "$out" | awk '/[0-9]+/ { print $6 };')
108 if [ ! -r $PREFIX_ABS/$TARGET_ENV/share/$file ]; then
109 echo "$file doesn't exist"
114 $samba_vlp "tdbfile=$tdbfile" lprm print1 $jobid
116 if [ $ret != 0 ] ; then
117 echo "Failed to remove jobid $jobid from $tdbfile"
122 testit "smbspool no args" \
123 test_smbspool_noargs $samba_smbspool || \
124 failed=$(expr $failed + 1)
126 testit "smbspool_krb5_wrapper no args" \
127 test_smbspool_noargs $samba_smbspool_krb5 || \
128 failed=$(expr $failed + 1)
130 testit "smbspool_krb5_wrapper AuthInfoRequired=none" \
131 test_smbspool_authinforequired_none || \
132 failed=$(expr $failed + 1)
134 testit "smbspool print example.ps" \
135 $samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps || \
136 failed=$(expr $failed + 1)
138 testit "vlp verify example.ps" \
140 || failed=$(expr $failed + 1)
142 testit "smbspool print example.ps via stdin" \
143 $samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" < $SRCDIR/testdata/printing/example.ps || \
144 failed=$(expr $failed + 1)
146 testit "vlp verify example.ps" \
148 || failed=$(expr $failed + 1)
150 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
152 testit "smbspool print DEVICE_URI example.ps" \
153 $samba_smbspool 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps || \
154 failed=$(expr $failed + 1)
157 testit "vlp verify example.ps" \
159 || failed=$(expr $failed + 1)
161 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
163 testit "smbspool print DEVICE_URI example.ps via stdin" \
164 $samba_smbspool 200 $USERNAME "Testprint" 1 "options" < $SRCDIR/testdata/printing/example.ps || \
165 failed=$(expr $failed + 1)
168 testit "vlp verify example.ps" \
170 || failed=$(expr $failed + 1)
172 AUTH_INFO_REQUIRED="username,password"
173 export AUTH_INFO_REQUIRED
174 testit "smbspool_krb5(username,password) print example.ps" \
175 $samba_smbspool_krb5 smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps || \
176 failed=$(expr $failed + 1)
178 testit "vlp verify example.ps" \
180 failed=$(expr $failed + 1)
181 unset AUTH_INFO_REQUIRED