summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2010-04-28 13:34:31 +0200
committerGünther Deschner <gd@samba.org>2010-04-28 15:11:41 +0200
commita53b09141cd57d7dc94bd0d0e05d7d25ee110857 (patch)
tree43c7a61613009beeaf3767e54abad1399602081f /source4/torture
parenteed665d653828832ec57642126c4040c47dd6e90 (diff)
downloadsamba-a53b09141cd57d7dc94bd0d0e05d7d25ee110857.tar.gz
samba-a53b09141cd57d7dc94bd0d0e05d7d25ee110857.tar.bz2
samba-a53b09141cd57d7dc94bd0d0e05d7d25ee110857.zip
s4-smbtorture: start on a test to verify how SetPrinter changes DsSpooler Printer Data.
Guenther
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/spoolss.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 674682b6ab..4aa52e96be 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -4953,6 +4953,90 @@ static bool test_DriverInfo_winreg(struct torture_context *tctx,
return ret;
}
+static bool test_PrinterData_DsSpooler(struct torture_context *tctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle,
+ const char *printer_name)
+{
+ struct spoolss_SetPrinterInfoCtr info_ctr;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct sec_desc_buf secdesc_ctr;
+ union spoolss_SetPrinterInfo sinfo;
+ union spoolss_PrinterInfo info;
+ struct dcerpc_binding_handle *b = p->binding_handle;
+
+ ZERO_STRUCT(info_ctr);
+ ZERO_STRUCT(devmode_ctr);
+ ZERO_STRUCT(secdesc_ctr);
+
+ torture_comment(tctx, "Testing DsSpooler <-> SetPrinter relations\n");
+
+ torture_assert(tctx,
+ test_GetPrinter_level(tctx, b, handle, 2, &info),
+ "failed to query Printer level 2");
+
+ torture_assert(tctx,
+ PrinterInfo_to_SetPrinterInfo(tctx, &info, 2, &sinfo),
+ "failed to convert");
+
+ info_ctr.level = 2;
+ info_ctr.info = sinfo;
+
+#define TEST_SET_SZ(wname, iname, val) \
+do {\
+ enum winreg_Type type;\
+ uint8_t *data;\
+ uint32_t needed;\
+ DATA_BLOB blob;\
+ const char *str;\
+ sinfo.info2->iname = val;\
+ torture_assert(tctx,\
+ test_SetPrinter(tctx, b, handle, &info_ctr, &devmode_ctr, &secdesc_ctr, 0),\
+ "failed to call SetPrinter");\
+ torture_assert(tctx,\
+ test_GetPrinterDataEx(tctx, p, handle, "DsSpooler", wname, &type, &data, &needed),\
+ "failed to query");\
+ torture_assert_int_equal(tctx, type, REG_SZ, "unexpected type");\
+ blob = data_blob_const(data, needed);\
+ torture_assert(tctx,\
+ pull_reg_sz(tctx, lp_iconv_convenience(tctx->lp_ctx), &blob, &str),\
+ "failed to pull REG_SZ");\
+ torture_assert_str_equal(tctx, str, val, "unexpected result");\
+} while(0);
+
+#define TEST_SET_DWORD(wname, iname, val) \
+do {\
+ enum winreg_Type type;\
+ uint8_t *data;\
+ uint32_t needed;\
+ uint32_t value;\
+ sinfo.info2->iname = val;\
+ torture_assert(tctx,\
+ test_SetPrinter(tctx, b, handle, &info_ctr, &devmode_ctr, &secdesc_ctr, 0),\
+ "failed to call SetPrinter");\
+ torture_assert(tctx,\
+ test_GetPrinterDataEx(tctx, p, handle, "DsSpooler", wname, &type, &data, &needed),\
+ "failed to query");\
+ torture_assert_int_equal(tctx, type, REG_DWORD, "unexpected type");\
+ torture_assert_int_equal(tctx, needed, 4, "unexpected length");\
+ value = IVAL(data, 0); \
+ torture_assert_int_equal(tctx, value, val, "unexpected result");\
+} while(0);
+
+ TEST_SET_SZ("description", comment, "newval");
+ TEST_SET_SZ("location", location, "newval");
+/* TEST_SET_DWORD("priority", priority, 25); */
+
+ /* FIXME gd: complete the list */
+
+#undef TEST_SET_SZ
+#undef TEST_DWORD
+
+ torture_comment(tctx, "DsSpooler <-> SetPrinter relations test succeeded\n\n");
+
+ return true;
+}
+
static bool test_GetChangeID_PrinterData(struct torture_context *tctx,
struct dcerpc_binding_handle *b,
struct policy_handle *handle,
@@ -6252,6 +6336,10 @@ static bool test_one_printer(struct torture_context *tctx,
ret = false;
}
+ if (!test_PrinterData_DsSpooler(tctx, p, handle, name)) {
+ ret = false;
+ }
+
if (have_driver) {
if (!test_DriverInfo_winreg(tctx, p, handle, name, drivername, environment)) {
ret = false;