s3: spoolss: Extend publish_toggle test to check returned GUID string format
authorSamuel Cabrero <scabrero@suse.de>
Thu, 5 Oct 2017 17:22:29 +0000 (19:22 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 11 Oct 2017 04:39:00 +0000 (06:39 +0200)
Extend the rpc.spoolss.printer.addprinter.publish_toggle test to
check the format of the returned GUID string in GetPrinter info
level 7 structure.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12993

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Oct 11 06:39:00 CEST 2017 on sn-devel-144

source4/torture/rpc/spoolss.c

index d4f6969..31b9525 100644 (file)
@@ -9218,14 +9218,26 @@ static bool test_printer_set_publish(struct torture_context *tctx,
                                         "info7 publish flag not set");
        } else {
                struct GUID guid;
+               char *ref_guid;
                torture_assert_int_equal(tctx,
                                         info.info7.action,
                                         DSPRINT_PUBLISH,
                                         "info7 publish flag not set");
+
+               /* GUID_from_string is able to parse both plain and
+                * curly-braced guids */
                torture_assert_ntstatus_ok(tctx,
                                           GUID_from_string(info.info7.guid,
                                           &guid),
                                           "invalid published printer GUID");
+
+               /* Build reference GUID string */
+               ref_guid = GUID_string2(tctx, &guid);
+               torture_assert_not_null(tctx, ref_guid, "ENOMEM");
+               ref_guid = talloc_strdup_upper(tctx, ref_guid);
+               torture_assert_not_null(tctx, ref_guid, "ENOMEM");
+               torture_assert_str_equal(tctx, info.info7.guid, ref_guid,
+                       "invalid GUID format");
        }
 
        return true;