summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorJustin Stephenson <jstephen@redhat.com>2018-08-23 13:16:40 -0400
committerBjoern Jacke <bjacke@samba.org>2019-01-28 15:44:18 +0100
commite2eadf9a926b3d627ff8cda72a5a142655a210e6 (patch)
treeafd799cd7a2e0348864018ad480c5aede222da5e /source4/torture
parented209cfee37cbc63efab925bc44c2b384417cc9b (diff)
downloadsamba-e2eadf9a926b3d627ff8cda72a5a142655a210e6.tar.gz
s4:torture: Share test iremotewinspool functions
Create iremotewinspool_common.c and iremotewinspool_common.h to make test functions available for additional tests Signed-off-by: Justin Stephenson <jstephen@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Bjoern Jacke <bjacke@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/rpc/iremotewinspool.c213
-rw-r--r--source4/torture/rpc/iremotewinspool_common.c188
-rw-r--r--source4/torture/rpc/iremotewinspool_common.h72
-rw-r--r--source4/torture/wscript_build6
4 files changed, 267 insertions, 212 deletions
diff --git a/source4/torture/rpc/iremotewinspool.c b/source4/torture/rpc/iremotewinspool.c
index b4dbe71160e..03613b443e3 100644
--- a/source4/torture/rpc/iremotewinspool.c
+++ b/source4/torture/rpc/iremotewinspool.c
@@ -25,218 +25,7 @@
#include "librpc/gen_ndr/ndr_spoolss_c.h"
#include "torture/rpc/torture_rpc.h"
#include "libcli/registry/util_reg.h"
-
-struct test_iremotewinspool_context {
- struct GUID object_uuid;
- struct dcerpc_pipe *iremotewinspool_pipe;
- struct policy_handle server_handle;
- const char *environment;
-};
-
-enum client_os_version
-{
- WIN_2000,
- WIN_VISTA,
- WIN_SERVER_2008,
- WIN_7,
- WIN_SERVER_2008R2,
- WIN_8,
- WIN_SERVER_2012,
- WIN_10,
- WIN_SERVER_2016
-};
-
-static struct spoolss_UserLevel1 test_get_client_info(struct torture_context *tctx,
- enum client_os_version os,
- enum spoolss_MajorVersion major_number,
- enum spoolss_MinorVersion minor_number)
-{
- struct spoolss_UserLevel1 level1;
-
- level1.size = 28;
- level1.client = talloc_asprintf(tctx, "\\\\%s", "mthelena");
- level1.user = "GD";
- level1.processor = PROCESSOR_ARCHITECTURE_AMD64;
- level1.major = major_number;
- level1.minor = minor_number;
-
- switch (os) {
- case WIN_SERVER_2016:
- case WIN_10:
- level1.build = 10586;
- break;
- case WIN_SERVER_2012:
- case WIN_8:
- level1.build = 9200;
- break;
- case WIN_SERVER_2008R2:
- case WIN_7:
- level1.build = 7007;
- break;
- case WIN_SERVER_2008:
- case WIN_VISTA:
- level1.build = 6000;
- break;
- case WIN_2000:
- level1.build = 1382;
- break;
- default:
- level1.build = 7007;
- }
-
- return level1;
-}
-
-static bool test_AsyncOpenPrinter_byprinter(struct torture_context *tctx,
- struct test_iremotewinspool_context *ctx,
- struct dcerpc_pipe *p,
- const char *printer_name,
- struct spoolss_UserLevel1 cinfo,
- struct policy_handle *handle)
-{
- struct dcerpc_binding_handle *b = p->binding_handle;
- struct spoolss_DevmodeContainer devmode_ctr;
- struct spoolss_UserLevelCtr client_info_ctr;
- uint32_t access_mask = SERVER_ALL_ACCESS;
- struct winspool_AsyncOpenPrinter r;
-
- ZERO_STRUCT(devmode_ctr);
-
- client_info_ctr.level = 1;
- client_info_ctr.user_info.level1 = &cinfo;
-
- r.in.pPrinterName = printer_name;
- r.in.pDatatype = NULL;
- r.in.pDevModeContainer = &devmode_ctr;
- r.in.AccessRequired = access_mask;
- r.in.pClientInfo = &client_info_ctr;
- r.out.pHandle = handle;
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winspool_AsyncOpenPrinter_r(b, tctx, &r),
- "AsyncOpenPrinter failed");
- torture_assert_werr_ok(tctx, r.out.result,
- "AsyncOpenPrinter failed");
-
- return true;
-}
-
-static bool test_AsyncClosePrinter_byhandle(struct torture_context *tctx,
- struct test_iremotewinspool_context *ctx,
- struct dcerpc_pipe *p,
- struct policy_handle *handle)
-{
- struct dcerpc_binding_handle *b = p->binding_handle;
-
- struct winspool_AsyncClosePrinter r;
-
- r.in.phPrinter = handle;
- r.out.phPrinter = handle;
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winspool_AsyncClosePrinter_r(b, tctx, &r),
- "AsyncClosePrinter failed");
- torture_assert_werr_ok(tctx, r.out.result,
- "AsyncClosePrinter failed");
-
- return true;
-}
-
-static bool test_AsyncGetPrinterData_checktype(struct torture_context *tctx,
- struct dcerpc_binding_handle *b,
- struct policy_handle *handle,
- const char *value_name,
- enum winreg_Type *expected_type,
- enum winreg_Type *type_p,
- uint8_t **data_p,
- uint32_t *needed_p)
-{
- struct winspool_AsyncGetPrinterData r;
- enum winreg_Type type;
- uint32_t needed;
-
- r.in.hPrinter = *handle;
- r.in.pValueName = value_name;
- r.in.nSize = 0;
- r.out.pType = &type;
- r.out.pData = talloc_zero_array(tctx, uint8_t, r.in.nSize);
- r.out.pcbNeeded = &needed;
-
- torture_comment(tctx, "Testing AsyncGetPrinterData(%s)\n",
- r.in.pValueName);
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winspool_AsyncGetPrinterData_r(b, tctx, &r),
- "AsyncGetPrinterData failed");
-
- if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
- if (expected_type) {
- torture_assert_int_equal(tctx, type, *expected_type, "unexpected type");
- }
- r.in.nSize = needed;
- r.out.pData = talloc_zero_array(tctx, uint8_t, r.in.nSize);
-
- torture_assert_ntstatus_ok(tctx,
- dcerpc_winspool_AsyncGetPrinterData_r(b, tctx, &r),
- "AsyncGetPrinterData failed");
- }
-
- torture_assert_werr_ok(tctx, r.out.result,
- "AsyncGetPrinterData failed");
-
- if (type_p) {
- *type_p = type;
- }
-
- if (data_p) {
- *data_p = r.out.pData;
- }
-
- if (needed_p) {
- *needed_p = needed;
- }
-
- return true;
-}
-
-static bool test_AsyncGetPrinterData_args(struct torture_context *tctx,
- struct dcerpc_binding_handle *b,
- struct policy_handle *handle,
- const char *value_name,
- enum winreg_Type *type_p,
- uint8_t **data_p,
- uint32_t *needed_p)
-{
- return test_AsyncGetPrinterData_checktype(tctx, b, handle,
- value_name,
- NULL,
- type_p, data_p, needed_p);
-}
-
-static bool test_get_environment(struct torture_context *tctx,
- struct dcerpc_binding_handle *b,
- struct policy_handle *handle,
- const char **architecture)
-{
- DATA_BLOB blob;
- enum winreg_Type type;
- uint8_t *data;
- uint32_t needed;
-
- torture_assert(tctx,
- test_AsyncGetPrinterData_args(tctx, b, handle, "Architecture", &type, &data, &needed),
- "failed to get Architecture");
-
- torture_assert_int_equal(tctx, type, REG_SZ, "unexpected type");
-
- blob = data_blob_const(data, needed);
-
- torture_assert(tctx,
- pull_reg_sz(tctx, &blob, architecture),
- "failed to pull environment");
-
- return true;
-}
+#include "torture/rpc/iremotewinspool_common.h"
static bool torture_rpc_iremotewinspool_setup_common(struct torture_context *tctx,
struct test_iremotewinspool_context *t)
diff --git a/source4/torture/rpc/iremotewinspool_common.c b/source4/torture/rpc/iremotewinspool_common.c
new file mode 100644
index 00000000000..e692f274196
--- /dev/null
+++ b/source4/torture/rpc/iremotewinspool_common.c
@@ -0,0 +1,188 @@
+#include "includes.h"
+#include "torture/torture.h"
+#include "librpc/gen_ndr/ndr_winspool.h"
+#include "librpc/gen_ndr/ndr_winspool_c.h"
+#include "librpc/gen_ndr/ndr_spoolss_c.h"
+#include "torture/rpc/torture_rpc.h"
+#include "libcli/registry/util_reg.h"
+#include "torture/rpc/iremotewinspool_common.h"
+
+struct spoolss_UserLevel1 test_get_client_info(struct torture_context *tctx,
+ enum client_os_version os,
+ enum spoolss_MajorVersion major_number,
+ enum spoolss_MinorVersion minor_number)
+{
+ struct spoolss_UserLevel1 level1;
+
+ level1.size = 28;
+ level1.client = talloc_asprintf(tctx, "\\\\%s", "mthelena");
+ level1.user = "GD";
+ level1.processor = PROCESSOR_ARCHITECTURE_AMD64;
+ level1.major = major_number;
+ level1.minor = minor_number;
+
+ if (os == WIN_SERVER_2016 || os == WIN_10) {
+ level1.build = 10586;
+ } else if (os == WIN_SERVER_2012 || os == WIN_8) {
+ level1.build = 9200;
+ } else if (os == WIN_SERVER_2008R2 || os == WIN_7) {
+ level1.build = 7007;
+ } else if (os == WIN_SERVER_2008 || os == WIN_VISTA) {
+ level1.build = 6000;
+ } else if (os == WIN_2000) {
+ level1.build = 1382;
+ }
+
+ return level1;
+}
+
+bool test_AsyncOpenPrinter_byprinter(struct torture_context *tctx,
+ struct test_iremotewinspool_context *ctx,
+ struct dcerpc_pipe *p,
+ const char *printer_name,
+ struct spoolss_UserLevel1 cinfo,
+ struct policy_handle *handle)
+{
+ struct dcerpc_binding_handle *b = p->binding_handle;
+ struct spoolss_DevmodeContainer devmode_ctr;
+ struct spoolss_UserLevelCtr client_info_ctr;
+ uint32_t access_mask = SERVER_ALL_ACCESS;
+ struct winspool_AsyncOpenPrinter r;
+
+ ZERO_STRUCT(devmode_ctr);
+
+ client_info_ctr.level = 1;
+ client_info_ctr.user_info.level1 = &cinfo;
+
+ r.in.pPrinterName = printer_name;
+ r.in.pDatatype = NULL;
+ r.in.pDevModeContainer = &devmode_ctr;
+ r.in.AccessRequired = access_mask;
+ r.in.pClientInfo = &client_info_ctr;
+ r.out.pHandle = handle;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winspool_AsyncOpenPrinter_r(b, tctx, &r),
+ "AsyncOpenPrinter failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ "AsyncOpenPrinter failed");
+
+ return true;
+}
+
+bool test_get_environment(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char **architecture)
+{
+ DATA_BLOB blob;
+ enum winreg_Type type;
+ uint8_t *data;
+ uint32_t needed;
+
+ torture_assert(tctx,
+ test_AsyncGetPrinterData_args(tctx, b, handle, "Architecture", &type, &data, &needed),
+ "failed to get Architecture");
+
+ torture_assert_int_equal(tctx, type, REG_SZ, "unexpected type");
+
+ blob = data_blob_const(data, needed);
+
+ torture_assert(tctx,
+ pull_reg_sz(tctx, &blob, architecture),
+ "failed to pull environment");
+
+ return true;
+}
+
+bool test_AsyncClosePrinter_byhandle(struct torture_context *tctx,
+ struct test_iremotewinspool_context *ctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle)
+{
+ struct dcerpc_binding_handle *b = p->binding_handle;
+
+ struct winspool_AsyncClosePrinter r;
+
+ r.in.phPrinter = handle;
+ r.out.phPrinter = handle;
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winspool_AsyncClosePrinter_r(b, tctx, &r),
+ "AsyncClosePrinter failed");
+ torture_assert_werr_ok(tctx, r.out.result,
+ "AsyncClosePrinter failed");
+
+ return true;
+}
+
+static bool test_AsyncGetPrinterData_checktype(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char *value_name,
+ enum winreg_Type *expected_type,
+ enum winreg_Type *type_p,
+ uint8_t **data_p,
+ uint32_t *needed_p)
+{
+ struct winspool_AsyncGetPrinterData r;
+ enum winreg_Type type;
+ uint32_t needed;
+
+ r.in.hPrinter = *handle;
+ r.in.pValueName = value_name;
+ r.in.nSize = 0;
+ r.out.pType = &type;
+ r.out.pData = talloc_zero_array(tctx, uint8_t, r.in.nSize);
+ r.out.pcbNeeded = &needed;
+
+ torture_comment(tctx, "Testing AsyncGetPrinterData(%s)\n",
+ r.in.pValueName);
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winspool_AsyncGetPrinterData_r(b, tctx, &r),
+ "AsyncGetPrinterData failed");
+
+ if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) {
+ if (expected_type) {
+ torture_assert_int_equal(tctx, type, *expected_type, "unexpected type");
+ }
+ r.in.nSize = needed;
+ r.out.pData = talloc_zero_array(tctx, uint8_t, r.in.nSize);
+
+ torture_assert_ntstatus_ok(tctx,
+ dcerpc_winspool_AsyncGetPrinterData_r(b, tctx, &r),
+ "AsyncGetPrinterData failed");
+ }
+
+ torture_assert_werr_ok(tctx, r.out.result,
+ "AsyncGetPrinterData failed");
+
+ if (type_p) {
+ *type_p = type;
+ }
+
+ if (data_p) {
+ *data_p = r.out.pData;
+ }
+
+ if (needed_p) {
+ *needed_p = needed;
+ }
+
+ return true;
+}
+
+bool test_AsyncGetPrinterData_args(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char *value_name,
+ enum winreg_Type *type_p,
+ uint8_t **data_p,
+ uint32_t *needed_p)
+{
+ return test_AsyncGetPrinterData_checktype(tctx, b, handle,
+ value_name,
+ NULL,
+ type_p, data_p, needed_p);
+}
diff --git a/source4/torture/rpc/iremotewinspool_common.h b/source4/torture/rpc/iremotewinspool_common.h
new file mode 100644
index 00000000000..868d142cdee
--- /dev/null
+++ b/source4/torture/rpc/iremotewinspool_common.h
@@ -0,0 +1,72 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ iremotewinspool rpc test operations
+
+ Copyright (C) 2018 Justin Stephenson
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "torture/rpc/torture_rpc.h"
+
+struct test_iremotewinspool_context {
+ struct GUID object_uuid;
+ struct dcerpc_pipe *iremotewinspool_pipe;
+ struct policy_handle server_handle;
+ const char *environment;
+};
+
+enum client_os_version
+{
+ WIN_2000,
+ WIN_VISTA,
+ WIN_SERVER_2008,
+ WIN_7,
+ WIN_SERVER_2008R2,
+ WIN_8,
+ WIN_SERVER_2012,
+ WIN_10,
+ WIN_SERVER_2016
+};
+
+struct spoolss_UserLevel1 test_get_client_info(struct torture_context *tctx,
+ enum client_os_version os,
+ enum spoolss_MajorVersion major_number,
+ enum spoolss_MinorVersion minor_number);
+
+bool test_AsyncOpenPrinter_byprinter(struct torture_context *tctx,
+ struct test_iremotewinspool_context *ctx,
+ struct dcerpc_pipe *p,
+ const char *printer_name,
+ struct spoolss_UserLevel1 cinfo,
+ struct policy_handle *handle);
+
+bool test_get_environment(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char **architecture);
+
+bool test_AsyncClosePrinter_byhandle(struct torture_context *tctx,
+ struct test_iremotewinspool_context *ctx,
+ struct dcerpc_pipe *p,
+ struct policy_handle *handle);
+
+bool test_AsyncGetPrinterData_args(struct torture_context *tctx,
+ struct dcerpc_binding_handle *b,
+ struct policy_handle *handle,
+ const char *value_name,
+ enum winreg_Type *type_p,
+ uint8_t **data_p,
+ uint32_t *needed_p);
diff --git a/source4/torture/wscript_build b/source4/torture/wscript_build
index 8d46d7355bc..c97b7ae034b 100644
--- a/source4/torture/wscript_build
+++ b/source4/torture/wscript_build
@@ -76,6 +76,11 @@ bld.SAMBA_SUBSYSTEM('TORTURE_NDR',
enabled=bld.PYTHON_BUILD_IS_ENABLED()
)
+bld.SAMBA_SUBSYSTEM('IREMOTEWINSPOOL_COMMON',
+ source='rpc/iremotewinspool_common.c',
+ deps='talloc',
+ enabled=bld.PYTHON_BUILD_IS_ENABLED())
+
torture_rpc_backupkey = ''
if bld.AD_DC_BUILD_IS_ENABLED():
if bld.CONFIG_SET('HAVE_GNUTLS_3_4_7'):
@@ -185,6 +190,7 @@ bld.SAMBA_MODULE('torture_rpc',
RPC_NDR_WITNESS
RPC_NDR_BACKUPKEY
RPC_NDR_WINSPOOL
+ IREMOTEWINSPOOL_COMMON
''' % samba_net + ntvfs_specific['deps'],
internal_module=True,
enabled=bld.PYTHON_BUILD_IS_ENABLED())