cddba3d38cc3fedaccdde8fba19fb155c75289bd
[kai/samba-autobuild/.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
160         torture_comment(tctx, "Testing GetPrinterData(%s).\n", value_name);
161         gpd.in.handle = handle;
162         gpd.in.value_name = value_name;
163         gpd.in.offered = 4;
164         gpd.out.needed = &needed;
165
166         status = dcerpc_spoolss_GetPrinterData(p, tctx, &gpd);
167         torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed.");
168         torture_assert_werr_equal(tctx, gpd.out.result, expected_werr,
169                         "GetPrinterData did not return expected error value.");
170
171         if (W_ERROR_IS_OK(expected_werr)) {
172                 torture_assert_int_equal(tctx, gpd.out.data.value,
173                         expected_value,
174                         "GetPrinterData did not return expected value.");
175         }
176         return true;
177 }
178
179 static bool test_EnumPrinters(struct torture_context *tctx,
180                                 struct dcerpc_pipe *p,
181                                 struct test_spoolss_win_context *ctx,
182                                 uint32_t initial_blob_size)
183 {
184         NTSTATUS status;
185         struct spoolss_EnumPrinters ep;
186         DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
187         uint32_t needed;
188
189         ep.in.flags = PRINTER_ENUM_NAME;
190         ep.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
191         ep.in.level = 2;
192         ep.in.buffer = &blob;
193         ep.in.offered = initial_blob_size;
194         ep.out.needed = &needed;
195
196         status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
197         torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed.");
198
199         if (W_ERROR_EQUAL(ep.out.result, WERR_INSUFFICIENT_BUFFER)) {
200                 blob = data_blob_talloc_zero(ctx, needed);
201                 ep.in.buffer = &blob;
202                 ep.in.offered = needed;
203                 status = dcerpc_spoolss_EnumPrinters(p, ctx, &ep);
204                 torture_assert_ntstatus_ok(tctx, status,"EnumPrinters failed.");
205         }
206
207         torture_assert_werr_ok(tctx, ep.out.result, "EnumPrinters failed.");
208
209         ctx->printer_count = ep.out.count;
210         ctx->printer_info = ep.out.info;
211
212         torture_comment(tctx, "Found %d printer(s).\n", ctx->printer_count);
213
214         return true;
215 }
216
217 static bool test_GetPrinter(struct torture_context *tctx,
218                                 struct dcerpc_pipe *p,
219                                 struct policy_handle *handle,
220                                 struct test_spoolss_win_context *ctx,
221                                 uint32_t level,
222                                 uint32_t initial_blob_size)
223 {
224         NTSTATUS status;
225         struct spoolss_GetPrinter gp;
226         DATA_BLOB blob = data_blob_talloc_zero(ctx, initial_blob_size);
227         uint32_t needed;
228
229         torture_comment(tctx, "Test GetPrinter level %d\n", level);
230
231         gp.in.handle = handle;
232         gp.in.level = level;
233         gp.in.buffer = (initial_blob_size == 0)?NULL:&blob;
234         gp.in.offered = initial_blob_size;
235         gp.out.needed = &needed;
236
237         status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
238         torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
239
240         if (W_ERROR_EQUAL(gp.out.result, WERR_INSUFFICIENT_BUFFER)) {
241                 blob = data_blob_talloc_zero(ctx, needed);
242                 gp.in.buffer = &blob;
243                 gp.in.offered = needed;
244                 status = dcerpc_spoolss_GetPrinter(p, tctx, &gp);
245                 torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed");
246         }
247
248         torture_assert_werr_ok(tctx, gp.out.result, "GetPrinter failed");
249
250         ctx->current_info = gp.out.info;
251         return true;
252 }
253
254 static bool test_EnumJobs(struct torture_context *tctx,
255                                 struct dcerpc_pipe *p,
256                                 struct policy_handle *handle)
257 {
258         NTSTATUS status;
259         struct spoolss_EnumJobs ej;
260         DATA_BLOB blob = data_blob_talloc_zero(tctx, 1024);
261
262         torture_comment(tctx, "Test EnumJobs\n");
263
264         ej.in.handle = handle;
265         ej.in.level = 2;
266         ej.in.buffer = &blob;
267         ej.in.offered = 1024;
268
269         status = dcerpc_spoolss_EnumJobs(p, tctx, &ej);
270         torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed");
271         torture_assert_werr_ok(tctx, ej.out.result, "EnumJobs failed");
272
273         return true;
274 }
275
276 static bool test_GetPrinterDriver2(struct torture_context *tctx,
277                                         struct dcerpc_pipe *p,
278                                         struct policy_handle *handle)
279 {
280         NTSTATUS status;
281         struct spoolss_GetPrinterDriver2 gpd2;
282         DATA_BLOB blob = data_blob_talloc_zero(tctx, 87424);
283         uint32_t needed;
284         uint32_t server_major_version;
285         uint32_t server_minor_version;
286
287         torture_comment(tctx, "Testing GetPrinterDriver2\n");
288
289         gpd2.in.handle = handle;
290         gpd2.in.architecture = "Windows NT x86";
291         gpd2.in.level = 101;
292         gpd2.in.buffer = &blob;
293         gpd2.in.offered = 87424;
294         gpd2.in.client_major_version = 3;
295         gpd2.in.client_minor_version = 0;
296         gpd2.out.needed = &needed;
297         gpd2.out.server_major_version = &server_major_version;
298         gpd2.out.server_minor_version = &server_minor_version;
299
300         status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &gpd2);
301         torture_assert_ntstatus_ok(tctx, status, "GetPrinterDriver2 failed");
302         torture_assert_werr_ok(tctx, gpd2.out.result,
303                         "GetPrinterDriver2 failed.");
304
305         return true;
306 }
307
308 static bool test_EnumForms(struct torture_context *tctx,
309                                 struct dcerpc_pipe *p,
310                                 struct policy_handle *handle,
311                                 uint32_t initial_blob_size)
312 {
313         NTSTATUS status;
314         struct spoolss_EnumForms ef;
315         DATA_BLOB blob = data_blob_talloc_zero(tctx, initial_blob_size);
316         uint32_t needed;
317
318         torture_comment(tctx, "Testing EnumForms\n");
319
320         ef.in.handle = handle;
321         ef.in.level = 1;
322         ef.in.buffer = (initial_blob_size == 0)?NULL:&blob;
323         ef.in.offered = initial_blob_size;
324         ef.out.needed = &needed;
325
326         status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
327         torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
328
329         if (W_ERROR_EQUAL(ef.out.result, WERR_INSUFFICIENT_BUFFER)) {
330                 blob = data_blob_talloc_zero(tctx, needed);
331                 ef.in.buffer = &blob;
332                 ef.in.offered = needed;
333                 status = dcerpc_spoolss_EnumForms(p, tctx, &ef);
334                 torture_assert_ntstatus_ok(tctx, status, "EnumForms failed");
335         }
336
337         torture_assert_werr_ok(tctx, ef.out.result, "EnumForms failed");
338
339         return true;
340 }
341
342 static bool test_EnumPrinterKey(struct torture_context *tctx,
343                                 struct dcerpc_pipe *p,
344                                 struct policy_handle *handle,
345                                 const char* key,
346                                 struct test_spoolss_win_context *ctx)
347 {
348         NTSTATUS status;
349         struct spoolss_EnumPrinterKey epk;
350         uint32_t needed = 0;
351
352         torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
353
354         epk.in.handle = handle;
355         epk.in.key_name = talloc_strdup(tctx, key);
356         epk.in.key_buffer_size = 0;
357         epk.out.needed = &needed;
358
359         status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
360         torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
361
362
363         if (W_ERROR_EQUAL(epk.out.result, WERR_MORE_DATA)) {
364                 epk.in.key_buffer_size = needed;
365                 epk.out.key_buffer = talloc_array(tctx, uint16_t, needed/2);
366                 status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
367                 torture_assert_ntstatus_ok(tctx, status,
368                                 "EnumPrinterKey failed");
369         }
370
371         torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
372
373         convert_string_talloc_convenience(ctx, lp_iconv_convenience(tctx->lp_ctx), CH_UTF16,
374                         CH_UNIX, epk.out.key_buffer, *epk.out.needed,
375                         (void**)&ctx->printer_keys);
376
377         return true;
378 }
379
380 static bool test_EnumPrinterDataEx(struct torture_context *tctx,
381                                         struct dcerpc_pipe *p,
382                                         struct policy_handle *handle,
383                                         const char *key,
384                                         uint32_t initial_blob_size,
385                                         WERROR expected_error)
386 {
387         NTSTATUS status;
388         struct spoolss_EnumPrinterDataEx epde;
389         uint32_t needed;
390         uint32_t count;
391
392         torture_comment(tctx, "Testing EnumPrinterDataEx(%s)\n", key);
393
394         epde.in.handle = handle;
395         epde.in.key_name = talloc_strdup(tctx, key);
396         epde.in.offered = 0;
397         epde.out.needed = &needed;
398         epde.out.count = &count;
399
400         status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
401         torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed.");
402         if (W_ERROR_EQUAL(epde.out.result, WERR_MORE_DATA)) {
403                 epde.in.offered = needed;
404                 epde.out.buffer = talloc_array(tctx, uint8_t, needed);
405                 status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &epde);
406                 torture_assert_ntstatus_ok(tctx, status,
407                                 "EnumPrinterDataEx failed.");
408         }
409
410         torture_assert_werr_equal(tctx, epde.out.result, expected_error,
411                         "EnumPrinterDataEx failed.");
412
413         return true;
414 }
415
416 static bool test_ClosePrinter(struct torture_context *tctx,
417                                 struct dcerpc_pipe *p,
418                                 struct policy_handle *handle)
419 {
420         NTSTATUS status;
421         struct spoolss_ClosePrinter cp;
422
423         cp.in.handle  = handle;
424         cp.out.handle = handle;
425
426         status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp);
427         torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed");
428
429         return true;
430 }
431
432 static bool test_WinXP(struct torture_context *tctx, struct dcerpc_pipe *p)
433 {
434         bool ret = true;
435         struct test_spoolss_win_context *ctx, *tmp_ctx;
436         struct policy_handle handle01, handle02, handle03, handle04;
437         /* Sometimes a handle stays unused. In order to make this clear in the
438          * code, the unused_handle structures are used for that. */
439         struct policy_handle unused_handle1, unused_handle2;
440         char *server_name;
441         char *key_pointer;
442
443         ntvfs_init(tctx->lp_ctx);
444
445         ctx = talloc_zero(tctx, struct test_spoolss_win_context);
446         tmp_ctx = talloc_zero(tctx, struct test_spoolss_win_context);
447
448         ret &= test_OpenPrinterSequence(tctx, p, &handle01);
449         ret &= test_GetPrinterData(tctx, p, &handle01,"UISingleJobStatusString",
450                         WERR_INVALID_PARAM, 0);
451         torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");
452
453         server_name = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p));
454         ret &= test_OpenPrinterEx(tctx, p, &unused_handle1, server_name, 0);
455
456         ret &= test_EnumPrinters(tctx, p, ctx, 1024);
457
458         ret &= test_OpenPrinterEx(tctx, p, &handle02, server_name, 0);
459         ret &= test_GetPrinterData(tctx, p, &handle02, "MajorVersion", WERR_OK,
460                         3);
461         ret &= test_ClosePrinter(tctx, p, &handle02);
462
463         /* If no printers were found, skip all tests that need a printer */
464         if (ctx->printer_count == 0) {
465                 goto end_testWinXP;
466         }
467
468         ret &= test_OpenPrinterEx(tctx, p, &handle02,
469                         ctx->printer_info[0].info2.printername,
470                         PRINTER_ACCESS_USE);
471         ret &= test_GetPrinter(tctx, p, &handle02, ctx, 2, 0);
472
473         torture_assert_str_equal(tctx, ctx->current_info->info2.printername,
474                         ctx->printer_info[0].info2.printername,
475                         "GetPrinter returned unexpected printername");
476         /*FIXME: Test more components of the PrinterInfo2 struct */
477
478         ret &= test_OpenPrinterEx(tctx, p, &handle03,
479                         ctx->printer_info[0].info2.printername, 0);
480         ret &= test_GetPrinter(tctx, p, &handle03, ctx, 0, 1164);
481         ret &= test_GetPrinter(tctx, p, &handle03, ctx, 2, 0);
482
483         ret &= test_OpenPrinterEx(tctx, p, &handle04,
484                         ctx->printer_info[0].info2.printername, 0);
485         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 0);
486         ret &= test_ClosePrinter(tctx, p, &handle04);
487
488         ret &= test_OpenPrinterEx(tctx, p, &handle04,
489                         ctx->printer_info[0].info2.printername, 0);
490         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 4096);
491         ret &= test_ClosePrinter(tctx, p, &handle04);
492
493         ret &= test_OpenPrinterAsAdmin(tctx, p,
494                         ctx->printer_info[0].info2.printername);
495
496         ret &= test_OpenPrinterEx(tctx, p, &handle04,
497                         ctx->printer_info[0].info2.printername, PRINTER_READ);
498         ret &= test_GetPrinterData(tctx, p, &handle04,"UISingleJobStatusString",
499                         WERR_BADFILE, 0);
500         torture_comment(tctx, "Skip RemoteFindNextPrinterChangeNotifyEx test\n");
501
502         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
503                         ctx->printer_info[0].info2.printername, 0);
504
505         ret &= test_EnumJobs(tctx, p, &handle04);
506         ret &= test_GetPrinter(tctx, p, &handle04, ctx, 2, 4096);
507
508         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
509         ret &= test_ClosePrinter(tctx, p, &handle04);
510
511         ret &= test_EnumPrinters(tctx, p, ctx, 1556);
512         ret &= test_GetPrinterDriver2(tctx, p, &handle03);
513         ret &= test_EnumForms(tctx, p, &handle03, 0);
514
515         ret &= test_EnumPrinterKey(tctx, p, &handle03, "", ctx);
516         key_pointer = ctx->printer_keys;
517         while(*key_pointer != '\0') {
518                 char *end_pointer;
519                 char *key_name;
520
521                 for(end_pointer = key_pointer; *end_pointer != '\0';
522                                 ++end_pointer) {
523                         /* Do nothing, just move the pointer */
524                 }
525                 key_name = talloc_strndup(tctx, key_pointer,
526                                 end_pointer - key_pointer);
527
528                 ret &= test_EnumPrinterKey(tctx, p, &handle03, key_name,
529                                 tmp_ctx);
530                 ret &= test_EnumPrinterDataEx(tctx, p, &handle03, key_name, 0,
531                                 WERR_OK);
532
533                 key_pointer = ++end_pointer;
534         }
535
536         ret &= test_EnumPrinterDataEx(tctx, p, &handle03, "", 0,
537                         WERR_INVALID_PARAM);
538
539         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 2, 0);
540
541         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
542                         ctx->printer_info[0].info2.printername, 0);
543         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
544
545         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 2, 2556);
546
547         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
548                         ctx->printer_info[0].info2.printername, 0);
549         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
550
551         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
552                         ctx->printer_info[0].info2.printername, 0);
553         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
554
555         ret &= test_GetPrinter(tctx, p, &handle03, tmp_ctx, 7, 0);
556
557         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
558                         ctx->printer_info[0].info2.printername, 0);
559         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
560
561         ret &= test_ClosePrinter(tctx, p, &handle03);
562
563         ret &= test_OpenPrinterEx(tctx, p, &unused_handle2,
564                         ctx->printer_info[0].info2.printername, 0);
565         ret &= test_ClosePrinter(tctx, p, &unused_handle2);
566
567         ret &= test_OpenPrinterEx(tctx, p, &handle03, server_name, 0);
568         ret &= test_GetPrinterData(tctx, p, &handle03, "W3SvcInstalled",
569                         WERR_OK, 0);
570         ret &= test_ClosePrinter(tctx, p, &handle03);
571
572         ret &= test_ClosePrinter(tctx, p, &unused_handle1);
573         ret &= test_ClosePrinter(tctx, p, &handle02);
574
575         ret &= test_OpenPrinterEx(tctx, p, &handle02,
576                         ctx->printer_info[0].info2.sharename, 0);
577         ret &= test_GetPrinter(tctx, p, &handle02, tmp_ctx, 2, 0);
578         ret &= test_ClosePrinter(tctx, p, &handle02);
579
580 end_testWinXP:
581         ret &= test_ClosePrinter(tctx, p, &handle01);
582
583         talloc_free(tmp_ctx);
584         talloc_free(ctx);
585         return ret;
586 }
587
588 struct torture_suite *torture_rpc_spoolss_win(TALLOC_CTX *mem_ctx)
589 {
590         struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-WIN");
591
592         struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, 
593                                                         "win", &ndr_table_spoolss);
594
595         torture_rpc_tcase_add_test(tcase, "testWinXP", test_WinXP);
596
597         return suite;
598 }
599