The branch, master has been updated
       via  1a64d3c... s4-smbtorture: add stricter SetPrinterDataEx tests to 
spoolss tests.
       via  4f6634e... s4-smbtorture: add test_SetPrinterDataEx to 
RPC-SPOOLSS-PRINTER.
       via  74c7c1c... s4-smbtorture: return needed size pointer from 
test_GetPrinterDataEx.
       via  e76b8a0... s4-smbtorture: test at least three different regtypes in 
test_SetPrinterDataEx.
      from  8bebb38... s3: Add connections_forall_read()

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1a64d3cbc65b70df1f1b3f473cdbfdce5c8f2ae9
Author: Günther Deschner <[email protected]>
Date:   Mon Mar 1 14:35:59 2010 +0100

    s4-smbtorture: add stricter SetPrinterDataEx tests to spoolss tests.
    
    Guenther

commit 4f6634e56dde97552fec69c99cbf63f80609f9f4
Author: Günther Deschner <[email protected]>
Date:   Mon Mar 1 14:27:43 2010 +0100

    s4-smbtorture: add test_SetPrinterDataEx to RPC-SPOOLSS-PRINTER.
    
    Guenther

commit 74c7c1cc7fcaed83a86ef0708c0faf4735bc5737
Author: Günther Deschner <[email protected]>
Date:   Mon Mar 1 14:26:30 2010 +0100

    s4-smbtorture: return needed size pointer from test_GetPrinterDataEx.
    
    Guenther

commit e76b8a07002dc3d01d5f4624c8cae25e75020099
Author: Günther Deschner <[email protected]>
Date:   Mon Mar 1 12:53:11 2010 +0100

    s4-smbtorture: test at least three different regtypes in 
test_SetPrinterDataEx.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source4/torture/rpc/spoolss.c |  132 +++++++++++++++++++++++++++++++++--------
 1 files changed, 108 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index b76ae6f..2b4d948 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -30,6 +30,7 @@
 #include "libcli/security/security.h"
 #include "torture/rpc/rpc.h"
 #include "param/param.h"
+#include "lib/registry/registry.h"
 
 #define TORTURE_WELLKNOWN_PRINTER      "torture_wkn_printer"
 #define TORTURE_PRINTER                        "torture_printer"
@@ -2893,7 +2894,8 @@ static bool test_GetPrinterDataEx(struct torture_context 
*tctx,
                                  const char *key_name,
                                  const char *value_name,
                                  enum winreg_Type *type_p,
-                                 union spoolss_PrinterData *data_p)
+                                 union spoolss_PrinterData *data_p,
+                                 uint32_t *needed_p)
 {
        NTSTATUS status;
        struct spoolss_GetPrinterDataEx r;
@@ -2940,6 +2942,10 @@ static bool test_GetPrinterDataEx(struct torture_context 
*tctx,
                *data_p = data;
        }
 
+       if (needed_p) {
+               *needed_p = needed;
+       }
+
        return true;
 }
 
@@ -2970,7 +2976,7 @@ static bool test_GetPrinterData_list(struct 
torture_context *tctx,
 
                torture_assert(tctx, test_GetPrinterData(tctx, p, handle, 
list[i], &type, &data),
                        talloc_asprintf(tctx, "GetPrinterData failed on %s\n", 
list[i]));
-               torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, 
"random_string", list[i], &type_ex, &data_ex),
+               torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, 
"random_string", list[i], &type_ex, &data_ex, NULL),
                        talloc_asprintf(tctx, "GetPrinterDataEx failed on 
%s\n", list[i]));
                torture_assert_int_equal(tctx, type, type_ex, "type mismatch");
                switch (type) {
@@ -3041,7 +3047,7 @@ static bool test_EnumPrinterData(struct torture_context 
*tctx, struct dcerpc_pip
                torture_assert(tctx, test_GetPrinterData(tctx, p, handle, 
r.out.value_name, NULL, NULL),
                        talloc_asprintf(tctx, "failed to call GetPrinterData 
for %s\n", r.out.value_name));
 
-               torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, 
"PrinterDriverData", r.out.value_name, NULL, NULL),
+               torture_assert(tctx, test_GetPrinterDataEx(tctx, p, handle, 
"PrinterDriverData", r.out.value_name, NULL, NULL, NULL),
                        talloc_asprintf(tctx, "failed to call GetPrinterDataEx 
on PrinterDriverData for %s\n", r.out.value_name));
 
                r.in.enum_index++;
@@ -3222,10 +3228,38 @@ static bool test_EnumPrinterKey(struct torture_context 
*tctx,
 
 static bool test_SetPrinterDataEx(struct torture_context *tctx,
                                  struct dcerpc_pipe *p,
-                                 struct policy_handle *handle)
+                                 struct policy_handle *handle,
+                                 const char *key_name,
+                                 const char *value_name,
+                                 enum winreg_Type type,
+                                 union spoolss_PrinterData *data,
+                                 uint32_t _offered)
 {
        NTSTATUS status;
        struct spoolss_SetPrinterDataEx r;
+
+       r.in.handle = handle;
+       r.in.key_name = key_name;
+       r.in.value_name = value_name;
+       r.in.type = type;
+       r.in.data = *data;
+       r.in._offered = _offered;
+
+       torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s) type: %s, 
offered: 0x%08x\n",
+               r.in.key_name, r.in.value_name, str_regtype(r.in.type), 
r.in._offered);
+
+       status = dcerpc_spoolss_SetPrinterDataEx(p, tctx, &r);
+
+       torture_assert_ntstatus_ok(tctx, status, "SetPrinterDataEx failed");
+       torture_assert_werr_ok(tctx, r.out.result, "SetPrinterDataEx failed");
+
+       return true;
+}
+
+static bool test_SetPrinterDataEx_matrix(struct torture_context *tctx,
+                                        struct dcerpc_pipe *p,
+                                        struct policy_handle *handle)
+{
        const char *value_name = "dog";
        const char *keys[] = {
                "torturedataex",
@@ -3248,45 +3282,89 @@ static bool test_SetPrinterDataEx(struct 
torture_context *tctx,
                "torture\\data,ex"
 #endif
        };
-       int i;
-       DATA_BLOB blob = data_blob_string_const("catfoobar");
+       enum winreg_Type types[] = {
+               REG_SZ,
+               REG_DWORD,
+               REG_BINARY
+       };
+       uint32_t value = 12345678;
+       const char *str = "abcdefghijklmnopqrstuvwxzy";
+       int i, t, s;
 
 
        for (i=0; i < ARRAY_SIZE(keys); i++) {
+       for (t=0; t < ARRAY_SIZE(types); t++) {
+       for (s=0; s < strlen(str); s++) {
 
                char *c;
                const char *key;
                enum winreg_Type type;
+               const char *string = talloc_strndup(tctx, str, s);
+               DATA_BLOB blob = data_blob_string_const(string);
                const char **subkeys;
                union spoolss_PrinterData data;
+               uint32_t needed, offered = 0;
 
-               r.in.handle = handle;
-               r.in.key_name = keys[i];
-               r.in.value_name = value_name;
-               r.in.type = REG_BINARY;
-               r.in.data.binary = blob;
+               if (types[t] == REG_DWORD) {
+                       s = 0xffff;
+               }
 
-               torture_comment(tctx, "Testing SetPrinterDataEx(%s - %s)\n", 
r.in.key_name, value_name);
+               switch (types[t]) {
+               case REG_BINARY:
+                       data.binary = blob;
+                       offered = blob.length;
+                       break;
+               case REG_DWORD:
+                       data.value = value;
+                       offered = 4;
+                       break;
+               case REG_SZ:
+                       data.string = string;
+                       offered = strlen_m_term(data.string)*2;
+                       break;
+               default:
+                       torture_fail(tctx, talloc_asprintf(tctx, "type %d 
untested\n", types[t]));
+               }
 
-               status = dcerpc_spoolss_SetPrinterDataEx(p, tctx, &r);
+               torture_assert(tctx,
+                       test_SetPrinterDataEx(tctx, p, handle, keys[i], 
value_name, types[t], &data, offered),
+                       "failed to call SetPrinterDataEx");
 
-               torture_assert_ntstatus_ok(tctx, status, "SetPrinterDataEx 
failed");
-               torture_assert_werr_ok(tctx, r.out.result, "SetPrinterDataEx 
failed");
+               if (!test_GetPrinterDataEx(tctx, p, handle, keys[i], 
value_name, &type, &data, &needed)) {
+                       return false;
+               }
 
-               key = talloc_strdup(tctx, r.in.key_name);
+               /* special case, a REG_BINARY set with 0 size returns a 0 sized
+                * REG_NONE - gd */
+               if ((types[t] == REG_BINARY) && (offered == 0)) {
+                       torture_assert_int_equal(tctx, REG_NONE, type, "type 
mismatch");
+               } else {
+                       torture_assert_int_equal(tctx, types[t], type, "type 
mismatch");
+               }
 
-               if (!test_GetPrinterDataEx(tctx, p, handle, r.in.key_name, 
value_name, &type, &data)) {
-                       return false;
+               switch (type) {
+               case REG_BINARY:
+                       torture_assert_data_blob_equal(tctx, blob, data.binary, 
"data mismatch");
+                       break;
+               case REG_DWORD:
+                       torture_assert_int_equal(tctx, value, data.value, "data 
mismatch");
+                       break;
+               case REG_SZ:
+                       torture_assert_str_equal(tctx, string, data.string, 
"data mismatch");
+                       break;
+               default:
+                       break;
                }
 
-               torture_assert_int_equal(tctx, r.in.type, type, "type 
mismatch");
-               torture_assert_data_blob_equal(tctx, blob, data.binary, "data 
mismatch");
+               torture_assert_int_equal(tctx, needed, offered, "size 
mismatch");
 
-               if (!test_EnumPrinterDataEx(tctx, p, handle, r.in.key_name)) {
+               key = talloc_strdup(tctx, keys[i]);
+
+               if (!test_EnumPrinterDataEx(tctx, p, handle, keys[i])) {
                        return false;
                }
 
-               if (!test_DeletePrinterDataEx(tctx, p, handle, r.in.key_name, 
value_name)) {
+               if (!test_DeletePrinterDataEx(tctx, p, handle, keys[i], 
value_name)) {
                        return false;
                }
 
@@ -3321,6 +3399,8 @@ static bool test_SetPrinterDataEx(struct torture_context 
*tctx,
                        }
                }
        }
+       }
+       }
 
        return true;
 }
@@ -3353,7 +3433,7 @@ static bool test_GetChangeID_PrinterDataEx(struct 
torture_context *tctx,
        union spoolss_PrinterData data;
 
        torture_assert(tctx,
-               test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", 
"ChangeID", &type, &data),
+               test_GetPrinterDataEx(tctx, p, handle, "PrinterDriverData", 
"ChangeID", &type, &data, NULL),
                "failed to call GetPrinterData");
 
        torture_assert(tctx, type == REG_DWORD, "unexpected type");
@@ -3734,7 +3814,7 @@ static bool test_OpenPrinterEx(struct torture_context 
*tctx,
                ret = false;
        }
 
-       if (!test_SetPrinterDataEx(tctx, p, &handle)) {
+       if (!test_SetPrinterDataEx_matrix(tctx, p, &handle)) {
                ret = false;
        }
 
@@ -4513,6 +4593,10 @@ static bool test_one_printer(struct torture_context 
*tctx,
                ret = false;
        }
 
+       if (!test_SetPrinterDataEx_matrix(tctx, p, handle)) {
+               ret = false;
+       }
+
        return ret;
 }
 


-- 
Samba Shared Repository

Reply via email to