torture: Add ntprinting latin1 test.
authorAndreas Schneider <asn@samba.org>
Thu, 14 Mar 2013 06:29:20 +0000 (07:29 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 15 Mar 2013 11:11:03 +0000 (12:11 +0100)
Reviewed-by: Günther Deschner <gd@samba.org>
source4/torture/ndr/ntprinting.c

index 44ad86b7aceacf2005ff5e2ff65b136cac944bcb..3ff9cb12eee43a068c9ad012b79e003b5c8e27a6 100644 (file)
@@ -22,6 +22,7 @@
 #include "torture/ndr/ndr.h"
 #include "librpc/gen_ndr/ndr_ntprinting.h"
 #include "torture/ndr/proto.h"
+#include "param/param.h"
 
 static const uint8_t ntprinting_printer_data[] = {
        0x48, 0x10, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
@@ -296,6 +297,170 @@ static const uint8_t ntprinting_printer_data[] = {
        0x00, 0x00, 0x00, 0x00, 0x00
 };
 
+static const uint8_t ntprinting_printer_data_latin1[] = {
+       0x48, 0x1a, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+       0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x94, 0x46, 0x50, 0x0e, 0x00, 0x00, 0x00, 0x00,
+       0x94, 0xee, 0xb9, 0x50, 0x00, 0x53, 0x30, 0x42,
+       0x43, 0x00, 0x53, 0x30, 0x42, 0x43, 0x00, 0x53,
+       0x61, 0x6d, 0x62, 0x61, 0x20, 0x50, 0x72, 0x69,
+       0x6e, 0x74, 0x65, 0x72, 0x20, 0x50, 0x6f, 0x72,
+       0x74, 0x00, 0x48, 0x50, 0x20, 0x44, 0x65, 0x73,
+       0x69, 0x67, 0x6e, 0x6a, 0x65, 0x74, 0x20, 0x38,
+       0x30, 0x30, 0x50, 0x53, 0x20, 0x34, 0x32, 0x20,
+       0x62, 0x79, 0x20, 0x48, 0x50, 0x00, 0x22, 0x20,
+       0x53, 0x41, 0x4c, 0x41, 0x20, 0x44, 0x41, 0x20,
+       0x52, 0x45, 0x43, 0x45, 0x50, 0xc7, 0xc3, 0x4f,
+       0x20, 0x44, 0x41, 0x20, 0x43, 0x4f, 0x4e, 0x53,
+       0x54, 0x52, 0x55, 0xc7, 0xc3, 0x4f, 0x20, 0x2d,
+       0x20, 0x52, 0x41, 0x4e, 0x44, 0x30, 0x20, 0x4c,
+       0x4f, 0x43, 0x41, 0x54, 0x49, 0x4f, 0x00, 0x55,
+       0x54, 0x47, 0x43, 0x41, 0x20, 0x00, 0x00, 0x77,
+       0x69, 0x6e, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x00,
+       0x52, 0x41, 0x57, 0x00, 0x00, 0x01, 0x00, 0x00,
+       0x00, 0x5c, 0x5c, 0x4c, 0x4f, 0x43, 0x41, 0x4c,
+       0x48, 0x4f, 0x53, 0x54, 0x5c, 0x53, 0x30, 0x42,
+       0x43, 0x00, 0x4c, 0x65, 0x74, 0x74, 0x65, 0x72,
+       0x00, 0x01, 0x04, 0x00, 0x04, 0xdc, 0x00, 0x00,
+       0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x64, 0x00, 0x01, 0x00, 0x0f, 0x00, 0xfc,
+       0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x47, 0x01,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x01, 0x00, 0x00, 0x00, 0x50, 0x72, 0x69,
+       0x6e, 0x74, 0x65, 0x72, 0x44, 0x72, 0x69, 0x76,
+       0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+       0x00, 0x00, 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74,
+       0x65, 0x72, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72,
+       0x44, 0x61, 0x74, 0x61, 0x5c, 0x44, 0x72, 0x76,
+       0x50, 0x61, 0x70, 0x65, 0x72, 0x53, 0x74, 0x61,
+       0x6e, 0x64, 0x61, 0x72, 0x64, 0x73, 0x00, 0x04,
+       0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x61,
+       0xc2, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0x50,
+       0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x44, 0x72,
+       0x69, 0x76, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61,
+       0x5c, 0x44, 0x72, 0x76, 0x44, 0x65, 0x76, 0x4d,
+       0x6f, 0x64, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00,
+       0x42, 0x02, 0x00, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x36, 0x00,
+       0x36, 0x00, 0x3b, 0x00, 0x2d, 0x00, 0x33, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x31, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x30, 0x00, 0x37, 0x00, 0x33, 0x00,
+       0x37, 0x00, 0x34, 0x00, 0x31, 0x00, 0x39, 0x00,
+       0x30, 0x00, 0x35, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x35, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x35, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x36, 0x00,
+       0x32, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x30, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x36, 0x00,
+       0x37, 0x00, 0x37, 0x00, 0x37, 0x00, 0x32, 0x00,
+       0x31, 0x00, 0x36, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x36, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x36, 0x00, 0x35, 0x00,
+       0x35, 0x00, 0x33, 0x00, 0x35, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x36, 0x00, 0x33, 0x00, 0x31, 0x00,
+       0x37, 0x00, 0x32, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x31, 0x00,
+       0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x37, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x3b, 0x00, 0x31, 0x00, 0x3b, 0x00,
+       0x30, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x3b, 0x00,
+       0x31, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00,
+       0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00,
+       0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00,
+       0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00,
+       0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00,
+       0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00,
+       0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00,
+       0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00,
+       0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x32, 0x00, 0x31, 0x00,
+       0x35, 0x00, 0x39, 0x00, 0x3b, 0x00, 0x32, 0x00,
+       0x37, 0x00, 0x39, 0x00, 0x34, 0x00, 0x3b, 0x00,
+       0x32, 0x00, 0x31, 0x00, 0x35, 0x00, 0x39, 0x00,
+       0x3b, 0x00, 0x32, 0x00, 0x37, 0x00, 0x39, 0x00,
+       0x34, 0x00, 0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00,
+       0x3b, 0x00, 0x3b, 0x00, 0x3b, 0x00, 0x3b, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x31, 0x00, 0x30, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x30, 0x00, 0x3b, 0x00, 0x30, 0x00,
+       0x3b, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x01, 0x00,
+       0x00, 0x00, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x65,
+       0x72, 0x44, 0x72, 0x69, 0x76, 0x65, 0x72, 0x44,
+       0x61, 0x74, 0x61, 0x5c, 0x44, 0x72, 0x76, 0x45,
+       0x57, 0x53, 0x49, 0x50, 0x00, 0x01, 0x00, 0x00,
+       0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+       0x00, 0x00, 0x00, 0x44, 0x73, 0x53, 0x70, 0x6f,
+       0x6f, 0x6c, 0x65, 0x72, 0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
+       0x00, 0x44, 0x73, 0x53, 0x70, 0x6f, 0x6f, 0x6c,
+       0x65, 0x72, 0x5c, 0x70, 0x72, 0x69, 0x6e, 0x74,
+       0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x00, 0x01,
+       0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x53,
+       0x00, 0x30, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00,
+       0x00, 0x01, 0x00, 0x00, 0x00, 0x44, 0x73, 0x53,
+       0x70, 0x6f, 0x6f, 0x6c, 0x65, 0x72, 0x5c, 0x73,
+       0x65, 0x72, 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d,
+       0x65, 0x00, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00,
+       0x00, 0x00, 0x53, 0x00, 0x36, 0x00, 0x30, 0x00,
+       0x32, 0x00, 0x30, 0x00, 0x50, 0x00, 0x53, 0x00,
+       0x36, 0x00, 0x36, 0x00, 0x00, 0x00, 0x01, 0x00,
+       0x00, 0x00, 0x44, 0x73, 0x53, 0x70, 0x6f, 0x6f,
+       0x6c, 0x65, 0x72, 0x5c, 0x73, 0x68, 0x6f, 0x72,
+       0x74, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4e,
+       0x61, 0x6d, 0x65, 0x00, 0x01, 0x00, 0x00, 0x00,
+       0x14, 0x00, 0x00, 0x00, 0x53, 0x00, 0x36, 0x00,
+       0x30, 0x00, 0x32, 0x00, 0x30, 0x00, 0x50, 0x00,
+       0x53, 0x00, 0x36, 0x00, 0x36, 0x00, 0x00, 0x00,
+       0x01, 0x00, 0x00, 0x00, 0x44, 0x73, 0x53, 0x70,
+       0x6f, 0x6f, 0x6c, 0x65, 0x72, 0x5c, 0x75, 0x4e,
+       0x43, 0x4e, 0x61, 0x6d, 0x65, 0x00, 0x01, 0x00,
+       0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x5c, 0x00,
+       0x5c, 0x00, 0x53, 0x00, 0x36, 0x00, 0x30, 0x00,
+       0x32, 0x00, 0x30, 0x00, 0x50, 0x00, 0x53, 0x00,
+       0x36, 0x00, 0x36, 0x00, 0x5c, 0x00, 0x53, 0x00,
+       0x30, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00
+};
+
 static bool ntprinting_printer_check(struct torture_context *tctx,
                                     struct ntprinting_printer *r)
 {
@@ -421,10 +586,62 @@ static bool ntprinting_printer_check(struct torture_context *tctx,
        return true;
 }
 
+static bool ntprinting_printer_latin1_check(struct torture_context *tctx)
+{
+       enum ndr_err_code ndr_err;
+       struct ntprinting_printer r;
+       DATA_BLOB blob;
+       bool ok;
+
+       ok = lpcfg_do_global_parameter(tctx->lp_ctx, "dos charset", "CP1252");
+       if (!ok) {
+               torture_comment(tctx, "Could not set 'dos charset' option.\n");
+               return false;
+       }
+       reload_charcnv(tctx->lp_ctx);
+
+       ZERO_STRUCT(r);
+       r.info.string_flags = LIBNDR_FLAG_STR_ASCII;
+
+       blob = data_blob_const(ntprinting_printer_data_latin1,
+                              sizeof(ntprinting_printer_data_latin1));
+
+       ndr_err = ndr_pull_struct_blob(&blob, tctx, &r,
+                  (ndr_pull_flags_fn_t)ndr_pull_ntprinting_printer);
+
+       torture_assert_ndr_success(tctx,
+                                  ndr_err,
+                                  "ndr_pull_ntprinting_printer");
+#if 0
+       ndr_print_debug((ndr_print_fn_t) ndr_print_ntprinting_printer,
+                       "ntprinter",
+                       &r);
+#endif
+       torture_assert_str_equal(tctx,
+                                r.info.printername,
+                                "S0BC",
+                                "printername");
+       /* latin1 encoding check */
+       torture_assert_str_equal(tctx,
+                                r.info.comment,
+                                "\" SALA DA RECEPÇÃO DA CONSTRUÇÃO - RAND0 LOCATIO",
+                                "comment");
+       torture_assert_str_equal(tctx,
+                                r.info.location,
+                                "UTGCA ",
+                                "location");
+
+       return true;
+}
+
 struct torture_suite *ndr_ntprinting_suite(TALLOC_CTX *ctx)
 {
        struct torture_suite *suite = torture_suite_create(ctx, "ntprinting");
 
+       torture_suite_add_simple_test(suite,
+                                     "ntprinting latin1 check",
+                                     ntprinting_printer_latin1_check);
+
        torture_suite_add_ndr_pull_test(suite,
                                        ntprinting_printer,
                                        ntprinting_printer_data,