From 35aed17b2651bc6dd9be415f8b8060357ee78ecb Mon Sep 17 00:00:00 2001 From: Kamen Mazdrashki Date: Sun, 5 Sep 2010 23:28:06 +0300 Subject: 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 --- source4/torture/libnet/libnet_user.c | 52 ++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 29 deletions(-) (limited to 'source4') 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; } -- cgit