s4-smbtorture: unify test list to run against single created printers in RPC-SPOOLSS...
[abartlet/samba.git/.git] / source4 / torture / rpc / spoolss_notify.c
1 /*
2    Unix SMB/CIFS implementation.
3    test suite for spoolss rpc notify operations
4
5    Copyright (C) Jelmer Vernooij 2007
6    Copyright (C) Guenther Deschner 2010
7
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "includes.h"
24 #include "system/filesys.h"
25 #include "librpc/gen_ndr/ndr_spoolss_c.h"
26 #include "librpc/gen_ndr/ndr_spoolss.h"
27 #include "torture/rpc/rpc.h"
28 #include "rpc_server/dcerpc_server.h"
29 #include "rpc_server/service_rpc.h"
30 #include "smbd/process_model.h"
31 #include "smb_server/smb_server.h"
32 #include "lib/socket/netif.h"
33 #include "ntvfs/ntvfs.h"
34 #include "param/param.h"
35
36 static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface)
37 {
38         return NT_STATUS_OK;
39 }
40
41 static void spoolss__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface)
42 {
43 }
44
45 static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r)
46 {
47         enum ndr_err_code ndr_err;
48         uint16_t opnum = dce_call->pkt.u.request.opnum;
49
50         dce_call->fault_code = 0;
51
52         if (opnum >= ndr_table_spoolss.num_calls) {
53                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
54                 return NT_STATUS_NET_WRITE_FAULT;
55         }
56
57         *r = talloc_size(mem_ctx, ndr_table_spoolss.calls[opnum].struct_size);
58         NT_STATUS_HAVE_NO_MEMORY(*r);
59
60         /* unravel the NDR for the packet */
61         ndr_err = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r);
62         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
63                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
64                                                   &ndr_table_spoolss, opnum, NDR_IN,
65                                   &dce_call->pkt.u.request.stub_and_verifier);
66                 dce_call->fault_code = DCERPC_FAULT_NDR;
67                 return NT_STATUS_NET_WRITE_FAULT;
68         }
69
70         return NT_STATUS_OK;
71 }
72
73 /* Note that received_packets are allocated in talloc_autofree_context(),
74  * because no other context appears to stay around long enough. */
75 static struct received_packet {
76         uint16_t opnum;
77         void *r;
78         struct received_packet *prev, *next;
79 } *received_packets = NULL;
80
81 static WERROR _spoolss_ReplyOpenPrinter(struct dcesrv_call_state *dce_call,
82                                         TALLOC_CTX *mem_ctx,
83                                         struct spoolss_ReplyOpenPrinter *r)
84 {
85         DEBUG(1,("_spoolss_ReplyOpenPrinter\n"));
86
87         NDR_PRINT_IN_DEBUG(spoolss_ReplyOpenPrinter, r);
88
89         r->out.handle = talloc(r, struct policy_handle);
90         r->out.handle->handle_type = 42;
91         r->out.handle->uuid = GUID_random();
92         r->out.result = WERR_OK;
93
94         NDR_PRINT_OUT_DEBUG(spoolss_ReplyOpenPrinter, r);
95
96         return WERR_OK;
97 }
98
99 static WERROR _spoolss_ReplyClosePrinter(struct dcesrv_call_state *dce_call,
100                                          TALLOC_CTX *mem_ctx,
101                                          struct spoolss_ReplyClosePrinter *r)
102 {
103         DEBUG(1,("_spoolss_ReplyClosePrinter\n"));
104
105         NDR_PRINT_IN_DEBUG(spoolss_ReplyClosePrinter, r);
106
107         ZERO_STRUCTP(r->out.handle);
108         r->out.result = WERR_OK;
109
110         NDR_PRINT_OUT_DEBUG(spoolss_ReplyClosePrinter, r);
111
112         return WERR_OK;
113 }
114
115 static WERROR _spoolss_RouterReplyPrinterEx(struct dcesrv_call_state *dce_call,
116                                             TALLOC_CTX *mem_ctx,
117                                             struct spoolss_RouterReplyPrinterEx *r)
118 {
119         DEBUG(1,("_spoolss_RouterReplyPrinterEx\n"));
120
121         NDR_PRINT_IN_DEBUG(spoolss_RouterReplyPrinterEx, r);
122
123         r->out.reply_result = talloc(r, uint32_t);
124         *r->out.reply_result = 0;
125         r->out.result = WERR_OK;
126
127         NDR_PRINT_OUT_DEBUG(spoolss_RouterReplyPrinterEx, r);
128
129         return WERR_OK;
130 }
131
132 static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
133 {
134         uint16_t opnum = dce_call->pkt.u.request.opnum;
135         struct received_packet *rp;
136
137         rp = talloc_zero(talloc_autofree_context(), struct received_packet);
138         rp->opnum = opnum;
139         rp->r = talloc_reference(rp, r);
140
141         DLIST_ADD_END(received_packets, rp, struct received_packet *);
142
143         switch (opnum) {
144         case 58: {
145                 struct spoolss_ReplyOpenPrinter *r2 = (struct spoolss_ReplyOpenPrinter *)r;
146                 r2->out.result = _spoolss_ReplyOpenPrinter(dce_call, mem_ctx, r2);
147                 break;
148         }
149         case 60: {
150                 struct spoolss_ReplyClosePrinter *r2 = (struct spoolss_ReplyClosePrinter *)r;
151                 r2->out.result = _spoolss_ReplyClosePrinter(dce_call, mem_ctx, r2);
152                 break;
153         }
154         case 66: {
155                 struct spoolss_RouterReplyPrinterEx *r2 = (struct spoolss_RouterReplyPrinterEx *)r;
156                 r2->out.result = _spoolss_RouterReplyPrinterEx(dce_call, mem_ctx, r2);
157                 break;
158         }
159
160         default:
161                 dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR;
162                 break;
163         }
164
165         if (dce_call->fault_code != 0) {
166                 dcerpc_log_packet(dce_call->conn->packet_log_dir,
167                                                   &ndr_table_spoolss, opnum, NDR_IN,
168                                   &dce_call->pkt.u.request.stub_and_verifier);
169                 return NT_STATUS_NET_WRITE_FAULT;
170         }
171         return NT_STATUS_OK;
172 }
173
174
175 static NTSTATUS spoolss__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r)
176 {
177         return NT_STATUS_OK;
178 }
179
180
181 static NTSTATUS spoolss__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r)
182 {
183         enum ndr_err_code ndr_err;
184         uint16_t opnum = dce_call->pkt.u.request.opnum;
185
186         ndr_err = ndr_table_spoolss.calls[opnum].ndr_push(push, NDR_OUT, r);
187         if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
188                 dce_call->fault_code = DCERPC_FAULT_NDR;
189                 return NT_STATUS_NET_WRITE_FAULT;
190         }
191
192         return NT_STATUS_OK;
193 }
194
195 const static struct dcesrv_interface notify_test_spoolss_interface = {
196         .name           = "spoolss",
197         .syntax_id  = {{0x12345678,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xab}},1.0},
198         .bind           = spoolss__op_bind,
199         .unbind         = spoolss__op_unbind,
200         .ndr_pull       = spoolss__op_ndr_pull,
201         .dispatch       = spoolss__op_dispatch,
202         .reply          = spoolss__op_reply,
203         .ndr_push       = spoolss__op_ndr_push
204 };
205
206 static bool spoolss__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version)
207 {
208         if (notify_test_spoolss_interface.syntax_id.if_version == if_version &&
209                 GUID_equal(&notify_test_spoolss_interface.syntax_id.uuid, uuid)) {
210                 memcpy(iface,&notify_test_spoolss_interface, sizeof(*iface));
211                 return true;
212         }
213
214         return false;
215 }
216
217 static bool spoolss__op_interface_by_name(struct dcesrv_interface *iface, const char *name)
218 {
219         if (strcmp(notify_test_spoolss_interface.name, name)==0) {
220                 memcpy(iface, &notify_test_spoolss_interface, sizeof(*iface));
221                 return true;
222         }
223
224         return false;
225 }
226
227 static NTSTATUS spoolss__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server)
228 {
229         int i;
230
231         for (i=0;i<ndr_table_spoolss.endpoints->count;i++) {
232                 NTSTATUS ret;
233                 const char *name = ndr_table_spoolss.endpoints->names[i];
234
235                 ret = dcesrv_interface_register(dce_ctx, name, &notify_test_spoolss_interface, NULL);
236                 if (!NT_STATUS_IS_OK(ret)) {
237                         DEBUG(1,("spoolss_op_init_server: failed to register endpoint '%s'\n",name));
238                         return ret;
239                 }
240         }
241
242         return NT_STATUS_OK;
243 }
244
245 static bool test_OpenPrinter(struct torture_context *tctx,
246                              struct dcerpc_pipe *p,
247                              struct policy_handle *handle,
248                              const char *name)
249 {
250         struct spoolss_OpenPrinter r;
251         const char *printername;
252
253         ZERO_STRUCT(r);
254
255         if (name) {
256                 printername     = talloc_asprintf(tctx, "\\\\%s\\%s", dcerpc_server_name(p), name);
257         } else {
258                 printername     = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
259         }
260
261         r.in.printername        = printername;
262         r.in.datatype           = NULL;
263         r.in.devmode_ctr.devmode= NULL;
264         r.in.access_mask        = SEC_FLAG_MAXIMUM_ALLOWED;
265         r.out.handle            = handle;
266
267         torture_comment(tctx, "Testing OpenPrinter(%s)\n", r.in.printername);
268
269         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_OpenPrinter(p, tctx, &r),
270                 "OpenPrinter failed");
271         torture_assert_werr_ok(tctx, r.out.result,
272                 "OpenPrinter failed");
273
274         return true;
275 }
276
277 static struct spoolss_NotifyOption *setup_printserver_NotifyOption(struct torture_context *tctx)
278 {
279         struct spoolss_NotifyOption *o;
280
281         o = talloc_zero(tctx, struct spoolss_NotifyOption);
282
283         o->version = 2;
284         o->flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
285
286         o->count = 2;
287         o->types = talloc_zero_array(o, struct spoolss_NotifyOptionType, o->count);
288
289         o->types[0].type = PRINTER_NOTIFY_TYPE;
290         o->types[0].count = 1;
291         o->types[0].fields = talloc_array(o->types, union spoolss_Field, o->types[0].count);
292         o->types[0].fields[0].field = PRINTER_NOTIFY_FIELD_SERVER_NAME;
293
294         o->types[1].type = JOB_NOTIFY_TYPE;
295         o->types[1].count = 1;
296         o->types[1].fields = talloc_array(o->types, union spoolss_Field, o->types[1].count);
297         o->types[1].fields[0].field = JOB_NOTIFY_FIELD_MACHINE_NAME;
298
299         return o;
300 }
301
302 static struct spoolss_NotifyOption *setup_printer_NotifyOption(struct torture_context *tctx)
303 {
304         struct spoolss_NotifyOption *o;
305
306         o = talloc_zero(tctx, struct spoolss_NotifyOption);
307
308         o->version = 2;
309         o->flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
310
311         o->count = 1;
312         o->types = talloc_zero_array(o, struct spoolss_NotifyOptionType, o->count);
313
314         o->types[0].type = PRINTER_NOTIFY_TYPE;
315         o->types[0].count = 1;
316         o->types[0].fields = talloc_array(o->types, union spoolss_Field, o->types[0].count);
317         o->types[0].fields[0].field = PRINTER_NOTIFY_FIELD_COMMENT;
318
319         return o;
320 }
321
322
323 static bool test_RemoteFindFirstPrinterChangeNotifyEx(struct torture_context *tctx,
324                                                       struct dcerpc_pipe *p,
325                                                       struct policy_handle *handle,
326                                                       const char *address,
327                                                       struct spoolss_NotifyOption *option)
328 {
329         struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r;
330
331         torture_comment(tctx, "Testing RemoteFindFirstPrinterChangeNotifyEx\n");
332
333         r.in.flags = 0;
334         r.in.local_machine = talloc_asprintf(tctx, "\\\\%s", address);
335         r.in.options = 0;
336         r.in.printer_local = 0;
337         r.in.notify_options = option;
338         r.in.handle = handle;
339
340         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r),
341                 "RemoteFindFirstPrinterChangeNotifyEx failed");
342         torture_assert_werr_ok(tctx, r.out.result,
343                 "error return code for RemoteFindFirstPrinterChangeNotifyEx");
344
345         return true;
346 }
347
348 static bool test_RouterRefreshPrinterChangeNotify(struct torture_context *tctx,
349                                                   struct dcerpc_pipe *p,
350                                                   struct policy_handle *handle,
351                                                   struct spoolss_NotifyOption *options)
352 {
353         struct spoolss_RouterRefreshPrinterChangeNotify r;
354         struct spoolss_NotifyInfo *info;
355
356         torture_comment(tctx, "Testing RouterRefreshPrinterChangeNotify\n");
357
358         r.in.handle = handle;
359         r.in.change_low = 0;
360         r.in.options = options;
361         r.out.info = &info;
362
363         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_RouterRefreshPrinterChangeNotify(p, tctx, &r),
364                 "RouterRefreshPrinterChangeNotify failed");
365         torture_assert_werr_ok(tctx, r.out.result,
366                 "error return code for RouterRefreshPrinterChangeNotify");
367
368         return true;
369 }
370
371 static bool test_ClosePrinter(struct torture_context *tctx,
372                               struct dcerpc_pipe *p,
373                               struct policy_handle *handle)
374 {
375         struct spoolss_ClosePrinter r;
376
377         r.in.handle = handle;
378         r.out.handle = handle;
379
380         torture_comment(tctx, "Testing ClosePrinter\n");
381
382         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_ClosePrinter(p, tctx, &r),
383                 "ClosePrinter failed");
384         torture_assert_werr_ok(tctx, r.out.result,
385                 "ClosePrinter failed");
386
387         return true;
388 }
389
390 static bool test_SetPrinter(struct torture_context *tctx,
391                             struct dcerpc_pipe *p,
392                             struct policy_handle *handle)
393 {
394         union spoolss_PrinterInfo info;
395         struct spoolss_SetPrinter r;
396         struct spoolss_SetPrinterInfo2 info2;
397         struct spoolss_SetPrinterInfoCtr info_ctr;
398         struct spoolss_DevmodeContainer devmode_ctr;
399         struct sec_desc_buf secdesc_ctr;
400
401         torture_assert(tctx, test_GetPrinter_level(tctx, p, handle, 2, &info), "");
402
403         ZERO_STRUCT(devmode_ctr);
404         ZERO_STRUCT(secdesc_ctr);
405
406         info2.servername        = info.info2.servername;
407         info2.printername       = info.info2.printername;
408         info2.sharename         = info.info2.sharename;
409         info2.portname          = info.info2.portname;
410         info2.drivername        = info.info2.drivername;
411         info2.comment           = talloc_asprintf(tctx, "torture_comment %d\n", (int)time(NULL));
412         info2.location          = info.info2.location;
413         info2.devmode_ptr       = 0;
414         info2.sepfile           = info.info2.sepfile;
415         info2.printprocessor    = info.info2.printprocessor;
416         info2.datatype          = info.info2.datatype;
417         info2.parameters        = info.info2.parameters;
418         info2.secdesc_ptr       = 0;
419         info2.attributes        = info.info2.attributes;
420         info2.priority          = info.info2.priority;
421         info2.defaultpriority   = info.info2.defaultpriority;
422         info2.starttime         = info.info2.starttime;
423         info2.untiltime         = info.info2.untiltime;
424         info2.status            = info.info2.status;
425         info2.cjobs             = info.info2.cjobs;
426         info2.averageppm        = info.info2.averageppm;
427
428         info_ctr.level = 2;
429         info_ctr.info.info2 = &info2;
430
431         r.in.handle = handle;
432         r.in.info_ctr = &info_ctr;
433         r.in.devmode_ctr = &devmode_ctr;
434         r.in.secdesc_ctr = &secdesc_ctr;
435         r.in.command = 0;
436
437         torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_SetPrinter(p, tctx, &r), "SetPrinter failed");
438         torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed");
439
440         return true;
441 }
442
443 static bool test_start_dcerpc_server(struct torture_context *tctx,
444                                      struct tevent_context *event_ctx,
445                                      struct dcesrv_context **dce_ctx_p,
446                                      const char **address_p)
447 {
448         struct dcesrv_endpoint_server ep_server;
449         NTSTATUS status;
450         struct dcesrv_context *dce_ctx;
451         const char *endpoints[] = { "spoolss", NULL };
452         struct dcesrv_endpoint *e;
453         const char *address;
454         struct interface *ifaces;
455
456         ntvfs_init(tctx->lp_ctx);
457
458         /* fill in our name */
459         ep_server.name = "spoolss";
460
461         /* fill in all the operations */
462         ep_server.init_server = spoolss__op_init_server;
463
464         ep_server.interface_by_uuid = spoolss__op_interface_by_uuid;
465         ep_server.interface_by_name = spoolss__op_interface_by_name;
466
467         torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server),
468                                   "unable to register spoolss server");
469
470         lp_set_cmdline(tctx->lp_ctx, "dcerpc endpoint servers", "spoolss");
471
472         load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
473         address = iface_n_ip(ifaces, 0);
474
475         torture_comment(tctx, "Listening for callbacks on %s\n", address);
476
477         status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, &single_ops, address);
478         torture_assert_ntstatus_ok(tctx, status, "starting smb server");
479
480         status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints, &dce_ctx);
481         torture_assert_ntstatus_ok(tctx, status,
482                                    "unable to initialize DCE/RPC server");
483
484         for (e=dce_ctx->endpoint_list;e;e=e->next) {
485                 status = dcesrv_add_ep(dce_ctx, tctx->lp_ctx,
486                                        e, tctx->ev, &single_ops);
487                 torture_assert_ntstatus_ok(tctx, status,
488                                 "unable listen on dcerpc endpoint server");
489         }
490
491         *dce_ctx_p = dce_ctx;
492         *address_p = address;
493
494         return true;
495 }
496
497 static struct received_packet *last_packet(struct received_packet *p)
498 {
499         struct received_packet *tmp;
500         for (tmp = p; tmp->next; tmp = tmp->next) ;;
501         return tmp;
502 }
503
504 static bool test_RFFPCNEx(struct torture_context *tctx,
505                           struct dcerpc_pipe *p)
506 {
507         struct dcesrv_context *dce_ctx;
508         struct policy_handle handle;
509         const char *address;
510         struct received_packet *tmp;
511         struct spoolss_NotifyOption *server_option = setup_printserver_NotifyOption(tctx);
512         struct spoolss_NotifyOption *printer_option = setup_printer_NotifyOption(tctx);
513
514         received_packets = NULL;
515
516         /* Start DCE/RPC server */
517         torture_assert(tctx, test_start_dcerpc_server(tctx, p->conn->event_ctx, &dce_ctx, &address), "");
518
519         torture_assert(tctx, test_OpenPrinter(tctx, p, &handle, NULL), "");
520         torture_assert(tctx, test_RemoteFindFirstPrinterChangeNotifyEx(tctx, p, &handle, address, server_option), "");
521         torture_assert(tctx, received_packets, "no packets received");
522         torture_assert_int_equal(tctx, received_packets->opnum, NDR_SPOOLSS_REPLYOPENPRINTER,
523                 "no ReplyOpenPrinter packet after RemoteFindFirstPrinterChangeNotifyEx");
524         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, NULL), "");
525         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, server_option), "");
526         torture_assert(tctx, test_ClosePrinter(tctx, p, &handle), "");
527         tmp = last_packet(received_packets);
528         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYCLOSEPRINTER,
529                 "no ReplyClosePrinter packet after ClosePrinter");
530 #if 0
531         torture_assert(tctx, test_OpenPrinter(tctx, p, &handle, "Epson AL-2600"), "");
532         torture_assert(tctx, test_RemoteFindFirstPrinterChangeNotifyEx(tctx, p, &handle, address, printer_option), "");
533         tmp = last_packet(received_packets);
534         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYOPENPRINTER,
535                 "no ReplyOpenPrinter packet after RemoteFindFirstPrinterChangeNotifyEx");
536         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, NULL), "");
537         torture_assert(tctx, test_RouterRefreshPrinterChangeNotify(tctx, p, &handle, printer_option), "");
538         torture_assert(tctx, test_SetPrinter(tctx, p, &handle), "");
539         tmp = last_packet(received_packets);
540         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_ROUTERREPLYPRINTEREX,
541                 "no RouterReplyPrinterEx packet after ClosePrinter");
542         torture_assert(tctx, test_ClosePrinter(tctx, p, &handle), "");
543         tmp = last_packet(received_packets);
544         torture_assert_int_equal(tctx, tmp->opnum, NDR_SPOOLSS_REPLYCLOSEPRINTER,
545                 "no ReplyClosePrinter packet after ClosePrinter");
546 #endif
547         /* Shut down DCE/RPC server */
548         talloc_free(dce_ctx);
549
550         return true;
551 }
552
553 /** Test that makes sure that calling ReplyOpenPrinter()
554  * on Samba 4 will cause an irpc broadcast call.
555  */
556 static bool test_ReplyOpenPrinter(struct torture_context *tctx,
557                                   struct dcerpc_pipe *p)
558 {
559         struct spoolss_ReplyOpenPrinter r;
560         struct spoolss_ReplyClosePrinter s;
561         struct policy_handle h;
562
563         if (torture_setting_bool(tctx, "samba3", false)) {
564                 torture_skip(tctx, "skipping ReplyOpenPrinter server implementation test against s3\n");
565         }
566
567         r.in.server_name = "earth";
568         r.in.printer_local = 2;
569         r.in.type = REG_DWORD;
570         r.in.bufsize = 0;
571         r.in.buffer = NULL;
572         r.out.handle = &h;
573
574         torture_assert_ntstatus_ok(tctx,
575                         dcerpc_spoolss_ReplyOpenPrinter(p, tctx, &r),
576                         "spoolss_ReplyOpenPrinter call failed");
577
578         torture_assert_werr_ok(tctx, r.out.result, "error return code");
579
580         s.in.handle = &h;
581         s.out.handle = &h;
582
583         torture_assert_ntstatus_ok(tctx,
584                         dcerpc_spoolss_ReplyClosePrinter(p, tctx, &s),
585                         "spoolss_ReplyClosePrinter call failed");
586
587         torture_assert_werr_ok(tctx, r.out.result, "error return code");
588
589         return true;
590 }
591
592 struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx)
593 {
594         struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-NOTIFY");
595
596         struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite,
597                                                         "notify", &ndr_table_spoolss);
598
599         torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx);
600         torture_rpc_tcase_add_test(tcase, "testReplyOpenPrinter", test_ReplyOpenPrinter);
601
602         return suite;
603 }