[PATCH 3/4] torture: torture tests for get_dfs_referral of trans.idl

Matthieu Patou mat at matws.net
Thu Dec 10 05:18:34 MST 2009


---
 source4/librpc/config.mk      |    7 ++-
 source4/torture/config.mk     |   19 +++++++-
 source4/torture/torture.c     |    1 +
 source4/torture/trans/proto.h |  109 +++++++++++++++++++++++++++++++++++++++++
 source4/torture/trans/trans.c |   98 ++++++++++++++++++++++++++++++++++++
 5 files changed, 232 insertions(+), 2 deletions(-)
 create mode 100644 source4/torture/trans/proto.h
 create mode 100644 source4/torture/trans/trans.c

diff --git a/source4/librpc/config.mk b/source4/librpc/config.mk
index 501b88b..bb8a569 100644
--- a/source4/librpc/config.mk
+++ b/source4/librpc/config.mk
@@ -275,6 +275,11 @@ NDR_NBT_OBJ_FILES = ../librpc/gen_ndr/ndr_nbt.o
 
 PUBLIC_HEADERS += ../librpc/gen_ndr/nbt.h
 
+[SUBSYSTEM::NDR_TRANS]
+PUBLIC_DEPENDENCIES = LIBNDR
+
+NDR_TRANS_OBJ_FILES = ../librpc/gen_ndr/ndr_trans.o
+
 [SUBSYSTEM::NDR_NTP_SIGND]
 PUBLIC_DEPENDENCIES = LIBNDR 
 
@@ -352,7 +357,7 @@ PUBLIC_DEPENDENCIES = \
 	NDR_FRSRPC NDR_FRSAPI NDR_FRSTRANS \
 	NDR_NFS4ACL NDR_NTP_SIGND \
 	NDR_DCOM NDR_WMI NDR_NAMED_PIPE_AUTH \
-	NDR_NTLMSSP
+	NDR_NTLMSSP NDR_TRANS
 
 NDR_TABLE_OBJ_FILES = ../librpc/ndr/ndr_table.o $(gen_ndrsrcdir)/tables.o
 
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 00362b6..53819f0 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -94,7 +94,7 @@ mkinclude libnetapi/config.mk
 [SUBSYSTEM::TORTURE_NDR]
 PRIVATE_DEPENDENCIES = torture SERVICE_SMB
 
-TORTURE_NDR_OBJ_FILES = $(addprefix $(torturesrcdir)/ndr/, ndr.o winreg.o atsvc.o lsa.o epmap.o dfs.o netlogon.o drsuapi.o spoolss.o samr.o)
+TORTURE_NDR_OBJ_FILES = $(addprefix $(torturesrcdir)/ndr/, ndr.o winreg.o atsvc.o lsa.o epmap.o dfs.o netlogon.o drsuapi.o spoolss.o samr.o) 
 
 $(eval $(call proto_header_template,$(torturesrcdir)/ndr/proto.h,$(TORTURE_NDR_OBJ_FILES:.o=.c)))
 
@@ -241,6 +241,22 @@ TORTURE_NET_OBJ_FILES = $(addprefix $(torturesrcdir)/libnet/, libnet.o \
 $(eval $(call proto_header_template,$(torturesrcdir)/libnet/proto.h,$(TORTURE_NET_OBJ_FILES:.o=.c)))
 
 #################################
+# Start SUBSYSTEM TORTURE_TRANS
+[MODULE::TORTURE_TRANS]
+SUBSYSTEM = smbtorture
+OUTPUT_TYPE = MERGED_OBJ
+INIT_FUNCTION = torture_trans_init
+PRIVATE_DEPENDENCIES = \
+		POPT_CREDENTIALS \
+		NDR_TRANS_OBJ_FILES
+# End SUBSYSTEM TORTURE_NTP
+#################################
+
+TORTURE_TRANS_OBJ_FILES = $(addprefix $(torturesrcdir)/trans/, trans.o)
+
+$(eval $(call proto_header_template,$(torturesrcdir)/trans/proto.h,$(TORTURE_NET_OBJ_FILES:.o=.c)))
+
+#################################
 # Start SUBSYSTEM TORTURE_NTP
 [MODULE::TORTURE_NTP]
 SUBSYSTEM = smbtorture
@@ -267,6 +283,7 @@ PRIVATE_DEPENDENCIES = \
 		POPT_CREDENTIALS \
 		dcerpc \
 		LIBCLI_SMB \
+		NDR_TRANS_OBJ_FILES \
 		SMBREADLINE
 # End BINARY smbtorture
 #################################
diff --git a/source4/torture/torture.c b/source4/torture/torture.c
index 49a6a8c..d69e5ec 100644
--- a/source4/torture/torture.c
+++ b/source4/torture/torture.c
@@ -60,6 +60,7 @@ _PUBLIC_ int torture_init(void)
 	extern NTSTATUS torture_rap_init(void);
  	extern NTSTATUS torture_rpc_init(void);
  	extern NTSTATUS torture_ntp_init(void);
+ 	extern NTSTATUS torture_trans_init(void);
 	extern NTSTATUS torture_smb2_init(void);
 	extern NTSTATUS torture_net_init(void);
 	extern NTSTATUS torture_libnetapi_init(void);
diff --git a/source4/torture/trans/proto.h b/source4/torture/trans/proto.h
new file mode 100644
index 0000000..4e757ea
--- /dev/null
+++ b/source4/torture/trans/proto.h
@@ -0,0 +1,109 @@
+#ifndef __TORTURE_TRANS_PROTO_H__
+#define __TORTURE_TRANS_PROTO_H__
+
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2) PRINTF_ATTRIBUTE(a1, a2)
+/* This file was automatically generated by mkproto.pl. DO NOT EDIT */
+
+/* this file contains prototypes for functions that are private 
+ * to this subsystem or library. These functions should not be 
+ * used outside this particular subsystem! */
+
+
+/* The following definitions come from torture/libnet/libnet.c  */
+
+NTSTATUS torture_net_init(void);
+
+/* The following definitions come from torture/libnet/utils.c  */
+
+bool test_opendomain(struct torture_context *tctx, 
+		     struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+		     struct policy_handle *handle, struct lsa_String *domname,
+		     struct dom_sid2 *sid_p);
+bool test_user_cleanup(struct torture_context *tctx, struct dcerpc_pipe *p, 
+		       TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle,
+		       const char *name);
+bool test_user_create(struct torture_context *tctx, 
+		      struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+		      struct policy_handle *handle, const char *name,
+		      uint32_t *rid);
+bool test_group_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+			struct policy_handle *domain_handle,
+			const char *name);
+bool test_group_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
+		       struct policy_handle *handle, const char *name,
+		       uint32_t *rid);
+void msg_handler(struct monitor_msg *m);
+
+/* The following definitions come from torture/libnet/userinfo.c  */
+
+bool torture_userinfo(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/userman.c  */
+
+bool torture_useradd(struct torture_context *torture);
+bool torture_userdel(struct torture_context *torture);
+bool torture_usermod(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/groupinfo.c  */
+
+bool torture_groupinfo(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/groupman.c  */
+
+bool torture_groupadd(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/domain.c  */
+
+bool torture_domainopen(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_lookup.c  */
+
+bool torture_lookup(struct torture_context *torture);
+bool torture_lookup_host(struct torture_context *torture);
+bool torture_lookup_pdc(struct torture_context *torture);
+bool torture_lookup_sam_name(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_user.c  */
+
+bool torture_createuser(struct torture_context *torture);
+bool torture_deleteuser(struct torture_context *torture);
+bool torture_modifyuser(struct torture_context *torture);
+bool torture_userinfo_api(struct torture_context *torture);
+bool torture_userlist(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_group.c  */
+
+bool torture_groupinfo_api(struct torture_context *torture);
+bool torture_grouplist(struct torture_context *torture);
+bool torture_creategroup(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_share.c  */
+
+bool torture_listshares(struct torture_context *torture);
+bool torture_delshare(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_rpc.c  */
+
+bool torture_rpc_connect_srv(struct torture_context *torture);
+bool torture_rpc_connect_pdc(struct torture_context *torture);
+bool torture_rpc_connect_dc(struct torture_context *torture);
+bool torture_rpc_connect_dc_info(struct torture_context *torture);
+bool torture_rpc_connect_binding(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_domain.c  */
+
+bool torture_domain_open_lsa(struct torture_context *torture);
+bool torture_domain_close_lsa(struct torture_context *torture);
+bool torture_domain_open_samr(struct torture_context *torture);
+bool torture_domain_close_samr(struct torture_context *torture);
+bool torture_domain_list(struct torture_context *torture);
+
+/* The following definitions come from torture/libnet/libnet_BecomeDC.c  */
+
+bool torture_net_become_dc(struct torture_context *torture);
+#undef _PRINTF_ATTRIBUTE
+#define _PRINTF_ATTRIBUTE(a1, a2)
+
+#endif /* __TORTURE_TRANS_PROTO_H__ */
+
diff --git a/source4/torture/trans/trans.c b/source4/torture/trans/trans.c
new file mode 100644
index 0000000..57874ad
--- /dev/null
+++ b/source4/torture/trans/trans.c
@@ -0,0 +1,98 @@
+/* 
+   Unix SMB/CIFS implementation.
+
+   Test NTP authentication support
+
+   Copyright (C) Andrew Bartlet <abartlet at samba.org> 2008
+   
+   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 "includes.h"
+#include "torture/smbtorture.h"
+#include "torture/rpc/rpc.h"
+#include "librpc/gen_ndr/ndr_trans.h"
+#include "param/param.h"
+static const int DFS_RESP_MSG_SIZE = 116;
+const char dfs_resp_msg[116] = 
+		{0x00,0x00,0x02,0x00,0x0f,0x00,0x00,0x00,0x03,0x00,0x22,0x00,0x00,0x00,0x02,0x00 \
+		,0x58,0x02,0x00,0x00,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 \
+		,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x22,0x00,0x00,0x00 \
+		,0x02,0x00,0x58,0x02,0x00,0x00,0x3a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 \
+		,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5c,0x00,0x6d,0x00 \
+		,0x73,0x00,0x77,0x00,0x32,0x00,0x6b,0x00,0x33,0x00,0x2e,0x00,0x74,0x00,0x73,0x00 \
+		,0x74,0x00,0x00,0x00,0x5c,0x00,0x4d,0x00,0x53,0x00,0x57,0x00,0x32,0x00,0x4b,0x00 \
+		,0x33,0x00,0x00,0x00};
+static bool test_pull_dfs_referral(struct torture_context *tctx, 
+			   struct cli_credentials *credentials)
+{
+	struct ndr_print *ndr_print;
+
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	struct trans2_dfs_referral_resp resp;
+	bool result = false;
+	DATA_BLOB blob;
+	DATA_BLOB blob2;
+	blob=data_blob_talloc(mem_ctx,dfs_resp_msg,DFS_RESP_MSG_SIZE);
+	enum ndr_err_code ndr_err;
+
+	ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, 
+					   lp_iconv_convenience(tctx->lp_ctx),
+					   &resp,
+					   (ndr_pull_flags_fn_t)ndr_pull_trans2_dfs_referral_resp);
+	ndr_push_struct_blob(&blob2, mem_ctx, lp_iconv_convenience(tctx->lp_ctx), &resp, (ndr_push_flags_fn_t)ndr_push_trans2_dfs_referral_resp);
+	torture_assert_int_equal(tctx,ndr_err,NDR_ERR_SUCCESS,"PUSH error");
+	if( (blob.length == blob2.length) && (memcmp(blob.data,blob2.data,blob.length)==0)) {
+		result = true;
+	}
+	torture_assert(tctx,result,"Pull get_dfs_referral has failed");
+	return result;
+}
+
+static bool test_push_dfs_referral(struct torture_context *tctx, 
+			   struct cli_credentials *credentials)
+{
+	struct ndr_print *ndr_print;
+
+	TALLOC_CTX *mem_ctx = talloc_new(tctx);
+	struct trans2_dfs_referral_resp resp;
+	DATA_BLOB blob;
+	blob=data_blob_talloc(mem_ctx,dfs_resp_msg,DFS_RESP_MSG_SIZE);
+	enum ndr_err_code ndr_err;
+
+	ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, 
+					   lp_iconv_convenience(tctx->lp_ctx),
+					   &resp,
+					   (ndr_pull_flags_fn_t)ndr_pull_trans2_dfs_referral_resp);
+	torture_assert_int_equal(tctx,ndr_err,NDR_ERR_SUCCESS,"PULL error");
+	
+	ndr_print = talloc_zero(mem_ctx, struct ndr_print);
+	ndr_print->print = ndr_print_debug_helper;
+	ndr_print->depth = 1;
+	ndr_print_trans2_dfs_referral_resp(ndr_print,"GET_DFS_REFERRAL response",&resp);
+	torture_assert_int_equal(tctx,resp.nb_referrals,2,"Wrong number of decoded referrals");
+	torture_assert_str_equal(tctx,resp.referral_entries[0].referral.v3.referrals.r2.special_name,"\\msw2k3.tst","Wrong decoded special name");
+
+	return true;
+}
+NTSTATUS torture_trans_init(void)
+{
+	struct torture_suite *suite = torture_suite_create( talloc_autofree_context(), "TRANS2");
+	torture_suite_add_simple_test(suite, "PULL-GET_DFS_REFERRAL", test_pull_dfs_referral);
+	torture_suite_add_simple_test(suite, "PUSH-GET_DFS_REFERRAL", test_push_dfs_referral);
+	suite->description = talloc_strdup(suite, "Tests for Transaction2 extension");
+
+	torture_register_suite(suite);
+	return NT_STATUS_OK;
+}
-- 
1.6.3.3


--------------080605080406060906090704
Content-Type: text/x-patch;
 name="0004-idl-add-generated-code.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0004-idl-add-generated-code.patch"



More information about the samba-technical mailing list