source: trunk/server/source4/torture/libnetapi/libnetapi.c

Last change on this file was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 SMB torture tester
4 Copyright (C) Guenther Deschner 2009
5
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.
10
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.
15
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/>.
18*/
19
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"
26
27bool torture_libnetapi_init_context(struct torture_context *tctx,
28 struct libnetapi_ctx **ctx_p)
29{
30 NET_API_STATUS status;
31 struct libnetapi_ctx *ctx;
32
33 status = libnetapi_init(&ctx);
34 if (status != 0) {
35 return false;
36 }
37
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));
44
45 *ctx_p = ctx;
46
47 return true;
48}
49
50static bool torture_libnetapi_initialize(struct torture_context *tctx)
51{
52 NET_API_STATUS status;
53 struct libnetapi_ctx *ctx;
54
55 status = libnetapi_init(&ctx);
56 if (status != 0) {
57 return false;
58 }
59
60 libnetapi_free(ctx);
61
62 return true;
63}
64
65NTSTATUS torture_libnetapi_init(void)
66{
67 struct torture_suite *suite;
68
69 suite = torture_suite_create(talloc_autofree_context(), "netapi");
70
71 torture_suite_add_simple_test(suite, "server", torture_libnetapi_server);
72 torture_suite_add_simple_test(suite, "group", torture_libnetapi_group);
73 torture_suite_add_simple_test(suite, "user", torture_libnetapi_user);
74 torture_suite_add_simple_test(suite, "initialize", torture_libnetapi_initialize);
75
76 suite->description = talloc_strdup(suite, "libnetapi convenience interface tests");
77
78 torture_register_suite(suite);
79
80 return NT_STATUS_OK;
81}
Note: See TracBrowser for help on using the repository browser.