5 Usage: test_smbspool.sh SERVER SERVER_IP USERNAME PASSWORD TARGET_ENV
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_argv_wrapper="$samba_bindir/smbspool_argv_wrapper"
26 samba_smbtorture3="$samba_bindir/smbtorture3"
27 samba_smbspool_krb5="$samba_bindir/smbspool_krb5_wrapper"
29 test_smbspool_noargs()
36 if [ $ret != 0 ]; then
38 echo "failed to execute $1"
41 echo "$out" | grep 'network smb "Unknown" "Windows Printer via SAMBA"'
43 if [ $ret != 0 ]; then
49 test_smbspool_authinforequired_none()
51 cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print4 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1'
53 AUTH_INFO_REQUIRED="none"
54 export AUTH_INFO_REQUIRED
58 unset AUTH_INFO_REQUIRED
60 if [ $ret != 0 ]; then
62 echo "failed to execute $smbspool_krb5"
69 test_smbspool_authinforequired_unknown()
71 cmd='$samba_smbspool_krb5 smb://$SERVER_IP/print4 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps 2>&1'
73 # smbspool_krb5_wrapper must ignore AUTH_INFO_REQUIRED unknown to him and pass the task to smbspool
74 # smbspool must fail with NT_STATUS_ACCESS_DENIED (22)
75 # "jjf4wgmsbc0" is just a random string
76 AUTH_INFO_REQUIRED="jjf4wgmsbc0"
77 export AUTH_INFO_REQUIRED
81 unset AUTH_INFO_REQUIRED
88 echo "failed to test $smbspool_krb5 against unknown value of AUTH_INFO_REQUIRED"
95 # The test environment uses 'vlp' (virtual lp) as the printing backend.
97 # When using the vlp backend the print job is only written to the database.
98 # The job needs to removed manually using 'vlp lprm' command!
100 # This calls the 'vlp' command to check if the print job has been successfully
101 # added to the database and also makes sure the temporary print file has been
104 # The function removes the print job from the vlp database if successful.
108 tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb"
109 if [ ! -w $tdbfile ]; then
110 echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!"
114 cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
118 if [ $ret != 0 ]; then
119 echo "failed to get print queue with $samba_vlp"
123 jobid=$(echo "$out" | awk '/[0-9]+/ { print $1 };')
124 if [ -z "$jobid" ] || [ $jobid -lt 100 ] || [ $jobid -gt 2000 ]; then
125 echo "Invalid jobid: $jobid"
130 file=$(echo "$out" | awk '/[0-9]+/ { print $6 };')
131 if [ ! -r $PREFIX_ABS/$TARGET_ENV/share/$file ]; then
132 echo "$file doesn't exist"
137 $samba_vlp "tdbfile=$tdbfile" lprm print1 $jobid
139 if [ $ret != 0 ]; then
140 echo "Failed to remove jobid $jobid from $tdbfile"
145 test_delete_on_close()
147 tdbfile="$PREFIX_ABS/$TARGET_ENV/lockdir/vlp.tdb"
148 if [ ! -w $tdbfile ]; then
149 echo "vlp tdbfile $tdbfile doesn't exist or is not writeable!"
153 cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
157 if [ $ret != 0 ]; then
158 echo "failed to lpq jobs on print1 with $samba_vlp"
163 num_jobs=$(echo "$out" | wc -l)
165 # Now run the test DELETE-PRINT from smbtorture3
167 cmd='$samba_smbtorture3 //$SERVER_IP/print1 -U$USERNAME%$PASSWORD DELETE-PRINT 2>&1'
171 if [ $ret != 0 ]; then
172 echo "failed to run DELETE-PRINT on print1"
177 cmd='$samba_vlp tdbfile=$tdbfile lpq print1 2>&1'
181 if [ $ret != 0 ]; then
182 echo "(2) failed to lpq jobs on print1 with $samba_vlp"
186 num_jobs1=$(echo "$out1" | wc -l)
189 # Number of jobs should not change. Job
190 # should not have made it to backend.
192 if [ "$num_jobs1" -ne "$num_jobs" ]; then
193 echo "delete-on-close fail $num_jobs1 -ne $num_jobs"
203 testit "smbspool no args" \
204 test_smbspool_noargs $samba_smbspool ||
205 failed=$(expr $failed + 1)
207 testit "smbspool_krb5_wrapper no args" \
208 test_smbspool_noargs $samba_smbspool_krb5 ||
209 failed=$(expr $failed + 1)
211 testit "smbspool_krb5_wrapper AuthInfoRequired=none" \
212 test_smbspool_authinforequired_none ||
213 failed=$(expr $failed + 1)
215 testit "smbspool_krb5_wrapper AuthInfoRequired=(sth unknown)" \
216 test_smbspool_authinforequired_unknown ||
217 failed=$(expr $failed + 1)
219 testit "smbspool print example.ps" \
220 $samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
221 failed=$(expr $failed + 1)
223 testit "vlp verify example.ps" \
225 failed=$(expr $failed + 1)
227 testit "smbspool print example.ps via stdin" \
228 $samba_smbspool smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
229 failed=$(expr $failed + 1)
231 testit "vlp verify example.ps" \
233 failed=$(expr $failed + 1)
235 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
237 testit "smbspool print DEVICE_URI example.ps" \
238 $samba_smbspool 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
239 failed=$(expr $failed + 1)
242 testit "vlp verify example.ps" \
244 failed=$(expr $failed + 1)
246 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
248 testit "smbspool print DEVICE_URI example.ps via stdin" \
249 $samba_smbspool 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
250 failed=$(expr $failed + 1)
253 testit "vlp verify example.ps" \
255 failed=$(expr $failed + 1)
257 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
259 testit "smbspool print sanitized Device URI in argv0 example.ps" \
260 $samba_argv_wrapper $samba_smbspool smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
261 failed=$(expr $failed + 1)
264 testit "vlp verify example.ps" \
266 failed=$(expr $failed + 1)
268 DEVICE_URI="smb://$USERNAME:$PASSWORD@$SERVER_IP/print1"
270 testit "smbspool print sanitized Device URI in argv0 example.ps via stdin" \
271 $samba_argv_wrapper $samba_smbspool smb://$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" <$SRCDIR/testdata/printing/example.ps ||
272 failed=$(expr $failed + 1)
275 testit "vlp verify example.ps" \
277 failed=$(expr $failed + 1)
279 AUTH_INFO_REQUIRED="username,password"
280 export AUTH_INFO_REQUIRED
281 testit "smbspool_krb5(username,password) print example.ps" \
282 $samba_smbspool_krb5 smb://$USERNAME:$PASSWORD@$SERVER_IP/print1 200 $USERNAME "Testprint" 1 "options" $SRCDIR/testdata/printing/example.ps ||
283 failed=$(expr $failed + 1)
285 testit "vlp verify example.ps" \
287 failed=$(expr $failed + 1)
288 unset AUTH_INFO_REQUIRED
290 testit "delete on close" \
291 test_delete_on_close ||
292 failed=$(expr $failed + 1)