s4-smbtorture: enhance spoolss_EnumPrinterKey torture test.
authorGünther Deschner <gd@samba.org>
Wed, 9 Dec 2009 14:31:51 +0000 (15:31 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 9 Dec 2009 14:34:45 +0000 (15:34 +0100)
This demonstrates that s3 still does not have that call implemented correctly.

Guenther

source4/torture/rpc/spoolss.c

index 1b3f8d19aace1e5036bcfda434aad502d52ec259..7468278e08e2f93704934e1b9cc2406a4baebe68 100644 (file)
@@ -3354,30 +3354,42 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
        struct spoolss_EnumPrinterKey r;
        uint32_t needed;
        struct spoolss_StringArray2 key_buffer;
        struct spoolss_EnumPrinterKey r;
        uint32_t needed;
        struct spoolss_StringArray2 key_buffer;
+       uint32_t offered[] = { 0, 512, 1024, 2048 };
+       int i;
 
        r.in.handle = handle;
        r.in.key_name = key_name;
 
        r.in.handle = handle;
        r.in.key_name = key_name;
-       r.in.offered = 0;
        r.out.key_buffer = &key_buffer;
        r.out.needed = &needed;
 
        r.out.key_buffer = &key_buffer;
        r.out.needed = &needed;
 
-       torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", r.in.key_name);
+       for (i=0; i < ARRAY_SIZE(offered); i++) {
+               r.in.offered = offered[i];
+
+               torture_comment(tctx, "Testing EnumPrinterKey(%s) with %d offered\n", r.in.key_name, r.in.offered);
 
 
-       torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
-               "failed to call EnumPrinterKey");
-       if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
-               torture_assert(tctx, (key_buffer._ndr_size == 0),
-                       talloc_asprintf(tctx, "EnumPrinterKey did not return 0 _ndr_size (but %d), windows clients would abort here!", key_buffer._ndr_size));
-               r.in.offered = needed;
                torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
                        "failed to call EnumPrinterKey");
                torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
                        "failed to call EnumPrinterKey");
-       }
-       torture_assert_werr_ok(tctx, r.out.result,
-               "failed to call EnumPrinterKey");
+               if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+                       torture_assert(tctx, (key_buffer._ndr_size == 0),
+                               talloc_asprintf(tctx, "EnumPrinterKey did not return 0 _ndr_size (but %d), windows clients would abort here!", key_buffer._ndr_size));
+                       r.in.offered = needed;
+                       torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
+                               "failed to call EnumPrinterKey");
+               }
+               torture_assert_werr_ok(tctx, r.out.result,
+                       "failed to call EnumPrinterKey");
+
+               torture_assert(tctx, (key_buffer._ndr_size * 2 == r.in.offered),
+                       talloc_asprintf(tctx, "EnumPrinterKey size mismatch, _ndr_size %d (expected %d)",
+                               key_buffer._ndr_size, r.in.offered/2));
 
 
-       torture_assert(tctx, (key_buffer._ndr_size * 2 == needed),
-               talloc_asprintf(tctx, "EnumPrinterKey size mismatch, _ndr_size %d (expected %d)",
-               key_buffer._ndr_size, needed/2));
+               torture_assert(tctx, (*r.out.needed <= r.in.offered),
+                       talloc_asprintf(tctx, "EnumPrinterKey size mismatch: needed %d is not <= offered %d", *r.out.needed, r.in.offered));
+
+               torture_assert(tctx, (*r.out.needed <= key_buffer._ndr_size * 2),
+                       talloc_asprintf(tctx, "EnumPrinterKey size mismatch: needed %d is not <= _ndr_size %d * 2", *r.out.needed, key_buffer._ndr_size));
+
+       }
 
        if (array) {
                *array = key_buffer.string;
 
        if (array) {
                *array = key_buffer.string;