]> git.ipfire.org Git - thirdparty/cups.git/blob - everywhere/bonjour-tests.bat
Update software for stable draft of IPP Everywhere Printer Self-Certification
[thirdparty/cups.git] / everywhere / bonjour-tests.bat
1 @echo off
2 ::
3 :: "$Id$"
4 ::
5 :: IPP Everywhere Printer Self-Certification Manual 1.0: Section 5: Bonjour Tests.
6 ::
7 :: Copyright 2014-2015 by The Printer Working Group.
8 ::
9 :: This program may be copied and furnished to others, and derivative works
10 :: that comment on, or otherwise explain it or assist in its implementation may
11 :: be prepared, copied, published and distributed, in whole or in part, without
12 :: restriction of any kind, provided that the above copyright notice and this
13 :: paragraph are included on all such copies and derivative works.
14 ::
15 :: The IEEE-ISTO and the Printer Working Group DISCLAIM ANY AND ALL WARRANTIES,
16 :: WHETHER EXPRESS OR IMPLIED INCLUDING (WITHOUT LIMITATION) ANY IMPLIED
17 :: WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 ::
19 :: Usage:
20 ::
21 :: bonjour-tests.bat 'Printer Name'
22 ::
23
24 set PLIST=%1 Bonjour Results.plist
25 echo Sending output to "%PLIST%"...
26
27 :: Write the standard XML plist header...
28 echo ^<?xml version=^"1.0^" encoding=^"UTF-8^"?^> >"%PLIST%"
29 echo ^<!DOCTYPE plist PUBLIC ^"-//Apple Computer//DTD PLIST 1.0//EN^" ^"http://www.apple.com/DTDs/PropertyList-1.0.dtd^"^> >>"%PLIST%"
30 echo ^<plist version=^"1.0^"^> >>"%PLIST%"
31 echo ^<dict^> >>"%PLIST%"
32 echo ^<key^>Tests^</key^>^<array^> >>"%PLIST%"
33
34 set total=0
35 set pass=0
36 set fail=0
37 set skip=0
38
39 :: B-1. IPP Browse test: Printers appear in a search for "_ipp._tcp,_print" services?
40 set /a total+=1
41 set <NUL /p="B-1. IPP Browse test: "
42 echo ^<dict^>^<key^>Name^</key^>^<string^>B-1. IPP Browse test^</string^> >>"%PLIST%"
43 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20151009.bonjour^</string^> >>"%PLIST%"
44
45 set result=FAIL
46 ippfind _ipp._tcp,_print.local. --name "%1" --quiet && set result=PASS
47 if "%result%" == "PASS" (
48 set /a pass+=1
49 ) else (
50 set /a fail+=1
51 )
52
53 echo %result%
54 if "%result%" == "FAIL" (
55 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
56 ) else (
57 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
58 )
59 echo ^</dict^> >>"%PLIST%"
60
61 :: B-2. IPP TXT keys test: The IPP TXT record contains all required keys.
62 set /a total+=1
63 set <NUL /p="B-2. IPP TXT keys test: "
64 echo ^<dict^>^<key^>Name^</key^>^<string^>B-2. IPP TXT keys test^</string^> >>"%PLIST%"
65 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
66
67 set result=FAIL
68 ippfind "%1._ipp._tcp.local." --txt adminurl --txt pdl --txt rp --txt UUID --quiet && set result=PASS
69 if "%result%" == "PASS" (
70 set /a pass+=1
71 ) else (
72 set /a fail+=1
73 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
74 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
75 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
76 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
77 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
78 echo ^</string^>^</array^> >>"%PLIST%"
79 )
80
81 echo %result%
82 if "%result%" == "FAIL" (
83 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
84
85 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
86 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";"
87 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";"
88 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";"
89 ) else (
90 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
91 )
92 echo ^</dict^> >>"%PLIST%"
93
94 :: B-3. IPP Resolve test: Printer responds to an IPP Get-Printer-Attributes request using the resolved hostname, port, and resource path.
95 set /a total+=1
96 set <NUL /p="B-3. IPP Resolve test: "
97 echo ^<dict^>^<key^>Name^</key^>^<string^>B-3. IPP Resolve test^</string^> >>"%PLIST%"
98 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
99
100 set result=FAIL
101 (ippfind "%1._ipp._tcp.local." --ls && set result=PASS) >nul:
102 if "%result%" == "PASS" (
103 set /a pass+=1
104 ) else (
105 set /a fail+=1
106 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
107 ippfind "%1._ipp._tcp.local." --ls >>"%PLIST%"
108 echo ^</string^>^</array^> >>"%PLIST%"
109 )
110
111 echo %result%
112 if "%result%" == "FAIL" (
113 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
114 ) else (
115 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
116 )
117 echo ^</dict^> >>"%PLIST%"
118
119 :: B-4. IPP TXT values test: The IPP TXT record values match the reported IPP attribute values.
120 set /a total+=1
121 set <NUL /p="B-4. IPP TXT values test: "
122 echo ^<dict^>^<key^>Name^</key^>^<string^>B-4. IPP TXT values test^</string^> >>"%PLIST%"
123 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
124
125 set result=FAIL
126 ippfind "%1._ipp._tcp.local." --txt-adminurl ^^^(http:^|https:^)// --txt-pdl image/pwg-raster --txt-pdl image/jpeg --txt-rp ^^ipp/^(print^|print/[^^/]+^)$ --txt-UUID ^^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$ -x ipptool -q -d "ADMINURL={txt_adminurl}" -d "UUID={txt_uuid}" "{}" bonjour-value-tests.test ";" && set result=PASS
127 if "%result%" == "PASS" (
128 set /a pass+=1
129 ) else (
130 set /a fail+=1
131 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
132 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
133 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
134 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
135 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
136 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]: >>"%PLIST%"
137 echo ^</string^>^</array^> >>"%PLIST%"
138 )
139
140 echo %result%
141 if "%result%" == "FAIL" (
142 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
143
144 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
145 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";"
146 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";"
147 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";"
148 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]:
149 ) else (
150 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
151 )
152 echo ^</dict^> >>"%PLIST%"
153
154 :: B-5. TLS tests: Performed only if TLS is supported
155 set /a total+=1
156 set <NUL /p="B-5. TLS tests: "
157 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5. TLS tests^</string^> >>"%PLIST%"
158 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
159
160 set result=SKIP
161 ippfind "%1._ipp._tcp.local." --txt tls --quiet && set result=PASS
162 if "%result%" == "PASS" (
163 set /a pass+=1
164 set HAVE_TLS=1
165 ) else (
166 set /a skip+=1
167 set HAVE_TLS=0
168 )
169
170 echo %result%
171 if "%result%" == "SKIP" (
172 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
173 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
174 ) else (
175 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
176 )
177 echo ^</dict^> >>"%PLIST%"
178
179 :: B-5.1 HTTP Upgrade test: Printer responds to an IPP Get-Printer-Attributes request after doing an HTTP Upgrade to TLS.
180 set /a total+=1
181 set <NUL /p="B-5.1 HTTP Upgrade test: "
182 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.1 HTTP Upgrade test^</string^> >>"%PLIST%"
183 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
184
185 if "%HAVE_TLS%" == "1" (
186 set result=FAIL
187 ippfind "%1._ipp._tcp.local." -x ipptool -E -q "{}" bonjour-access-tests.test ";" && set result=PASS
188 if "%result%" == "PASS" (
189 set /a pass+=1
190 ) else (
191 set /a fail+=1
192 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST"
193 ippfind "%1._ipp._tcp.local." -x ipptool -E -q "{}" bonjour-access-tests.test ";" >>"%PLIST%"
194 echo ^</string^>^</array^> >>"%PLIST%"
195 )
196 ) else (
197 set /a skip+=1
198 set result=SKIP
199 )
200
201 echo %result%
202 if "%result%" == "FAIL" (
203 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
204 ) else (
205 if "%result%" == "SKIP" (
206 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
207 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
208 ) else (
209 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
210 )
211 )
212 echo ^</dict^> >>"%PLIST%"
213
214 :: B-5.2 IPPS Browse test: Printer appears in a search for "_ipps._tcp,_print" services.
215 set /a total+=1
216 set <NUL /p="B-5.2 IPPS Browse test: "
217 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.2 IPPS Browse test^</string^> >>"%PLIST%"
218 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
219
220 if "%HAVE_TLS%" == "1" (
221 set result=FAIL
222 ippfind _ipps._tcp,_print.local. --name "%1" --quiet && set result=PASS
223 if "%result%" == "PASS" (
224 set /a pass+=1
225 ) else (
226 set /a fail+=1
227 )
228 ) else (
229 set /a skip+=1
230 set result=SKIP
231 )
232
233 echo %result%
234 if "%result%" == "FAIL" (
235 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
236 ) else (
237 if "%result%" == "SKIP" (
238 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
239 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
240 ) else (
241 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
242 )
243 )
244 echo ^</dict^> >>"%PLIST%"
245
246 :: B-5.3 IPPS TXT keys test: The TXT record for IPPS contains all required keys
247 set /a total+=1
248 set <NUL /p="B-5.3 IPPS TXT keys test: "
249 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.3 IPPS TXT keys test^</string^> >>"%PLIST%"
250 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
251
252 if "%HAVE_TLS%" == "1" (
253 set result=FAIL
254 ippfind "%1._ipps._tcp.local." --txt adminurl --txt pdl --txt rp --txt TLS --txt UUID --quiet && set result=PASS
255 if "%result%" == "PASS" (
256 set /a pass+=1
257 ) else (
258 set /a fail+=1
259 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
260 ippfind "%1._ipps._tcp.local." -x echo adminurl={txt_adminurl}" ";" >>"%PLIST%"
261 ippfind "%1._ipps._tcp.local." -x echo pdl={txt_pdl}" ";" >>"%PLIST%"
262 ippfind "%1._ipps._tcp.local." -x echo rp={txt_rp}" ";" >>"%PLIST%"
263 ippfind "%1._ipps._tcp.local." -x echo TLS={txt_tls}" ";" >>"%PLIST%"
264 ippfind "%1._ipps._tcp.local." -x echo UUID={txt_uuid}" ";" >>"%PLIST%"
265 echo ^</string^>^</array^> >>"%PLIST%"
266 )
267 ) else (
268 set /a skip+=1
269 set result=SKIP
270 )
271
272 echo %result%
273 if "%result%" == "FAIL" (
274 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
275
276 ippfind "%1._ipps._tcp.local." -x echo adminurl={txt_adminurl}" ";"
277 ippfind "%1._ipps._tcp.local." -x echo pdl={txt_pdl}" ";"
278 ippfind "%1._ipps._tcp.local." -x echo rp={txt_rp}" ";"
279 ippfind "%1._ipps._tcp.local." -x echo TLS={txt_tls}" ";"
280 ippfind "%1._ipps._tcp.local." -x echo UUID={txt_uuid}" ";"
281 ) else (
282 if "%result%" == "SKIP" (
283 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
284 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
285 ) else (
286 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
287 )
288 )
289 echo ^</dict^> >>"%PLIST%"
290
291 :: B-5.4 IPPS Resolve test: Printer responds to an IPPS Get-Printer-Attributes request using the resolved hostname, port, and resource path.
292 set /a total+=1
293 set <NUL /p="B-5.4 IPPS Resolve test: "
294 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.4 IPPS Resolve test^</string^> >>"%PLIST%"
295 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
296
297 if "%HAVE_TLS%" == "1" (
298 set result=FAIL
299 (ippfind "%1._ipps._tcp.local." --ls && set result=PASS) >nul:
300 if "%result%" == "PASS" (
301 set /a pass+=1
302 ) else (
303 set /a fail+=1
304 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
305 ippfind "%1._ipps._tcp.local." --ls >>"%PLIST%"
306 echo ^</string^>^</array^> >>"%PLIST%"
307 )
308 ) else (
309 set /a skip+=1
310 set result=SKIP
311 )
312
313 echo %result%
314 if "%result%" == "FAIL" (
315 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
316 ) else (
317 if "%result%" == "SKIP" (
318 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
319 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
320 ) else (
321 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
322 )
323 )
324 echo ^</dict^> >>"%PLIST%"
325
326 :: B-5.5 IPPS TXT values test: The TXT record values for IPPS match the reported IPPS attribute values.
327 set /a total+=1
328 set <NUL /p="B-5.5 IPPS TXT values test: "
329 echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.5 IPPS TXT values test^</string^> >>"%PLIST%"
330 echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
331
332 if "%HAVE_TLS%" == "1" (
333 set result=FAIL
334 ippfind "%1._ipps._tcp.local." --txt-adminurl ^^^(http:^|https:^)// --txt-pdl image/pwg-raster --txt-pdl image/jpeg --txt-rp ^^ipp/^(print^|print/[^^/]+^)$ --txt-UUID ^^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$ -x ipptool -q "{}" bonjour-value-tests.test ";" && set result=PASS
335 if "%result%" == "PASS" (
336 set /a pass+=1
337 ) else (
338 set /a fail+=1
339 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
340 ippfind "%1._ipps._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
341 ippfind "%1._ipps._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
342 ippfind "%1._ipps._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
343 ippfind "%1._ipps._tcp.local." -x echo TLS="{txt_tls}" ";" >>"%PLIST%"
344 ippfind "%1._ipps._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
345 ippfind "%1._ipps._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]: >>"%PLIST"
346 echo ^</string^>^</array^> >>"%PLIST%"
347 )
348 ) else (
349 set /a skip+=1
350 set result=SKIP
351 )
352
353 echo %result%
354 if "%result%" == "FAIL" (
355 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
356
357 ippfind "%1._ipps._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
358 ippfind "%1._ipps._tcp.local." -x echo pdl="{txt_pdl}" ";"
359 ippfind "%1._ipps._tcp.local." -x echo rp="{txt_rp}" ";"
360 ippfind "%1._ipps._tcp.local." -x echo TLS="{txt_tls}" ";"
361 ippfind "%1._ipps._tcp.local." -x echo UUID="{txt_uuid}" ";"
362 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]:
363 ) else (
364 if "%result%" == "SKIP" (
365 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
366 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
367 ) else (
368 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
369 )
370 )
371 echo ^</dict^> >>"%PLIST%"
372
373 :: Finish up...
374 echo ^</array^> >>"%PLIST%"
375 echo ^<key^>Successful^</key^> >>"%PLIST%"
376 if %fail% gtr 0 (
377 echo ^<false /^> >>"%PLIST%"
378 ) else (
379 echo ^<true /^> >>"%PLIST%"
380 )
381 echo ^</dict^> >>"%PLIST%"
382 echo ^</plist^> >>"%PLIST%"
383
384 set /a score=%pass% + %skip%
385 set /a score=100 * %score% / %total%
386 echo Summary: %total% tests, %pass% passed, %fail% failed, %skip% skipped
387 echo Score: %score%%%
388
389 ::
390 :: End of "$Id$".
391 ::