2 Unix SMB/CIFS implementation.
3 test suite for lsa dfs operations
5 Copyright (C) Andrew Tridgell 2003
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "torture/torture.h"
24 #include "torture/rpc/rpc.h"
25 #include "librpc/gen_ndr/ndr_dfs_c.h"
28 static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
31 struct dfs_GetManagerVersion r;
34 r.out.exist_flag = ∃
36 status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r);
37 if (!NT_STATUS_IS_OK(status)) {
38 printf("GetManagerVersion failed - %s\n", nt_errstr(status));
45 static BOOL test_InfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level,
56 printf("Testing GetInfo level %u on '%s'\n", level, root);
58 status = dcerpc_dfs_GetInfo(p, mem_ctx, &r);
59 if (!NT_STATUS_IS_OK(status)) {
60 printf("Info failed - %s\n", nt_errstr(status));
67 static BOOL test_Info(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root)
70 uint16_t levels[] = {1, 2, 3, 4, 100, 101, 102, 200, 300};
72 for (i=0;i<ARRAY_SIZE(levels);i++) {
73 if (!test_InfoLevel(p, mem_ctx, levels[i], root)) {
80 static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level)
85 struct dfs_EnumStruct e;
87 struct dfs_EnumArray1 e1;
91 r.in.bufsize = (uint32_t)-1;
93 r.in.unknown = &total;
102 status = dcerpc_dfs_Enum(p, mem_ctx, &r);
103 if (!NT_STATUS_IS_OK(status)) {
104 printf("Enum failed - %s\n", nt_errstr(status));
108 if (level == 1 && r.out.total) {
110 for (i=0;i<*r.out.total;i++) {
111 const char *root = r.out.info->e.info1->s[i].path;
112 if (!test_Info(p, mem_ctx, root)) {
123 static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
126 uint16_t levels[] = {1, 2, 3, 4, 200, 300};
128 for (i=0;i<ARRAY_SIZE(levels);i++) {
129 if (!test_EnumLevel(p, mem_ctx, levels[i])) {
137 static BOOL test_Add(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
141 struct dfs_Remove rem;
143 add.in.path = "\\\\win2003\\2nd root\\test";
144 add.in.server = "win2003";
146 add.in.comment = "a test comment";
149 status = dcerpc_dfs_Add(p, mem_ctx, &add);
150 if (!NT_STATUS_IS_OK(status)) {
151 printf("Add failed - %s\n", nt_errstr(status));
155 rem.in.path = add.in.path;
156 rem.in.server = add.in.server;
157 rem.in.share = add.in.share;
159 status = dcerpc_dfs_Remove(p, mem_ctx, &rem);
160 if (!NT_STATUS_IS_OK(status)) {
161 printf("Add failed - %s\n", nt_errstr(status));
169 BOOL torture_rpc_dfs(struct torture_context *torture)
172 struct dcerpc_pipe *p;
176 mem_ctx = talloc_init("torture_rpc_dfs");
178 status = torture_rpc_connection(mem_ctx,
180 &dcerpc_table_netdfs);
181 if (!NT_STATUS_IS_OK(status)) {
185 if (!test_GetManagerVersion(p, mem_ctx)) {
190 if (!test_Add(p, mem_ctx)) {
195 if (!test_Enum(p, mem_ctx)) {
199 talloc_free(mem_ctx);