2 Unix SMB/CIFS implementation.
3 test suite for RAP / DCERPC consistency
4 Copyright (C) Guenther Deschner 2010
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/>.
21 #include "libcli/libcli.h"
22 #include "torture/smbtorture.h"
23 #include "torture/util.h"
24 #include "libcli/rap/rap.h"
25 #include "torture/rap/proto.h"
26 #include "param/param.h"
27 #include "torture/rpc/torture_rpc.h"
28 #include "librpc/gen_ndr/ndr_srvsvc_c.h"
30 static bool test_rpc_netservergetinfo(struct torture_context
*tctx
,
31 struct smbcli_state
*cli
)
33 struct rap_WserverGetInfo r
;
34 struct dcerpc_pipe
*p
;
35 struct dcerpc_binding_handle
*b
;
36 struct srvsvc_NetSrvGetInfo s
;
37 union srvsvc_NetSrvInfo info
;
39 const char *server_name
;
41 torture_assert_ntstatus_ok(tctx
,
42 torture_rpc_connection(tctx
, &p
, &ndr_table_srvsvc
),
43 "failed to open srvsvc");
45 b
= p
->binding_handle
;
47 s
.in
.server_unc
= NULL
;
51 torture_assert_ntstatus_ok(tctx
,
52 dcerpc_srvsvc_NetSrvGetInfo_r(b
, tctx
, &s
),
53 "srvsvc_NetSrvGetInfo level 101 failed");
54 torture_assert_werr_ok(tctx
, s
.out
.result
,
55 "srvsvc_NetSrvGetInfo level 101 failed");
57 r
.in
.bufsize
= 0xffff;
60 torture_assert_ntstatus_ok(tctx
,
61 smbcli_rap_netservergetinfo(cli
->tree
, tctx
, &r
),
62 "rap_netservergetinfo level 0 failed");
63 torture_assert_int_equal(tctx
, r
.out
.status
, 0,
64 "rap_netservergetinfo level 0 failed");
66 server_name
= talloc_strndup(tctx
, info
.info101
->server_name
, 16);
68 torture_assert_str_equal(tctx
, (const char *)r
.out
.info
.info0
.name
, server_name
, "server name");
72 torture_assert_ntstatus_ok(tctx
,
73 smbcli_rap_netservergetinfo(cli
->tree
, tctx
, &r
),
74 "rap_netservergetinfo level 1 failed");
75 torture_assert_int_equal(tctx
, r
.out
.status
, 0,
76 "rap_netservergetinfo level 1 failed");
78 torture_assert_str_equal(tctx
, (const char *)r
.out
.info
.info1
.name
, server_name
, "server name");
79 torture_assert_int_equal(tctx
, r
.out
.info
.info1
.version_major
, info
.info101
->version_major
, "version major");
80 torture_assert_int_equal(tctx
, r
.out
.info
.info1
.version_minor
, info
.info101
->version_minor
, "version minor");
81 torture_assert_int_equal(tctx
, r
.out
.info
.info1
.servertype
, info
.info101
->server_type
, "server_type");
82 torture_assert_str_equal(tctx
, r
.out
.info
.info1
.comment
, info
.info101
->comment
, "comment");
89 struct torture_suite
*torture_rap_rpc(TALLOC_CTX
*mem_ctx
)
91 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "rpc");
93 torture_suite_add_1smb_test(suite
, "netservergetinfo",
94 test_rpc_netservergetinfo
);
96 suite
->description
= talloc_strdup(suite
,
97 "RAP / DCERPC consistency tests");