s4-smbtorture: disable winreg QueryValue test for today.
[Samba/nascimento.git] / source4 / torture / rpc / frsapi.c
blob78347775d0d58b5910f38d860056e6aa40d652d0
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for rpc frsapi operations
5 Copyright (C) Guenther Deschner 2007
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 3 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.
22 #include "includes.h"
23 #include "torture/rpc/rpc.h"
24 #include "librpc/gen_ndr/ndr_frsapi_c.h"
25 #include "param/param.h"
27 static bool test_GetDsPollingIntervalW(struct torture_context *tctx,
28 struct dcerpc_pipe *p,
29 uint32_t *CurrentInterval,
30 uint32_t *DsPollingLongInterval,
31 uint32_t *DsPollingShortInterval)
33 struct frsapi_GetDsPollingIntervalW r;
35 ZERO_STRUCT(r);
37 r.out.CurrentInterval = CurrentInterval;
38 r.out.DsPollingLongInterval = DsPollingLongInterval;
39 r.out.DsPollingShortInterval = DsPollingShortInterval;
41 torture_assert_ntstatus_ok(tctx,
42 dcerpc_frsapi_GetDsPollingIntervalW(p, tctx, &r),
43 "GetDsPollingIntervalW failed");
45 torture_assert_werr_ok(tctx, r.out.result,
46 "GetDsPollingIntervalW failed");
48 return true;
51 static bool test_SetDsPollingIntervalW(struct torture_context *tctx,
52 struct dcerpc_pipe *p,
53 uint32_t CurrentInterval,
54 uint32_t DsPollingLongInterval,
55 uint32_t DsPollingShortInterval)
57 struct frsapi_SetDsPollingIntervalW r;
59 ZERO_STRUCT(r);
61 r.in.CurrentInterval = CurrentInterval;
62 r.in.DsPollingLongInterval = DsPollingLongInterval;
63 r.in.DsPollingShortInterval = DsPollingShortInterval;
65 torture_assert_ntstatus_ok(tctx,
66 dcerpc_frsapi_SetDsPollingIntervalW(p, tctx, &r),
67 "SetDsPollingIntervalW failed");
69 torture_assert_werr_ok(tctx, r.out.result,
70 "SetDsPollingIntervalW failed");
72 return true;
75 static bool test_DsPollingIntervalW(struct torture_context *tctx,
76 struct dcerpc_pipe *p)
78 uint32_t i1, i2, i3;
79 uint32_t k1, k2, k3;
81 if (!test_GetDsPollingIntervalW(tctx, p, &i1, &i2, &i3)) {
82 return false;
85 if (!test_SetDsPollingIntervalW(tctx, p, i1, i2, i3)) {
86 return false;
89 k1 = i1;
90 k2 = k3 = 0;
92 if (!test_SetDsPollingIntervalW(tctx, p, k1, k2, k3)) {
93 return false;
96 if (!test_GetDsPollingIntervalW(tctx, p, &k1, &k2, &k3)) {
97 return false;
100 if ((i1 != k1) || (i2 != k2) || (i3 != k3)) {
101 return false;
104 return true;
107 static bool test_IsPathReplicated_err(struct torture_context *tctx,
108 struct dcerpc_pipe *p,
109 const char *path,
110 uint32_t type,
111 WERROR werr)
113 struct frsapi_IsPathReplicated r;
114 struct GUID guid;
115 uint32_t replicated, primary, root;
117 ZERO_STRUCT(r);
119 r.in.path = path;
120 r.in.replica_set_type = type;
121 r.out.replicated = &replicated;
122 r.out.primary = &primary;
123 r.out.root = &root;
124 r.out.replica_set_guid = &guid;
126 torture_assert_ntstatus_ok(tctx,
127 dcerpc_frsapi_IsPathReplicated(p, tctx, &r),
128 "IsPathReplicated failed");
130 torture_assert_werr_equal(tctx, r.out.result, werr,
131 "GetDsPollingIntervalW failed");
133 return true;
136 static bool _test_IsPathReplicated(struct torture_context *tctx,
137 struct dcerpc_pipe *p,
138 const char *path,
139 uint32_t type)
141 return test_IsPathReplicated_err(tctx, p, path, type, WERR_OK);
144 static bool test_IsPathReplicated(struct torture_context *tctx,
145 struct dcerpc_pipe *p)
147 const uint32_t lvls[] = {
148 FRSAPI_REPLICA_SET_TYPE_0,
149 FRSAPI_REPLICA_SET_TYPE_DOMAIN,
150 FRSAPI_REPLICA_SET_TYPE_DFS };
151 int i;
152 bool ret = true;
154 if (!test_IsPathReplicated_err(tctx, p, NULL, 0,
155 WERR_FRS_INVALID_SERVICE_PARAMETER)) {
156 ret = false;
159 for (i=0; i<ARRAY_SIZE(lvls); i++) {
160 if (!_test_IsPathReplicated(tctx, p, dcerpc_server_name(p),
161 lvls[i])) {
162 ret = false;
166 for (i=0; i<ARRAY_SIZE(lvls); i++) {
167 const char *path = talloc_asprintf(tctx, "\\\\%s\\SYSVOL",
168 dcerpc_server_name(p));
169 if (!_test_IsPathReplicated(tctx, p, path, lvls[i])) {
170 ret = false;
174 for (i=0; i<ARRAY_SIZE(lvls); i++) {
175 if (!_test_IsPathReplicated(tctx, p,
176 "C:\\windows\\sysvol\\domain",
177 lvls[i])) {
178 ret = false;
182 return ret;
185 static bool test_ForceReplication(struct torture_context *tctx,
186 struct dcerpc_pipe *p)
188 struct frsapi_ForceReplication r;
190 ZERO_STRUCT(r);
192 r.in.replica_set_guid = NULL;
193 r.in.connection_guid = NULL;
194 r.in.replica_set_name = lp_dnsdomain(tctx->lp_ctx);
195 r.in.partner_dns_name = dcerpc_server_name(p);
197 torture_assert_ntstatus_ok(tctx,
198 dcerpc_frsapi_ForceReplication(p, tctx, &r),
199 "ForceReplication failed");
201 torture_assert_werr_ok(tctx, r.out.result,
202 "ForceReplication failed");
204 return true;
207 static bool test_InfoW(struct torture_context *tctx,
208 struct dcerpc_pipe *p)
210 int i;
212 for (i=0; i<10; i++) {
214 struct frsapi_InfoW r;
215 struct frsapi_Info *info;
216 int d;
217 DATA_BLOB blob;
219 ZERO_STRUCT(r);
221 info = talloc_zero(tctx, struct frsapi_Info);
223 r.in.length = 0x1000;
224 r.in.info = r.out.info = info;
226 info->length = r.in.length;
227 info->length2 = r.in.length;
228 info->level = i;
229 info->offset = 0x2c;
230 info->blob_len = 0x2c;
232 torture_assert_ntstatus_ok(tctx,
233 dcerpc_frsapi_InfoW(p, tctx, &r),
234 "InfoW failed");
236 torture_assert_werr_ok(tctx, r.out.result, "InfoW failed");
238 /* display the formatted blob text */
239 blob = r.out.info->blob;
240 for (d = 0; d < blob.length; d++) {
241 if (blob.data[d]) {
242 printf("%c", blob.data[d]);
245 printf("\n");
248 return true;
251 struct torture_suite *torture_rpc_frsapi(TALLOC_CTX *mem_ctx)
253 struct torture_rpc_tcase *tcase;
254 struct torture_suite *suite = torture_suite_create(mem_ctx, "FRSAPI");
255 struct torture_test *test;
257 tcase = torture_suite_add_rpc_iface_tcase(suite, "frsapi",
258 &ndr_table_frsapi);
260 test = torture_rpc_tcase_add_test(tcase, "DsPollingIntervalW",
261 test_DsPollingIntervalW);
263 test = torture_rpc_tcase_add_test(tcase, "IsPathReplicated",
264 test_IsPathReplicated);
266 test = torture_rpc_tcase_add_test(tcase, "ForceReplication",
267 test_ForceReplication);
269 test = torture_rpc_tcase_add_test(tcase, "InfoW",
270 test_InfoW);
271 return suite;