summaryrefslogtreecommitdiff
path: root/source4/torture/libnet
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-09-05 23:28:06 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-09-05 23:34:28 +0300
commit35aed17b2651bc6dd9be415f8b8060357ee78ecb (patch)
treeeeb5a98da8b29495e856e8599c8ac2d301c74400 /source4/torture/libnet
parentdea5c7b9486f7d4cbefd563a4e366c2fb3ccbf8f (diff)
downloadsamba-35aed17b2651bc6dd9be415f8b8060357ee78ecb.tar.gz
samba-35aed17b2651bc6dd9be415f8b8060357ee78ecb.tar.bz2
samba-35aed17b2651bc6dd9be415f8b8060357ee78ecb.zip
s4-test: refactor API-DELETEUSER test a little to:
- fail torture_context in case libnet_DeleteUser() has failed - make use of torture_assert_* macros to track down where failur occured - use only one memory context internally
Diffstat (limited to 'source4/torture/libnet')
-rw-r--r--source4/torture/libnet/libnet_user.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c
index c5af5ed1ab..64f57d57ad 100644
--- a/source4/torture/libnet/libnet_user.c
+++ b/source4/torture/libnet/libnet_user.c
@@ -80,55 +80,49 @@ bool torture_deleteuser(struct torture_context *torture)
{
NTSTATUS status;
struct dcerpc_pipe *p;
- TALLOC_CTX *prep_mem_ctx, *mem_ctx;
+ TALLOC_CTX *mem_ctx;
struct policy_handle h;
struct lsa_String domain_name;
const char *name = TEST_USERNAME;
struct libnet_context *ctx = NULL;
struct libnet_DeleteUser req;
- bool ret = true;
-
- prep_mem_ctx = talloc_init("prepare test_deleteuser");
-
- req.in.user_name = TEST_USERNAME;
- req.in.domain_name = lpcfg_workgroup(torture->lp_ctx);
+ bool ret = false;
status = torture_rpc_connection(torture,
&p,
&ndr_table_samr);
- if (!NT_STATUS_IS_OK(status)) {
- ret = false;
- goto done;
- }
+ torture_assert_ntstatus_ok(torture, status, "torture_rpc_connection() failed");
+
+ mem_ctx = talloc_init("torture_deleteuser");
+ /*
+ * Pre-create a user to be deleted later
+ */
domain_name.string = lpcfg_workgroup(torture->lp_ctx);
- if (!test_domain_open(torture, p->binding_handle, &domain_name, prep_mem_ctx, &h, NULL)) {
- ret = false;
- goto done;
- }
+ ret = test_domain_open(torture, p->binding_handle, &domain_name, mem_ctx, &h, NULL);
+ torture_assert_goto(torture, ret, ret, done, "test_domain_open() failed");
- if (!test_user_create(torture, p->binding_handle, prep_mem_ctx, &h, name, NULL)) {
- ret = false;
- goto done;
- }
+ ret = test_user_create(torture, p->binding_handle, mem_ctx, &h, name, NULL);
+ torture_assert_goto(torture, ret, ret, done, "test_user_create() failed");
- mem_ctx = talloc_init("test_deleteuser");
+ /*
+ * Delete the user using libnet layer
+ */
+ ret = test_libnet_context_init(torture, true, &ctx);
+ torture_assert_goto(torture, ret, ret, done, "test_libnet_context_init() failed");
- if (!test_libnet_context_init(torture, true, &ctx)) {
- return false;
- }
+ req.in.user_name = TEST_USERNAME;
+ req.in.domain_name = lpcfg_workgroup(torture->lp_ctx);
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));
- ret = false;
- }
+ torture_assert_ntstatus_ok_goto(torture, status, ret, done, "libnet_DeleteUser() failed");
- talloc_free(mem_ctx);
+ /* mark test as successful */
+ ret = true;
done:
talloc_free(ctx);
- talloc_free(prep_mem_ctx);
+ talloc_free(mem_ctx);
return ret;
}