summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorbubulle <bubulle@alioth.debian.org>2010-01-10 17:48:14 +0000
committerbubulle <bubulle@alioth.debian.org>2010-01-10 17:48:14 +0000
commit24d327ba0fd0f6c9192bb77c4423d6864b5421e4 (patch)
treea759ceae640d8cda02dc766b4b2e1e4cdff1457c /source4
parent33602026cf4cce11e018cffe3ddcb352250da1b9 (diff)
downloadsamba-24d327ba0fd0f6c9192bb77c4423d6864b5421e4.tar.gz
merge upstream 3.4.4~dfsg
git-svn-id: svn://svn.debian.org/svn/pkg-samba/trunk/samba@3218 fc4039ab-9d04-0410-8cac-899223bdd6b0
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/rpc/spoolss.c145
-rw-r--r--source4/torture/rpc/spoolss_win.c9
2 files changed, 151 insertions, 3 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index bfe667240c..d107616ef3 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -23,7 +23,9 @@
#include "includes.h"
#include "torture/torture.h"
#include "torture/rpc/rpc.h"
+#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "param/param.h"
struct test_spoolss_context {
/* print server handle */
@@ -2000,6 +2002,149 @@ static bool test_EnumPrinterDrivers_old(struct torture_context *tctx,
return true;
}
+static bool test_EnumPrinterKey(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle,
+ const char *key_name,
+ const char ***array)
+{
+ struct spoolss_EnumPrinterKey r;
+ uint32_t needed = 0;
+ union spoolss_KeyNames key_buffer;
+ int32_t offered[] = { 0, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 256, 512, 1024, 2048 };
+ uint32_t _ndr_size;
+ int i;
+
+ r.in.handle = handle;
+ r.in.key_name = key_name;
+ r.out.key_buffer = &key_buffer;
+ r.out.needed = &needed;
+ r.out._ndr_size = &_ndr_size;
+
+ for (i=0; i < ARRAY_SIZE(offered); i++) {
+
+ if (offered[i] < 0 && needed) {
+ if (needed <= 4) {
+ continue;
+ }
+ r.in.offered = needed + offered[i];
+ } else {
+ r.in.offered = offered[i];
+ }
+
+ ZERO_STRUCT(key_buffer);
+
+ 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, (_ndr_size == r.in.offered/2),
+ talloc_asprintf(tctx, "EnumPrinterKey size mismatch, _ndr_size %d (expected %d)",
+ _ndr_size, r.in.offered/2));
+
+ r.in.offered = needed;
+ torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterKey(p, tctx, &r),
+ "failed to call EnumPrinterKey");
+ }
+
+ if (offered[i] > 0) {
+ torture_assert_werr_ok(tctx, r.out.result,
+ "failed to call EnumPrinterKey");
+ }
+
+ torture_assert(tctx, (_ndr_size == r.in.offered/2),
+ talloc_asprintf(tctx, "EnumPrinterKey size mismatch, _ndr_size %d (expected %d)",
+ _ndr_size, r.in.offered/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 <= _ndr_size * 2),
+ talloc_asprintf(tctx, "EnumPrinterKey size mismatch: needed %d is not <= _ndr_size %d * 2", *r.out.needed, _ndr_size));
+
+ if (key_buffer.string_array) {
+ uint32_t calc_needed = 0;
+ int s;
+ for (s=0; key_buffer.string_array[s]; s++) {
+ calc_needed += strlen_m_term(key_buffer.string_array[s])*2;
+ }
+ if (!key_buffer.string_array[0]) {
+ calc_needed += 2;
+ }
+ calc_needed += 2;
+
+ torture_assert_int_equal(tctx, *r.out.needed, calc_needed,
+ "EnumPrinterKey unexpected size");
+ }
+ }
+
+ if (array) {
+ *array = key_buffer.string_array;
+ }
+
+ return true;
+}
+
+bool test_printer_keys(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
+{
+ const char **key_array = NULL;
+ int i;
+
+ {
+ struct spoolss_EnumPrinterKey r;
+ uint32_t needed;
+ struct spoolss_StringArray2 key_buffer;
+
+ r.in.handle = handle;
+ r.in.key_name = "";
+ r.in.offered = 0;
+ r.out.key_buffer = &key_buffer;
+ r.out.needed = &needed;
+
+ 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)) {
+ 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");
+
+ key_array = key_buffer.string;
+ }
+
+ for (i=0; key_array[i]; i++) {
+ struct spoolss_EnumPrinterDataEx r;
+ uint32_t count;
+ struct spoolss_PrinterEnumValues *info;
+ uint32_t needed;
+
+ r.in.handle = handle;
+ r.in.key_name = key_array[i];
+ r.in.offered = 0;
+ r.out.count = &count;
+ r.out.info = &info;
+ r.out.needed = &needed;
+
+ torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r),
+ "failed to call EnumPrinterDataEx");
+ if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+ r.in.offered = needed;
+ torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r),
+ "failed to call EnumPrinterDataEx");
+ }
+ torture_assert_werr_ok(tctx, r.out.result,
+ "failed to call EnumPrinterDataEx");
+ }
+
+ return true;
+}
+
bool torture_rpc_spoolss(struct torture_context *torture)
{
NTSTATUS status;
diff --git a/source4/torture/rpc/spoolss_win.c b/source4/torture/rpc/spoolss_win.c
index 719d8e26d2..77536e52fa 100644
--- a/source4/torture/rpc/spoolss_win.c
+++ b/source4/torture/rpc/spoolss_win.c
@@ -23,6 +23,7 @@
#include "torture/rpc/rpc.h"
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_server/dcerpc_server.h"
+#include "librpc/gen_ndr/ndr_misc.h"
#include "ntvfs/ntvfs.h"
#include "param/param.h"
@@ -177,7 +178,7 @@ static bool test_GetPrinterData(struct torture_context *tctx,
if (W_ERROR_IS_OK(expected_werr)) {
torture_assert_int_equal(tctx, data.value,
expected_value,
- "GetPrinterData did not return expected value.");
+ talloc_asprintf(tctx, "GetPrinterData for %s did not return expected value.", value_name));
}
return true;
}
@@ -385,7 +386,8 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
NTSTATUS status;
struct spoolss_EnumPrinterKey epk;
uint32_t needed = 0;
- const char **key_buffer = NULL;
+ union spoolss_KeyNames key_buffer;
+ uint32_t _ndr_size;
torture_comment(tctx, "Testing EnumPrinterKey(%s)\n", key);
@@ -394,6 +396,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
epk.in.offered = 0;
epk.out.needed = &needed;
epk.out.key_buffer = &key_buffer;
+ epk.out._ndr_size = &_ndr_size;
status = dcerpc_spoolss_EnumPrinterKey(p, tctx, &epk);
torture_assert_ntstatus_ok(tctx, status, "EnumPrinterKey failed");
@@ -408,7 +411,7 @@ static bool test_EnumPrinterKey(struct torture_context *tctx,
torture_assert_werr_ok(tctx, epk.out.result, "EnumPrinterKey failed");
- ctx->printer_keys = key_buffer;
+ ctx->printer_keys = key_buffer.string_array;
return true;
}