torture: support printer publish pending responses
authorDavid Disseldorp <ddiss@samba.org>
Wed, 29 May 2013 08:43:35 +0000 (10:43 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 3 Jun 2013 14:06:15 +0000 (16:06 +0200)
Windows (tested against 2k8r2) returns WERR_IO_PENDING and
DSPRINT_PENDING when a publish or unpublish is requested via
setprinter(level=7). Modify the AD printer publishing test to support
these responses.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Jun  3 16:06:15 CEST 2013 on sn-devel-104

source4/torture/rpc/spoolss.c

index 959ba30e8391675bdd307d80da9734f1d8cb415d..4c84bc0d1386e586c2b3c3ddb9e695649b1df200 100644 (file)
@@ -1247,8 +1247,9 @@ static bool test_SetPrinter(struct torture_context *tctx,
 
        torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_SetPrinter_r(b, tctx, &r),
                "failed to call SetPrinter");
-       torture_assert_werr_ok(tctx, r.out.result,
-               "failed to call SetPrinter");
+       torture_assert(tctx, (W_ERROR_EQUAL(r.out.result, WERR_OK)
+                          || W_ERROR_EQUAL(r.out.result, WERR_IO_PENDING)),
+                      "SetPrinter failed");
 
        return true;
 }
@@ -8534,7 +8535,6 @@ static bool test_printer_set_publish(struct torture_context *tctx,
        struct spoolss_SetPrinterInfoCtr info_ctr;
        struct spoolss_DevmodeContainer devmode_ctr;
        struct sec_desc_buf secdesc_ctr;
-       struct GUID guid;
 
        info7.guid = "";
        info7.action = DSPRINT_PUBLISH;
@@ -8558,11 +8558,23 @@ static bool test_printer_set_publish(struct torture_context *tctx,
        torture_assert(tctx,
                       test_GetPrinter_level(tctx, b, handle, 7, &info),
                       "");
-       torture_assert_int_equal(tctx,
-                                info.info7.action, DSPRINT_PUBLISH,
-                                "info7 publish flag not set");
-       torture_assert_ntstatus_ok(tctx, GUID_from_string(info.info7.guid, &guid),
-                                  "invalid guid for published printer");
+       if (info.info7.action & DSPRINT_PENDING) {
+               torture_comment(tctx, "publish is pending\n");
+               torture_assert_int_equal(tctx,
+                                        info.info7.action,
+                                        (DSPRINT_PENDING | DSPRINT_PUBLISH),
+                                        "info7 publish flag not set");
+       } else {
+               struct GUID guid;
+               torture_assert_int_equal(tctx,
+                                        info.info7.action,
+                                        DSPRINT_PUBLISH,
+                                        "info7 publish flag not set");
+               torture_assert_ntstatus_ok(tctx,
+                                          GUID_from_string(info.info7.guid,
+                                          &guid),
+                                          "invalid published printer GUID");
+       }
 
        return true;
 }
@@ -8599,12 +8611,23 @@ static bool test_printer_set_unpublish(struct torture_context *tctx,
        torture_assert(tctx,
                       test_GetPrinter_level(tctx, b, handle, 7, &info),
                       "");
-       torture_assert_int_equal(tctx,
-                                info.info7.action, DSPRINT_UNPUBLISH,
-                                "info7 unpublish flag not set");
-       torture_assert_str_equal(tctx,
-                                info.info7.guid, "",
-                                "guid not empty after unpublish");
+
+       if (info.info7.action & DSPRINT_PENDING) {
+               struct GUID guid;
+               torture_comment(tctx, "unpublish is pending\n");
+               torture_assert_int_equal(tctx,
+                                        info.info7.action,
+                                        (DSPRINT_PENDING | DSPRINT_UNPUBLISH),
+                                        "info7 unpublish flag not set");
+               torture_assert_ntstatus_ok(tctx,
+                                          GUID_from_string(info.info7.guid,
+                                          &guid),
+                                          "invalid printer GUID");
+       } else {
+               torture_assert_int_equal(tctx,
+                                        info.info7.action, DSPRINT_UNPUBLISH,
+                                        "info7 unpublish flag not set");
+       }
 
        return true;
 }