s4: Let the "setpassword" script finally use the "samdb_set_password" routine
[Samba/aatanasov.git] / source4 / torture / libnetapi / libnetapi.c
blobc3a27eba0c04f762faea70166032b9bd2d52aa3c
1 /*
2 Unix SMB/CIFS implementation.
3 SMB torture tester
4 Copyright (C) Guenther Deschner 2009
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "torture/smbtorture.h"
22 #include "auth/credentials/credentials.h"
23 #include "lib/cmdline/popt_common.h"
24 #include <netapi.h>
25 #include "torture/libnetapi/proto.h"
27 bool torture_libnetapi_init_context(struct torture_context *tctx,
28 struct libnetapi_ctx **ctx_p)
30 NET_API_STATUS status;
31 struct libnetapi_ctx *ctx;
33 status = libnetapi_init(&ctx);
34 if (status != 0) {
35 return false;
38 libnetapi_set_debuglevel(ctx,
39 talloc_asprintf(ctx, "%d", DEBUGLEVEL));
40 libnetapi_set_username(ctx,
41 cli_credentials_get_username(cmdline_credentials));
42 libnetapi_set_password(ctx,
43 cli_credentials_get_password(cmdline_credentials));
45 *ctx_p = ctx;
47 return true;
50 static bool torture_libnetapi_initialize(struct torture_context *tctx)
52 NET_API_STATUS status;
53 struct libnetapi_ctx *ctx;
55 status = libnetapi_init(&ctx);
56 if (status != 0) {
57 return false;
60 libnetapi_free(ctx);
62 return true;
65 NTSTATUS torture_libnetapi_init(void)
67 struct torture_suite *suite;
69 suite = torture_suite_create(talloc_autofree_context(), "NETAPI");
71 torture_suite_add_simple_test(suite, "GROUP", torture_libnetapi_group);
72 torture_suite_add_simple_test(suite, "USER", torture_libnetapi_user);
73 torture_suite_add_simple_test(suite, "INITIALIZE", torture_libnetapi_initialize);
75 suite->description = talloc_strdup(suite, "libnetapi convenience interface tests");
77 torture_register_suite(suite);
79 return NT_STATUS_OK;