summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-06-10 13:12:08 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-06-11 01:20:09 +0300
commiteda49261205471a1e0c96ae4e1eda037edb11eba (patch)
treef0272ba5805abb7d9d43435a434c0802c615bc58 /source4/torture
parent85d7863b2c2420bd652d73ab4ec230f709acae73 (diff)
downloadsamba-eda49261205471a1e0c96ae4e1eda037edb11eba.tar.gz
samba-eda49261205471a1e0c96ae4e1eda037edb11eba.tar.bz2
samba-eda49261205471a1e0c96ae4e1eda037edb11eba.zip
s4/test-libnet: Helper func to initialize libnet_context
and create rpc connections to SAMR and LSA pipes. This function should be used in cases where we need 'deterministic' connection to the DC we are testing against. The problem is that most of the test follow the pattern: 1. Connect to server supplied on command line 2. Create user/group through connection in 1. 3. Use 'fresh' libnet_context to query/alter the object in step 2. In singe-DC environment this work well. But in multiple-DC environment libnet may connect to another DC (step 3), not the one we use in step 1 and 2. This leads to false error - object created in step 2 is not found on DC we are querying in step 3.
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/libnet/utils.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c
index dfc5923f2a..312b19483f 100644
--- a/source4/torture/libnet/utils.c
+++ b/source4/torture/libnet/utils.c
@@ -27,6 +27,7 @@
#include "torture/rpc/torture_rpc.h"
#include "libnet/libnet.h"
#include "librpc/gen_ndr/ndr_samr_c.h"
+#include "librpc/gen_ndr/ndr_lsa_c.h"
#include "torture/libnet/proto.h"
#include "lib/ldb_wrap.h"
@@ -429,6 +430,59 @@ bool test_samr_close_handle(struct torture_context *tctx,
return true;
}
+/**
+ * Create and initialize libnet_context Context.
+ * Use this function in cases where we need to have SAMR and LSA pipes
+ * of libnet_context to be connected before executing any other
+ * libnet call
+ *
+ * @param rpc_connect [in] Connects SAMR and LSA pipes
+ */
+bool test_libnet_context_init(struct torture_context *tctx,
+ bool rpc_connect,
+ struct libnet_context **_net_ctx)
+{
+ NTSTATUS status;
+ bool bret = true;
+ struct libnet_context *net_ctx;
+
+ net_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);
+ torture_assert(tctx, net_ctx != NULL, "Failed to create libnet_context");
+
+ /* Use command line credentials for testing */
+ net_ctx->cred = cmdline_credentials;
+
+ if (rpc_connect) {
+ /* connect SAMR pipe */
+ status = torture_rpc_connection(tctx,
+ &net_ctx->samr.pipe,
+ &ndr_table_samr);
+ torture_assert_ntstatus_ok_goto(tctx, status, bret, done,
+ "Failed to connect SAMR pipe");
+
+ net_ctx->samr.samr_handle = net_ctx->samr.pipe->binding_handle;
+
+ /* connect LSARPC pipe */
+ status = torture_rpc_connection(tctx,
+ &net_ctx->lsa.pipe,
+ &ndr_table_lsarpc);
+ torture_assert_ntstatus_ok_goto(tctx, status, bret, done,
+ "Failed to connect LSA pipe");
+
+ net_ctx->lsa.lsa_handle = net_ctx->lsa.pipe->binding_handle;
+ }
+
+ *_net_ctx = net_ctx;
+
+done:
+ if (!bret) {
+ /* a previous call has failed,
+ * clean up memory before exit */
+ talloc_free(net_ctx);
+ }
+ return bret;
+}
+
void msg_handler(struct monitor_msg *m)
{