mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
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
This commit is contained in:
parent
dea5c7b948
commit
35aed17b26
@ -80,55 +80,49 @@ bool torture_deleteuser(struct torture_context *torture)
|
|||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
struct dcerpc_pipe *p;
|
struct dcerpc_pipe *p;
|
||||||
TALLOC_CTX *prep_mem_ctx, *mem_ctx;
|
TALLOC_CTX *mem_ctx;
|
||||||
struct policy_handle h;
|
struct policy_handle h;
|
||||||
struct lsa_String domain_name;
|
struct lsa_String domain_name;
|
||||||
const char *name = TEST_USERNAME;
|
const char *name = TEST_USERNAME;
|
||||||
struct libnet_context *ctx = NULL;
|
struct libnet_context *ctx = NULL;
|
||||||
struct libnet_DeleteUser req;
|
struct libnet_DeleteUser req;
|
||||||
bool ret = true;
|
bool ret = false;
|
||||||
|
|
||||||
prep_mem_ctx = talloc_init("prepare test_deleteuser");
|
|
||||||
|
|
||||||
req.in.user_name = TEST_USERNAME;
|
|
||||||
req.in.domain_name = lpcfg_workgroup(torture->lp_ctx);
|
|
||||||
|
|
||||||
status = torture_rpc_connection(torture,
|
status = torture_rpc_connection(torture,
|
||||||
&p,
|
&p,
|
||||||
&ndr_table_samr);
|
&ndr_table_samr);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
torture_assert_ntstatus_ok(torture, status, "torture_rpc_connection() failed");
|
||||||
ret = false;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
mem_ctx = talloc_init("torture_deleteuser");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pre-create a user to be deleted later
|
||||||
|
*/
|
||||||
domain_name.string = lpcfg_workgroup(torture->lp_ctx);
|
domain_name.string = lpcfg_workgroup(torture->lp_ctx);
|
||||||
if (!test_domain_open(torture, p->binding_handle, &domain_name, prep_mem_ctx, &h, NULL)) {
|
ret = test_domain_open(torture, p->binding_handle, &domain_name, mem_ctx, &h, NULL);
|
||||||
ret = false;
|
torture_assert_goto(torture, ret, ret, done, "test_domain_open() failed");
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!test_user_create(torture, p->binding_handle, prep_mem_ctx, &h, name, NULL)) {
|
ret = test_user_create(torture, p->binding_handle, mem_ctx, &h, name, NULL);
|
||||||
ret = false;
|
torture_assert_goto(torture, ret, ret, done, "test_user_create() failed");
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)) {
|
req.in.user_name = TEST_USERNAME;
|
||||||
return false;
|
req.in.domain_name = lpcfg_workgroup(torture->lp_ctx);
|
||||||
}
|
|
||||||
|
|
||||||
status = libnet_DeleteUser(ctx, mem_ctx, &req);
|
status = libnet_DeleteUser(ctx, mem_ctx, &req);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
torture_assert_ntstatus_ok_goto(torture, status, ret, done, "libnet_DeleteUser() failed");
|
||||||
torture_comment(torture, "libnet_DeleteUser call failed: %s\n", nt_errstr(status));
|
|
||||||
ret = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
talloc_free(mem_ctx);
|
/* mark test as successful */
|
||||||
|
ret = true;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
talloc_free(ctx);
|
talloc_free(ctx);
|
||||||
talloc_free(prep_mem_ctx);
|
talloc_free(mem_ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user