summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-06-10 18:23:06 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-06-11 01:20:10 +0300
commit1ceb0dd92f1c1795264832eee0711612cc58d9a8 (patch)
treeef89b32595a13bf7da88c6f4b189c5f2248d1b54 /source4/torture
parentd6d8ec80f9fc713924df1c9b72ab0491bdf95bde (diff)
downloadsamba-1ceb0dd92f1c1795264832eee0711612cc58d9a8.tar.gz
samba-1ceb0dd92f1c1795264832eee0711612cc58d9a8.tar.bz2
samba-1ceb0dd92f1c1795264832eee0711612cc58d9a8.zip
s4/test: use test_libnet_context_init() function to create libnet_context
This way we ensure that LIBNET call will be issued against the DC we are testing against
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/libnet/libnet_group.c12
-rw-r--r--source4/torture/libnet/libnet_user.c35
2 files changed, 23 insertions, 24 deletions
diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c
index ddc5630af6..0d8249f9f3 100644
--- a/source4/torture/libnet/libnet_group.c
+++ b/source4/torture/libnet/libnet_group.c
@@ -57,7 +57,7 @@ bool torture_groupinfo_api(struct torture_context *torture)
bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
- struct libnet_context *ctx;
+ struct libnet_context *ctx = NULL;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
@@ -65,9 +65,6 @@ bool torture_groupinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture group info");
- ctx = libnet_context_init(torture->ev, torture->lp_ctx);
- ctx->cred = cmdline_credentials;
-
status = torture_rpc_connection(torture,
&p,
&ndr_table_samr);
@@ -88,6 +85,10 @@ bool torture_groupinfo_api(struct torture_context *torture)
mem_ctx = talloc_init("torture group info");
+ if (!test_libnet_context_init(torture, true, &ctx)) {
+ return false;
+ }
+
ZERO_STRUCT(req);
req.in.domain_name = domain_name.string;
@@ -113,9 +114,8 @@ bool torture_groupinfo_api(struct torture_context *torture)
ret = false;
}
- talloc_free(ctx);
-
done:
+ talloc_free(ctx);
talloc_free(mem_ctx);
return ret;
}
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index 9837a88e36..84a642a622 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -54,14 +54,15 @@ bool torture_createuser(struct torture_context *torture)
{
NTSTATUS status;
TALLOC_CTX *mem_ctx;
- struct libnet_context *ctx;
+ struct libnet_context *ctx = NULL;
struct libnet_CreateUser req;
bool ret = true;
mem_ctx = talloc_init("test_createuser");
- ctx = libnet_context_init(torture->ev, torture->lp_ctx);
- ctx->cred = cmdline_credentials;
+ if (!test_libnet_context_init(torture, true, &ctx)) {
+ return false;
+ }
req.in.user_name = TEST_USERNAME;
req.in.domain_name = lp_workgroup(torture->lp_ctx);
@@ -102,15 +103,12 @@ bool torture_deleteuser(struct torture_context *torture)
struct policy_handle h;
struct lsa_String domain_name;
const char *name = TEST_USERNAME;
- struct libnet_context *ctx;
+ struct libnet_context *ctx = NULL;
struct libnet_DeleteUser req;
bool ret = true;
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(torture->ev, torture->lp_ctx);
- ctx->cred = cmdline_credentials;
-
req.in.user_name = TEST_USERNAME;
req.in.domain_name = lp_workgroup(torture->lp_ctx);
@@ -135,6 +133,10 @@ bool torture_deleteuser(struct torture_context *torture)
mem_ctx = talloc_init("test_deleteuser");
+ if (!test_libnet_context_init(torture, true, &ctx)) {
+ return false;
+ }
+
status = libnet_DeleteUser(ctx, mem_ctx, &req);
if (!NT_STATUS_IS_OK(status)) {
torture_comment(torture, "libnet_DeleteUser call failed: %s\n", nt_errstr(status));
@@ -320,7 +322,7 @@ bool torture_modifyuser(struct torture_context *torture)
struct policy_handle h;
struct lsa_String domain_name;
char *name;
- struct libnet_context *ctx;
+ struct libnet_context *ctx = NULL;
struct libnet_ModifyUser req;
struct libnet_UserInfo user_req;
int fld;
@@ -329,9 +331,6 @@ bool torture_modifyuser(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare test_deleteuser");
- ctx = libnet_context_init(torture->ev, torture->lp_ctx);
- ctx->cred = cmdline_credentials;
-
status = torture_rpc_connection(torture,
&p,
&ndr_table_samr);
@@ -356,7 +355,7 @@ bool torture_modifyuser(struct torture_context *torture)
torture_comment(torture, "Testing change of all fields - each single one in turn\n");
- if (!_libnet_context_init_pipes(torture, ctx)) {
+ if (!test_libnet_context_init(torture, true, &ctx)) {
return false;
}
@@ -439,7 +438,7 @@ bool torture_userinfo_api(struct torture_context *torture)
bool ret = true;
NTSTATUS status;
TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
- struct libnet_context *ctx;
+ struct libnet_context *ctx = NULL;
struct dcerpc_pipe *p;
struct policy_handle h;
struct lsa_String domain_name;
@@ -448,9 +447,6 @@ bool torture_userinfo_api(struct torture_context *torture)
prep_mem_ctx = talloc_init("prepare torture user info");
- ctx = libnet_context_init(torture->ev, torture->lp_ctx);
- ctx->cred = cmdline_credentials;
-
status = torture_rpc_connection(torture,
&p,
&ndr_table_samr);
@@ -472,6 +468,10 @@ bool torture_userinfo_api(struct torture_context *torture)
mem_ctx = talloc_init("torture user info");
+ if (!test_libnet_context_init(torture, true, &ctx)) {
+ return false;
+ }
+
ZERO_STRUCT(req);
req.in.domain_name = domain_name.string;
@@ -498,9 +498,8 @@ bool torture_userinfo_api(struct torture_context *torture)
ret = false;
}
- talloc_free(ctx);
-
done:
+ talloc_free(ctx);
talloc_free(mem_ctx);
return ret;
}