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.
23 #include "torture/torture.h"
24 #include "torture/rpc/rpc.h"
25 #include "librpc/gen_ndr/ndr_frsapi_c.h"
26 #include "torture/util.h"
27 #include "param/param.h"
29 static bool test_GetDsPollingIntervalW(struct torture_context
*tctx
,
30 struct dcerpc_pipe
*p
,
31 uint32_t *CurrentInterval
,
32 uint32_t *DsPollingLongInterval
,
33 uint32_t *DsPollingShortInterval
)
35 struct frsapi_GetDsPollingIntervalW r
;
39 r
.out
.CurrentInterval
= CurrentInterval
;
40 r
.out
.DsPollingLongInterval
= DsPollingLongInterval
;
41 r
.out
.DsPollingShortInterval
= DsPollingShortInterval
;
43 torture_assert_ntstatus_ok(tctx
,
44 dcerpc_frsapi_GetDsPollingIntervalW(p
, tctx
, &r
),
45 "GetDsPollingIntervalW failed");
47 torture_assert_werr_ok(tctx
, r
.out
.result
,
48 "GetDsPollingIntervalW failed");
53 static bool test_SetDsPollingIntervalW(struct torture_context
*tctx
,
54 struct dcerpc_pipe
*p
,
55 uint32_t CurrentInterval
,
56 uint32_t DsPollingLongInterval
,
57 uint32_t DsPollingShortInterval
)
59 struct frsapi_SetDsPollingIntervalW r
;
63 r
.in
.CurrentInterval
= CurrentInterval
;
64 r
.in
.DsPollingLongInterval
= DsPollingLongInterval
;
65 r
.in
.DsPollingShortInterval
= DsPollingShortInterval
;
67 torture_assert_ntstatus_ok(tctx
,
68 dcerpc_frsapi_SetDsPollingIntervalW(p
, tctx
, &r
),
69 "SetDsPollingIntervalW failed");
71 torture_assert_werr_ok(tctx
, r
.out
.result
,
72 "SetDsPollingIntervalW failed");
77 static bool test_DsPollingIntervalW(struct torture_context
*tctx
,
78 struct dcerpc_pipe
*p
)
83 if (!test_GetDsPollingIntervalW(tctx
, p
, &i1
, &i2
, &i3
)) {
87 if (!test_SetDsPollingIntervalW(tctx
, p
, i1
, i2
, i3
)) {
94 if (!test_SetDsPollingIntervalW(tctx
, p
, k1
, k2
, k3
)) {
98 if (!test_GetDsPollingIntervalW(tctx
, p
, &k1
, &k2
, &k3
)) {
102 if ((i1
!= k1
) || (i2
!= k2
) || (i3
!= k3
)) {
109 static bool test_IsPathReplicated_err(struct torture_context
*tctx
,
110 struct dcerpc_pipe
*p
,
115 struct frsapi_IsPathReplicated r
;
117 uint32_t unknown1
, unknown2
, unknown3
= 0;
122 r
.in
.replica_set_type
= type
;
123 r
.out
.unknown1
= &unknown1
;
124 r
.out
.unknown2
= &unknown2
;
125 r
.out
.unknown3
= &unknown3
;
126 r
.out
.replica_set_guid
= &guid
;
128 torture_assert_ntstatus_ok(tctx
,
129 dcerpc_frsapi_IsPathReplicated(p
, tctx
, &r
),
130 "IsPathReplicated failed");
132 torture_assert_werr_equal(tctx
, r
.out
.result
, werr
,
133 "GetDsPollingIntervalW failed");
138 static bool _test_IsPathReplicated(struct torture_context
*tctx
,
139 struct dcerpc_pipe
*p
,
143 return test_IsPathReplicated_err(tctx
, p
, path
, type
, WERR_OK
);
146 static bool test_IsPathReplicated(struct torture_context
*tctx
,
147 struct dcerpc_pipe
*p
)
149 const uint32_t lvls
[] = {
150 FRSAPI_REPLICA_SET_TYPE_0
,
151 FRSAPI_REPLICA_SET_TYPE_DOMAIN
,
152 FRSAPI_REPLICA_SET_TYPE_DFS
};
156 if (!test_IsPathReplicated_err(tctx
, p
, NULL
, 0,
157 WERR_FRS_INVALID_SERVICE_PARAMETER
)) {
161 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
162 if (!_test_IsPathReplicated(tctx
, p
, dcerpc_server_name(p
),
168 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
169 const char *path
= talloc_asprintf(tctx
, "\\\\%s\\SYSVOL",
170 dcerpc_server_name(p
));
171 if (!_test_IsPathReplicated(tctx
, p
, path
, lvls
[i
])) {
176 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
177 if (!_test_IsPathReplicated(tctx
, p
,
178 "C:\\windows\\sysvol\\domain",
187 static bool test_ForceReplication(struct torture_context
*tctx
,
188 struct dcerpc_pipe
*p
)
190 struct frsapi_ForceReplication r
;
196 r
.in
.replica_set
= talloc_asprintf(tctx
, "%s",
197 lp_realm(tctx
->lp_ctx
));
198 r
.in
.partner_name
= dcerpc_server_name(p
);
200 torture_assert_ntstatus_ok(tctx
,
201 dcerpc_frsapi_ForceReplication(p
, tctx
, &r
),
202 "ForceReplication failed");
204 torture_assert_werr_ok(tctx
, r
.out
.result
,
205 "ForceReplication failed");
210 static bool test_InfoW(struct torture_context
*tctx
,
211 struct dcerpc_pipe
*p
)
215 for (i
=0; i
<10; i
++) {
217 struct frsapi_InfoW r
;
218 struct frsapi_Info
*info
;
224 info
= talloc_zero(tctx
, struct frsapi_Info
);
226 r
.in
.length
= 0x1000;
227 r
.in
.info
= r
.out
.info
= info
;
229 info
->length
= r
.in
.length
;
230 info
->length2
= r
.in
.length
;
233 info
->blob_len
= 0x2c;
235 torture_assert_ntstatus_ok(tctx
,
236 dcerpc_frsapi_InfoW(p
, tctx
, &r
),
239 torture_assert_werr_ok(tctx
, r
.out
.result
, "InfoW failed");
241 /* display the formatted blob text */
242 blob
= r
.out
.info
->blob
;
243 for (d
= 0; d
< blob
.length
; d
++) {
245 printf("%c", blob
.data
[d
]);
254 struct torture_suite
*torture_rpc_frsapi(TALLOC_CTX
*mem_ctx
)
256 struct torture_rpc_tcase
*tcase
;
257 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "FRSAPI");
258 struct torture_test
*test
;
260 tcase
= torture_suite_add_rpc_iface_tcase(suite
, "frsapi",
263 test
= torture_rpc_tcase_add_test(tcase
, "DsPollingIntervalW",
264 test_DsPollingIntervalW
);
266 test
= torture_rpc_tcase_add_test(tcase
, "IsPathReplicated",
267 test_IsPathReplicated
);
269 test
= torture_rpc_tcase_add_test(tcase
, "ForceReplication",
270 test_ForceReplication
);
272 test
= torture_rpc_tcase_add_test(tcase
, "InfoW",