The branch, master has been updated
       via  1e897f6... s4-smbtorture: add "printerdata_values" test to 
RPC-SPOOLSS-PRINTER.
       via  13ede2b... s4-smbtorture: also test keynames with '/' in it in 
SetPrinterDataEx keyname tests.
       via  e439b6c... s4-smbtorture: activate all keys in SetPrinterData keys 
test.
       via  c31ffaf... s4-smbtorture: split out a "printerdata_keys" test for 
RPC-SPOOLSS-PRINTER.
      from  df96f18... testprogs/win32: add prepare_dcpromo tool

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


- Log -----------------------------------------------------------------
commit 1e897f656104f29769b204dc443f1684395d8173
Author: Günther Deschner <[email protected]>
Date:   Tue Jun 22 15:45:45 2010 +0200

    s4-smbtorture: add "printerdata_values" test to RPC-SPOOLSS-PRINTER.
    
    Guenther

commit 13ede2bf7a75b2b52132954684f23ad5a89a83a1
Author: Günther Deschner <[email protected]>
Date:   Tue Jun 22 15:25:01 2010 +0200

    s4-smbtorture: also test keynames with '/' in it in SetPrinterDataEx 
keyname tests.
    
    Guenther

commit e439b6cb8ceb01d930bd8ec2d7b9c79ebca5647e
Author: Günther Deschner <[email protected]>
Date:   Tue Jun 22 15:22:03 2010 +0200

    s4-smbtorture: activate all keys in SetPrinterData keys test.
    
    (just skip some of them still against s3).
    
    Guenther

commit c31ffaf5872292c610394406cf8e8ce61d8439c5
Author: Günther Deschner <[email protected]>
Date:   Tue Jun 22 14:55:20 2010 +0200

    s4-smbtorture: split out a "printerdata_keys" test for RPC-SPOOLSS-PRINTER.
    
    This separates key and value tests for SetPrinterDataEx and GetPrinterDataEx
    (and also speeds up the whole testsuite).
    
    Guenther

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

Summary of changes:
 source4/torture/rpc/spoolss.c |  287 ++++++++++++++++++++++++++++++++---------
 1 files changed, 226 insertions(+), 61 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index e61adfe..a797e24 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -4797,36 +4797,210 @@ static bool test_SetPrinterDataEx(struct 
torture_context *tctx,
        return true;
 }
 
-static bool test_SetPrinterDataEx_matrix(struct torture_context *tctx,
-                                        struct dcerpc_pipe *p,
-                                        struct policy_handle *handle,
-                                        const char *printername,
-                                        struct dcerpc_binding_handle 
*winreg_handle,
-                                        struct policy_handle *hive_handle)
+static bool test_SetPrinterDataEx_keys(struct torture_context *tctx,
+                                      struct dcerpc_pipe *p,
+                                      struct policy_handle *handle)
 {
        struct dcerpc_binding_handle *b = p->binding_handle;
        const char *value_name = "dog";
        const char *keys[] = {
                "torturedataex",
                "torture data ex",
-#if 0
-       /* FIXME: not working with s3 atm. */
                "torturedataex_with_subkey\\subkey",
                "torturedataex_with_subkey\\subkey:0",
                "torturedataex_with_subkey\\subkey:1",
                "torturedataex_with_subkey\\subkey\\subsubkey",
                "torturedataex_with_subkey\\subkey\\subsubkey:0",
                "torturedataex_with_subkey\\subkey\\subsubkey:1",
-#endif
                "torture,data",
-#if 0
-       /* FIXME: not working with s3 atm. */
-
                "torture,data,ex",
                "torture,data\\ex",
-               "torture\\data,ex"
-#endif
+               "torture\\data,ex",
+               "torture/data",
+               "torture/data ex",
+               "torture/data ex/sub",
+               "torture//data",
+               "torture//data ex",
+               "torture//data ex/sub",
+               "torture//data ex//sub",
+       };
+       int i;
+
+       for (i=0; i < ARRAY_SIZE(keys); i++) {
+
+               char *c;
+               const char *key;
+               enum winreg_Type type;
+               DATA_BLOB blob_in, blob_out;
+               const char **subkeys;
+               uint32_t ecount;
+               struct spoolss_PrinterEnumValues *einfo;
+               uint32_t needed;
+
+               if (torture_setting_bool(tctx, "samba3", false)) {
+                       char *q;
+                       q = strrchr(keys[i], '\\');
+                       if (q) {
+                               torture_skip(tctx,
+                                       talloc_asprintf(tctx, "skipping keyname 
'%s' including '\\' character against Samba3\n",
+                                               keys[i]));
+                       }
+               }
+
+               blob_in = data_blob_talloc(tctx, NULL, 42);
+
+               generate_random_buffer(blob_in.data, blob_in.length);
+
+               torture_assert(tctx,
+                       test_SetPrinterDataEx(tctx, b, handle, keys[i], 
value_name, REG_BINARY, blob_in.data, blob_in.length),
+                       "failed to call SetPrinterDataEx");
+
+               torture_assert(tctx,
+                       test_GetPrinterDataEx(tctx, p, handle, keys[i], 
value_name, &type, &blob_out.data, &needed),
+                       "failed to call GetPrinterDataEx");
+
+               blob_out.length = needed;
+               torture_assert(tctx,
+                       test_EnumPrinterDataEx(tctx, b, handle, keys[i], 
&ecount, &einfo),
+                       "failed to call EnumPrinterDataEx");
+
+               torture_assert_int_equal(tctx, type, REG_BINARY, "type 
mismatch");
+               torture_assert_int_equal(tctx, blob_out.length, blob_in.length, 
"size mismatch");
+               torture_assert_mem_equal(tctx, blob_out.data, blob_in.data, 
blob_in.length, "buffer mismatch");
+
+               torture_assert_int_equal(tctx, ecount, 1, "unexpected enum 
count");
+               torture_assert_str_equal(tctx, einfo[0].value_name, value_name, 
"value_name mismatch");
+               torture_assert_int_equal(tctx, einfo[0].value_name_len, 
strlen_m_term(value_name)*2, "unexpected value_name_len");
+               torture_assert_int_equal(tctx, einfo[0].type, REG_BINARY, "type 
mismatch");
+               torture_assert_int_equal(tctx, einfo[0].data_length, 
blob_in.length, "size mismatch");
+               if (einfo[0].data_length > 0) {
+                       torture_assert_mem_equal(tctx, einfo[0].data->data, 
blob_in.data, blob_in.length, "buffer mismatch");
+               }
+
+               key = talloc_strdup(tctx, keys[i]);
+
+               if (!test_DeletePrinterDataEx(tctx, b, handle, keys[i], 
value_name)) {
+                       return false;
+               }
+
+               c = strchr(key, '\\');
+               if (c) {
+                       int k;
+
+                       /* we have subkeys */
+
+                       *c = 0;
+
+                       if (!test_EnumPrinterKey(tctx, b, handle, key, 
&subkeys)) {
+                               return false;
+                       }
+
+                       for (k=0; subkeys && subkeys[k]; k++) {
+
+                               const char *current_key = talloc_asprintf(tctx, 
"%s\\%s", key, subkeys[k]);
+
+                               if (!test_DeletePrinterKey(tctx, b, handle, 
current_key)) {
+                                       return false;
+                               }
+                       }
+
+                       if (!test_DeletePrinterKey(tctx, b, handle, key)) {
+                               return false;
+                       }
+
+               } else {
+                       if (!test_DeletePrinterKey(tctx, b, handle, key)) {
+                               return false;
+                       }
+               }
+       }
+
+       return true;
+}
+
+static bool test_SetPrinterDataEx_values(struct torture_context *tctx,
+                                        struct dcerpc_pipe *p,
+                                        struct policy_handle *handle)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       const char *key = "torturedataex";
+       const char *values[] = {
+               "torture_value",
+               "torture value",
+               "torture,value",
+               "torture/value",
+               "torture\\value",
+               "torture\\\\value"
        };
+       int i;
+
+       for (i=0; i < ARRAY_SIZE(values); i++) {
+
+               enum winreg_Type type;
+               DATA_BLOB blob_in, blob_out;
+               uint32_t ecount;
+               struct spoolss_PrinterEnumValues *einfo;
+               uint32_t needed;
+
+               if (torture_setting_bool(tctx, "samba3", false)) {
+                       char *q;
+                       q = strrchr(values[i], ',');
+                       if (q) {
+                               torture_skip(tctx,
+                                       talloc_asprintf(tctx, "skipping 
valuename '%s' including ',' character against Samba3\n",
+                                               values[i]));
+                       }
+               }
+
+               blob_in = data_blob_talloc(tctx, NULL, 42);
+
+               generate_random_buffer(blob_in.data, blob_in.length);
+
+               torture_assert(tctx,
+                       test_SetPrinterDataEx(tctx, b, handle, key, values[i], 
REG_BINARY, blob_in.data, blob_in.length),
+                       "failed to call SetPrinterDataEx");
+
+               torture_assert(tctx,
+                       test_GetPrinterDataEx(tctx, p, handle, key, values[i], 
&type, &blob_out.data, &needed),
+                       "failed to call GetPrinterDataEx");
+
+               blob_out.length = needed;
+               torture_assert(tctx,
+                       test_EnumPrinterDataEx(tctx, b, handle, key, &ecount, 
&einfo),
+                       "failed to call EnumPrinterDataEx");
+
+               torture_assert_int_equal(tctx, type, REG_BINARY, "type 
mismatch");
+               torture_assert_int_equal(tctx, blob_out.length, blob_in.length, 
"size mismatch");
+               torture_assert_mem_equal(tctx, blob_out.data, blob_in.data, 
blob_in.length, "buffer mismatch");
+
+               torture_assert_int_equal(tctx, ecount, 1, "unexpected enum 
count");
+               torture_assert_str_equal(tctx, einfo[0].value_name, values[i], 
"value_name mismatch");
+               torture_assert_int_equal(tctx, einfo[0].value_name_len, 
strlen_m_term(values[i])*2, "unexpected value_name_len");
+               torture_assert_int_equal(tctx, einfo[0].type, REG_BINARY, "type 
mismatch");
+               torture_assert_int_equal(tctx, einfo[0].data_length, 
blob_in.length, "size mismatch");
+               if (einfo[0].data_length > 0) {
+                       torture_assert_mem_equal(tctx, einfo[0].data->data, 
blob_in.data, blob_in.length, "buffer mismatch");
+               }
+
+               torture_assert(tctx,
+                       test_DeletePrinterDataEx(tctx, b, handle, key, 
values[i]),
+                       "failed to call DeletePrinterDataEx");
+       }
+
+       return true;
+}
+
+
+static bool test_SetPrinterDataEx_matrix(struct torture_context *tctx,
+                                        struct dcerpc_pipe *p,
+                                        struct policy_handle *handle,
+                                        const char *printername,
+                                        struct dcerpc_binding_handle 
*winreg_handle,
+                                        struct policy_handle *hive_handle)
+{
+       struct dcerpc_binding_handle *b = p->binding_handle;
+       const char *value_name = "dog";
+       const char *key_name = "torturedataex";
        enum winreg_Type types[] = {
                REG_SZ,
                REG_MULTI_SZ,
@@ -4834,20 +5008,15 @@ static bool test_SetPrinterDataEx_matrix(struct 
torture_context *tctx,
                REG_BINARY
        };
        const char *str = "abcdefghi";
-       int i, t, s;
-
+       int 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);
                const char *array[2];
                DATA_BLOB blob = data_blob_string_const(string);
-               const char **subkeys;
                DATA_BLOB data;
                uint8_t *data_out;
                uint32_t needed, offered = 0;
@@ -4894,15 +5063,15 @@ static bool test_SetPrinterDataEx_matrix(struct 
torture_context *tctx,
                }
 
                torture_assert(tctx,
-                       test_SetPrinterDataEx(tctx, b, handle, keys[i], 
value_name, types[t], data.data, offered),
+                       test_SetPrinterDataEx(tctx, b, handle, key_name, 
value_name, types[t], data.data, offered),
                        "failed to call SetPrinterDataEx");
 
                torture_assert(tctx,
-                       test_GetPrinterDataEx(tctx, p, handle, keys[i], 
value_name, &type, &data_out, &needed),
+                       test_GetPrinterDataEx(tctx, p, handle, key_name, 
value_name, &type, &data_out, &needed),
                        "failed to call GetPrinterDataEx");
 
                torture_assert(tctx,
-                       test_EnumPrinterDataEx(tctx, b, handle, keys[i], 
&ecount, &einfo),
+                       test_EnumPrinterDataEx(tctx, b, handle, key_name, 
&ecount, &einfo),
                        "failed to call EnumPrinterDataEx");
 
                torture_assert_int_equal(tctx, types[t], type, "type mismatch");
@@ -4926,7 +5095,7 @@ static bool test_SetPrinterDataEx_matrix(struct 
torture_context *tctx,
 
                        torture_assert(tctx,
                                test_winreg_query_printerdata(tctx, 
winreg_handle, hive_handle,
-                                       printername, keys[i], value_name,
+                                       printername, key_name, value_name,
                                        &w_type, &w_size, &w_length, &w_data), 
"");
 
                        torture_assert_int_equal(tctx, w_type, types[t], 
"winreg type mismatch");
@@ -4935,43 +5104,9 @@ static bool test_SetPrinterDataEx_matrix(struct 
torture_context *tctx,
                        torture_assert_mem_equal(tctx, w_data, data.data, 
offered, "winreg buffer mismatch");
                }
 
-               key = talloc_strdup(tctx, keys[i]);
-
-               if (!test_DeletePrinterDataEx(tctx, b, handle, keys[i], 
value_name)) {
-                       return false;
-               }
-
-               c = strchr(key, '\\');
-               if (c) {
-                       int k;
-
-                       /* we have subkeys */
-
-                       *c = 0;
-
-                       if (!test_EnumPrinterKey(tctx, b, handle, key, 
&subkeys)) {
-                               return false;
-                       }
-
-                       for (k=0; subkeys && subkeys[k]; k++) {
-
-                               const char *current_key = talloc_asprintf(tctx, 
"%s\\%s", key, subkeys[k]);
-
-                               if (!test_DeletePrinterKey(tctx, b, handle, 
current_key)) {
-                                       return false;
-                               }
-                       }
-
-                       if (!test_DeletePrinterKey(tctx, b, handle, key)) {
-                               return false;
-                       }
-
-               } else {
-                       if (!test_DeletePrinterKey(tctx, b, handle, key)) {
-                               return false;
-                       }
-               }
-       }
+               torture_assert(tctx,
+                       test_DeletePrinterDataEx(tctx, b, handle, key_name, 
value_name),
+                       "failed to call DeletePrinterDataEx");
        }
        }
 
@@ -7158,6 +7293,34 @@ static bool test_printer_data_consistency(struct 
torture_context *tctx,
        return true;
 }
 
+static bool test_printer_data_keys(struct torture_context *tctx,
+                                  void *private_data)
+{
+       struct torture_printer_context *t =
+               (struct torture_printer_context 
*)talloc_get_type_abort(private_data, struct torture_printer_context);
+       struct dcerpc_pipe *p = t->spoolss_pipe;
+
+       torture_assert(tctx,
+               test_SetPrinterDataEx_keys(tctx, p, &t->handle),
+               "failed to test printer data keys");
+
+       return true;
+}
+
+static bool test_printer_data_values(struct torture_context *tctx,
+                                    void *private_data)
+{
+       struct torture_printer_context *t =
+               (struct torture_printer_context 
*)talloc_get_type_abort(private_data, struct torture_printer_context);
+       struct dcerpc_pipe *p = t->spoolss_pipe;
+
+       torture_assert(tctx,
+               test_SetPrinterDataEx_values(tctx, p, &t->handle),
+               "failed to test printer data values");
+
+       return true;
+}
+
 static bool test_printer_data_set(struct torture_context *tctx,
                                  void *private_data)
 {
@@ -7231,6 +7394,8 @@ void torture_tcase_printer(struct torture_tcase *tcase)
        torture_tcase_add_simple_test(tcase, "change_id", 
test_printer_change_id);
        torture_tcase_add_simple_test(tcase, "keys", test_printer_keys);
        torture_tcase_add_simple_test(tcase, "printerdata_consistency", 
test_printer_data_consistency);
+       torture_tcase_add_simple_test(tcase, "printerdata_keys", 
test_printer_data_keys);
+       torture_tcase_add_simple_test(tcase, "printerdata_values", 
test_printer_data_values);
        torture_tcase_add_simple_test(tcase, "printerdata_set", 
test_printer_data_set);
        torture_tcase_add_simple_test(tcase, "printerdata_winreg", 
test_printer_data_winreg);
        torture_tcase_add_simple_test(tcase, "printerdata_dsspooler", 
test_printer_data_dsspooler);


-- 
Samba Shared Repository

Reply via email to