Merge branch 'master' of ssh://git.samba.org/data/git/samba into wspp-schema
[ira/wip.git] / source4 / torture / rpc / spoolss_win.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for spoolss rpc operations as performed by various win versions
4
5    Copyright (C) Kai Blin 2007
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "torture/torture.h"
23 #include "torture/rpc/rpc.h"
24 #include "librpc/gen_ndr/ndr_spoolss_c.h"
25 #include "rpc_server/dcerpc_server.h"
26 #include "ntvfs/ntvfs.h"
27 #include "param/param.h"
28
29 struct test_spoolss_win_context {
30         /* EnumPrinters */
31         uint32_t printer_count;
32         union spoolss_PrinterInfo *printer_info;
33         union spoolss_PrinterInfo *current_info;
34
35         /* EnumPrinterKeys */
36         char *printer_keys;
37 };
38
39 /* This is a convenience function for all OpenPrinterEx calls */
40 static bool test_OpenPrinterEx(struct torture_context *tctx,
41                                 struct dcerpc_pipe *p,
42                                 struct policy_handle *handle,
43                                 const char *printer_name,
44                                 uint32_t access_mask)
45 {
46         NTSTATUS status;
47         struct spoolss_OpenPrinterEx op;
48         struct spoolss_UserLevel1 ul_1;
49
50         torture_comment(tctx, "Opening printer '%s'\n", printer_name);
51
52         op.in.printername               = talloc_strdup(tctx, printer_name);
53         op.in.datatype                  = NULL;
54         op.in.devmode_ctr.devmode       = NULL;
55         op.in.access_mask               = access_mask;
56         op.in.level                     = 1;
57         op.in.userlevel.level1          = &ul_1;
58         op.out.handle                   = handle;
59
60         ul_1.size                       = 1234;
61         ul_1.client                     = "\\clientname";
62         ul_1.user                       = "username";
63         ul_1.build                      = 1;
64         ul_1.major                      = 2;
65         ul_1.minor                      = 3;
66         ul_1.processor                  = 4567;
67
68         status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &op);
69         torture_assert_ntstatus_ok(tctx, status, "OpenPrinterEx failed");
70         torture_assert_werr_ok(tctx, op.out.result, "OpenPrinterEx failed");
71
72         return true;
73 }
74
75 static bool test_OpenPrinterAsAdmin(struct torture_context *tctx,
76                                         struct dcerpc_pipe *p,
77                                         const char *printername)
78 {
79         NTSTATUS status;
80         struct spoolss_OpenPrinterEx op;
81         struct spoolss_ClosePrinter cp;
82         struct spoolss_UserLevel1 ul_1;
83         struct policy_handle handle;
84
85         ul_1.size                       = 1234;
86         ul_1.client                     = "\\clientname";
87         ul_1.user                       = "username";
88         ul_1.build                      = 1;
89         ul_1.major                      = 2;
90         ul_1.minor                      = 3;
91         ul_1.processor                  = 4567;
92
93         op.in.printername               = talloc_strdup(tctx, printername);
94         op.in.datatype                  = NULL;
95         op.in.devmode_ctr.devmode       = NULL;
96         op.in.access_mask               = SERVER_ALL_ACCESS;
97         op.in.level                     = 1;
98         op.in.userlevel.level1          = &ul_1;
99         op.out.handle                   = &handle;
100
101         cp.in.handle                    = &handle;
102         cp.out.handle                   = &handle;
103
104         torture_comment(tctx, "Testing OpenPrinterEx(%s) with admin rights\n",
105                         op.in.printername);
106
107         status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &op);
108
109         if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(op.out.result)) {
110                 status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
111                 torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
112         }
113
114         return true;
115 }
116
117
118 static bool test_ClosePrinter(struct torture_context *tctx,
119                                 struct dcerpc_pipe *p,
120                                 struct policy_handle *handle);
121
122 /* This replicates the opening sequence of OpenPrinterEx calls XP does */
123 static bool test_OpenPrinterSequence(struct torture_context *tctx,
124                                         struct dcerpc_pipe *p,
125                                         struct policy_handle *handle)
126 {
127         bool ret;
128         char *printername = talloc_asprintf(tctx, "\\\\%s",
129                         dcerpc_server_name(p));
130
131         /* First, see if we can open the printer read_only */
132         ret = test_OpenPrinterEx(tctx, p, handle, printername, 0);
133         torture_assert(tctx, ret == true, "OpenPrinterEx failed.");
134
135         ret = test_ClosePrinter(tctx, p, handle);
136         torture_assert(tctx, ret, "ClosePrinter failed");
137
138         /* Now let's see if we have admin rights to it. */
139         ret = test_OpenPrinterAsAdmin(tctx, p, printername);
140         torture_assert(tctx, ret == true,
141                         "OpenPrinterEx as admin failed unexpectedly.");
142
143         ret = test_OpenPrinterEx(tctx, p, handle, printername, SERVER_EXECUTE);
144         torture_assert(tctx, ret == true, "OpenPrinterEx failed.");
145
146         return true;
147 }
148
149 static bool test_GetPrinterData(struct torture_context *tctx,
150                                 struct dcerpc_pipe *p,
151                                 struct policy_handle *handle,
152                                 const char *value_name,
153                                 WERROR expected_werr,
154                                 uint32_t expected_value)
155 {
156         NTSTATUS status;
157         struct spoolss_GetPrinterData gpd;
158         uint32_t needed;
159         enum spoolss_PrinterDataType type;
160
161         torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name);
162         gpd.in.handle = handle;
163         gpd.in.value_name = value_name;
164         gpd.in.offered = 4;
165         gpd.out.needed = &needed;
166         gpd.out.type = &type;
167
168         status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd);
169         torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed.");
170         torture_assert_werr_equal(tctx, gpd.out.result, expected_werr,
171                         "GetPrinterData did not return expected error value.");
172
173         if (W_ERROR_IS_OK(expected_werr)) {
174                 torture_assert_int_equal(tctx, gpd.out.data.value,
175                         expected_value,
176                         "GetPrinterData did not return expected value.");
177         }
178         return true;
179 }
180
181 static bool test_EnumPrinters(struct torture_context *tctx,
182                                 struct dcerpc_pipe *p,
183                                 struct test_spoolss_win_context *ctx,
184                                 uint32_t initial_blob_size)
185 {
186         NTSTATUS status;
187         struct spoolss_EnumPrinters ep;
188         DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
189         uint32_t needed;
190         uint32_t count;
191         union spoolss_PrinterInfo *info;
192
193         ep.in.flags = PRINTER_ENUM_NAME;
194         ep.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
195         ep.in.level = 2;
196         ep.in.buffer = &blob;
197         ep.in.offered = initial_blob_size;
198         ep.out.needed = &needed;
199         ep.out.count = &count;
200         ep.out.info = &info;
201
202         status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
203         torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed.");
204
205         if (W_ERROR_EQUAL(ep.out.result, WERR_INSUFFICIENT_BUFFER)) {
206                 blob = data_blob_talloc_zero(ctx, needed);
207                 ep.in.buffer = &blob;
208                 ep.in.offered = needed;
209                 status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
210                 torture_assert_ntstatus_ok(tctx, status,"EnumPrinters failed.");
211         }
212
213         torture_assert_werr_ok(tctx, ep.out.result, "EnumPrinters failed.");
214
215         ctx->printer_count = count;
216         ctx->printer_info = info;
217
218         torture_comment(tctx, "Found %d printer(s).\n", ctx->printer_count);
219
220         return true;
221 }
222
223 static bool test_GetPrinter(struct torture_context *tctx,
224                                 struct dcerpc_pipe *p,
225                                 struct policy_handle *handle,
226                                 struct test_spoolss_win_context *ctx,
227                                 uint32_t level,
228                                 uint32_t initial_blob_size)
229 {
230         NTSTATUS status;
231         struct spoolss_GetPrinter gp;
232         DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
233         uint32_t needed;
234
235         torture_comment(tctx, "Test GetPrinter level %d\n", level);
236
237         gp.in.handle = handle;
238         gp.in.level = level;
239         gp.in.buffer = (initial_blob_size == 0)?NULL:&blob;
240         gp.in.offered = initial_blob_size;
241         gp.out.needed = &needed;
242
243         status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
244         torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
245
246         if (W_ERROR_EQUAL(gp.out.result, WERR_INSUFFICIENT_BUFFER)) {
247                 blob = data_blob_talloc_zero(ctx, needed);
248                 gp.in.buffer = &blob;
249                 gp.in.offered = needed;
250                 status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
251                 torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
252         }
253
254         torture_assert_werr_ok(tctx, gp.out.result, "GetPrinter failed");
255
256         ctx->current_info = gp.out.info;
257         return true;
258 }
259
260 static bool test_EnumJobs(struct torture_context *tctx,
261                                 struct dcerpc_pipe *p,
262                                 struct policy_handle *handle)
263 {
264         NTSTATUS status;
265         struct spoolss_EnumJobs ej;
266         DATA_BLOB blob = data_blob_talloc_zero(tctx, 1024);
267         uint32_t needed;
268         uint32_t count;
269         union spoolss_JobInfo *info;
270
271         torture_comment(tctx, "Test EnumJobs\n");
272
273         ej.in.handle = handle;
274         ej.in.level = 2;
275         ej.in.buffer = &blob;
276         ej.in.offered = 1024;
277         ej.out.needed = &needed;
278         ej.out.count = &count;
279         ej.out.info = &info;
280
281         status = dcerpc_spoolss_EnumJobs(p, tctx, &ej);
282         torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
283         torture_assert_werr_ok(tctx, ej.out.result, "EnumJobs failed");
284
285         return true;
286 }
287
288 static bool test_GetPrinterDriver2(struct torture_context *tctx,
289                                         struct dcerpc_pipe *p,
290                                         struct policy_handle *handle)
291 {
292         NTSTATUS status;
293         struct spoolss_GetPrinterDriver2 gpd2;
294         DATA_BLOB blob = data_blob_talloc_zero(tctx, 87424);
295         uint32_t needed;
296         uint32_t server_major_version;
297         uint32_t server_minor_version;
298
299         torture_comment(tctx, "Testing GetPrinterDriver2\n");
300
301         gpd2.in.handle = handle;
302         gpd2.in.architecture = "Windows NT x86";
303         gpd2.in.level = 101;
304         gpd2.in.buffer = &blob;
305         gpd2.in.offered = 87424;
306         gpd2.in.client_major_version = 3;
307         gpd2.in.client_minor_version = 0;
308         gpd2.out.needed = &needed;
309         gpd2.out.server_major_version = &server_major_version;
310         gpd2.out.server_minor_version = &server_minor_version;
311
312         status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &gpd2);
313         torture_assert_ntstatus_ok(tctx, status, "GetPrinterDriver2 failed");
314         torture_assert_werr_ok(tctx, gpd2.out.result,
315                         "GetPrinterDriver2 failed.");
316
317         return true;
318 }
319
320 static bool test_EnumForms(struct torture_context *tctx,
321                                 struct dcerpc_pipe *p,
322                                 struct policy_handle *handle,
323                                 uint32_t initial_blob_size)
324 {
325         NTSTATUS status;
326         struct spoolss_EnumForms ef;
327         DATA_BLOB blob = data_blob_talloc_zero(tctx, initial_blob_size);
328         uint32_t needed;
329         uint32_t count;
330         union spoolss_FormInfo *info;
331
332         torture_comment(tctx, "Testing EnumForms\n");
333
334         ef.in.handle = handle;
335         ef.in.level = 1;
336         ef.in.buffer = (initial_blob_size == 0)?NULL:&blob;
337         ef.in.offered = initial_blob_size;
338         ef.out.needed = &needed;
339         ef.out.count = &count;
340         ef.out.info = &info;
341
342         status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
343         torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
344
345         if (W_ERROR_EQUAL(ef.out.result, WERR_INSUFFICIENT_BUFFER)) {
346                 blob = data_blob_talloc_zero(tctx, needed);
347                 ef.in.buffer = &blob;
348                 ef.in.offered = needed;
349                 status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
350                 torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
351         }
352
353         torture_assert_werr_ok(tctx, ef.out.result, "EnumForms failed");
354
355         return true;
356 }
357
358 static bool test_EnumPrinterKey(struct torture_context *tctx,
359                                 struct dcerpc_pipe *p,
360                                 struct policy_handle *handle,
361                                 const char* key,
362                                 struct test_spoolss_win_context *ctx)
363 {
364         NTSTATUS status;
365         struct spoolss_EnumPrinterKey epk;
366         uint32_t needed = 0;
367
368         torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
369
370         epk.in.handle = handle;
371         epk.in.key_name = talloc_strdup(tctx, key);
372         epk.in.key_buffer_size = 0;
373         epk.out.needed = &needed;
374         epk.out.key_buffer = talloc_array(tctx, uint16_t, 0);
375
376         status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
377         torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
378
379
380         if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
381                 epk.in.key_buffer_size = needed;
382                 epk.out.key_buffer = talloc_array(tctx, uint16_t, needed/2);
383                 status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
384                 torture_assert_ntstatus_ok(tctx, status,
385                                 "EnumPrinterKey failed");
386         }
387
388         torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
389
390         convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16,
391                         CH_UNIX, epk.out.key_buffer, *epk.out.needed,
392                         (void**)&ctx->printer_keys, NULL, false);
393
394         return true;
395 }
396
397 static bool test_EnumPrinterDataEx(struct torture_context *tctx,
398                                         struct dcerpc_pipe *p,
399                                         struct policy_handle *handle,
400                                         const char *key,
401                                         uint32_t initial_blob_size,
402                                         WERROR expected_error)
403 {
404         NTSTATUS status;
405         struct spoolss_EnumPrinterDataEx epde;
406         uint32_t needed;
407         uint32_t count;
408
409         torture_comment(tctx, "Testing EnumPrinterDataEx(%s)\n", key);
410
411         epde.in.handle = handle;
412         epde.in.key_name = talloc_strdup(tctx, key);
413         epde.in.offered = 0;
414         epde.out.needed = &needed;
415         epde.out.count = &count;
416         epde.out.buffer = talloc_array(tctx, uint8_t, 0);
417
418         status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
419         torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed.");
420         if (W_ERROR_EQUAL(epde.out.result, WERR_MORE_DATA)) {
421                 epde.in.offered = needed;
422                 epde.out.buffer = talloc_array(tctx, uint8_t, needed);
423                 status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
424                 torture_assert_ntstatus_ok(tctx, status,
425                                 "EnumPrinterDataEx failed.");
426         }
427
428         torture_assert_werr_equal(tctx, epde.out.result, expected_error,
429                         "EnumPrinterDataEx failed.");
430
431         return true;
432 }
433
434 static bool test_ClosePrinter(struct torture_context *tctx,
435                                 struct dcerpc_pipe *p,
436                                 struct policy_handle *handle)
437 {
438         NTSTATUS status;
439         struct spoolss_ClosePrinter cp;
440
441         cp.in.handle  = handle;
442         cp.out.handle = handle;
443
444         status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
445         torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
446
447         return true;
448 }
449
450 static bool test_WinXP(struct torture_context *tctx, struct dcerpc_pipe *p)
451 {
452         bool ret = true;
453         struct test_spoolss_win_context *ctx, *tmp_ctx;
454         struct policy_handle handle01, handle02, handle03, handle04;
455         /* Sometimes a handle stays unused. In order to make this clear in the
456          * code, the unused_handle structures are used for that. */
457         struct policy_handle unused_handle1, unused_handle2;
458         char *server_name;
459         char *key_pointer;
460
461         ntvfs_init(tctx->lp_ctx);
462
463         ctx = talloc_zero(tctx, struct test_spoolss_win_context);
464         tmp_ctx = talloc_zero(tctx, struct test_spoolss_win_context);
465
466         ret &= test_OpenPrinterSequence(tctx, p, &handle01);
467         ret &= test_GetPrinterData(tctx, p, &handle01,"UISingleJobStatusString",
468                         WERR_INVALID_PARAM, 0);
469         torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");
470
471         server_name = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p));
472         ret &= test_OpenPrinterEx(tctx, p, &unused_handle1, server_name, 0);
473
474         ret &= test_EnumPrinters(tctx, p, ctx, 1024);
475
476         ret &= test_OpenPrinterEx(tctx, p, &handle02, server_name, 0);
477         ret &= test_GetPrinterData(tctx, p, &handle02, "MajorVersion", WERR_OK,
478                         3);
479         ret &= test_ClosePrinter(tctx, p, &handle02);
480
481         /* If no printers were found, skip all tests that need a printer */
482         if (ctx->printer_count == 0) {
483                 goto end_testWinXP;
484         }
485
486         ret &= test_OpenPrinterEx(tctx, p, &handle02,
487                         ctx->printer_info[0].info2.printername,
488                         PRINTER_ACCESS_USE);
489         ret &= test_GetPrinter(tctx, p, &handle02, ctx, 2, 0);
490
491         torture_assert_str_equal(tctx, ctx->current_info->info2.printername,
492                         ctx->printer_info[0].info2.printername,
493                         "GetPrinter returned unexpected printername");
494         /*FIXME: Test more components of the PrinterInfo2 struct */
495
496         ret &= test_OpenPrinterEx(tctx, p, &handle03,
497                         ctx->printer_info[0].info2.printername, 0);
498         ret &= test_GetPrinter(tctx, p, &handle03, ctx, 0, 1164);
499         ret &= test_GetPrinter(tctx, p, &handle03, ctx, 2, 0);
500
501         ret &= test_OpenPrinterEx(tctx, p, &handle04,
502                         ctx->printer_info[0].info2.printername, 0);
503         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 0);
504         ret &= test_ClosePrinter(tctx, p, &handle04);
505
506         ret &= test_OpenPrinterEx(tctx, p, &handle04,
507                         ctx->printer_info[0].info2.printername, 0);
508         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 4096);
509         ret &= test_ClosePrinter(tctx, p, &handle04);
510
511         ret &= test_OpenPrinterAsAdmin(tctx, p,
512                         ctx->printer_info[0].info2.printername);
513
514         ret &= test_OpenPrinterEx(tctx, p, &handle04,
515                         ctx->printer_info[0].info2.printername, PRINTER_READ);
516         ret &= test_GetPrinterData(tctx, p, &handle04,"UISingleJobStatusString",
517                         WERR_BADFILE, 0);
518         torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");
519
520         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
521                         ctx->printer_info[0].info2.printername, 0);
522
523         ret &= test_EnumJobs(tctx, p, &handle04);
524         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 4096);
525
526         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
527         ret &= test_ClosePrinter(tctx, p, &handle04);
528
529         ret &= test_EnumPrinters(tctx, p, ctx, 1556);
530         ret &= test_GetPrinterDriver2(tctx, p, &handle03);
531         ret &= test_EnumForms(tctx, p, &handle03, 0);
532
533         ret &= test_EnumPrinterKey(tctx, p, &handle03, "", ctx);
534         key_pointer = ctx->printer_keys;
535         while(*key_pointer != '\0') {
536                 char *end_pointer;
537                 char *key_name;
538
539                 for(end_pointer = key_pointer; *end_pointer != '\0';
540                                 ++end_pointer) {
541                         /* Do nothing, just move the pointer */
542                 }
543                 key_name = talloc_strndup(tctx, key_pointer,
544                                 end_pointer - key_pointer);
545
546                 ret &= test_EnumPrinterKey(tctx, p, &handle03, key_name,
547                                 tmp_ctx);
548                 ret &= test_EnumPrinterDataEx(tctx, p, &handle03, key_name, 0,
549                                 WERR_OK);
550
551                 key_pointer = ++end_pointer;
552         }
553
554         ret &= test_EnumPrinterDataEx(tctx, p, &handle03, "", 0,
555                         WERR_INVALID_PARAM);
556
557         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 2, 0);
558
559         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
560                         ctx->printer_info[0].info2.printername, 0);
561         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
562
563         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 2, 2556);
564
565         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
566                         ctx->printer_info[0].info2.printername, 0);
567         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
568
569         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
570                         ctx->printer_info[0].info2.printername, 0);
571         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
572
573         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 7, 0);
574
575         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
576                         ctx->printer_info[0].info2.printername, 0);
577         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
578
579         ret &= test_ClosePrinter(tctx, p, &handle03);
580
581         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
582                         ctx->printer_info[0].info2.printername, 0);
583         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
584
585         ret &= test_OpenPrinterEx(tctx, p, &handle03, server_name, 0);
586         ret &= test_GetPrinterData(tctx, p, &handle03, "W3SvcInstalled",
587                         WERR_OK, 0);
588         ret &= test_ClosePrinter(tctx, p, &handle03);
589
590         ret &= test_ClosePrinter(tctx, p, &unused_handle1);
591         ret &= test_ClosePrinter(tctx, p, &handle02);
592
593         ret &= test_OpenPrinterEx(tctx, p, &handle02,
594                         ctx->printer_info[0].info2.sharename, 0);
595         ret &= test_GetPrinter(tctx, p, &handle02, tmp_ctx, 2, 0);
596         ret &= test_ClosePrinter(tctx, p, &handle02);
597
598 end_testWinXP:
599         ret &= test_ClosePrinter(tctx, p, &handle01);
600
601         talloc_free(tmp_ctx);
602         talloc_free(ctx);
603         return ret;
604 }
605
606 struct torture_suite *torture_rpc_spoolss_win(TALLOC_CTX *mem_ctx)
607 {
608         struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-WIN");
609
610         struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, 
611                                                         "win", &ndr_table_spoolss);
612
613         torture_rpc_tcase_add_test(tcase, "testWinXP", test_WinXP);
614
615         return suite;
616 }
617