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/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_binding_handle
*b
,
29 uint32_t *CurrentInterval
,
30 uint32_t *DsPollingLongInterval
,
31 uint32_t *DsPollingShortInterval
)
33 struct frsapi_GetDsPollingIntervalW 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_r(b
, tctx
, &r
),
43 "GetDsPollingIntervalW failed");
45 torture_assert_werr_ok(tctx
, r
.out
.result
,
46 "GetDsPollingIntervalW failed");
51 static bool test_SetDsPollingIntervalW(struct torture_context
*tctx
,
52 struct dcerpc_binding_handle
*b
,
53 uint32_t CurrentInterval
,
54 uint32_t DsPollingLongInterval
,
55 uint32_t DsPollingShortInterval
)
57 struct frsapi_SetDsPollingIntervalW 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_r(b
, tctx
, &r
),
67 "SetDsPollingIntervalW failed");
69 torture_assert_werr_ok(tctx
, r
.out
.result
,
70 "SetDsPollingIntervalW failed");
75 static bool test_DsPollingIntervalW(struct torture_context
*tctx
,
76 struct dcerpc_pipe
*p
)
78 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
82 if (!test_GetDsPollingIntervalW(tctx
, b
, &i1
, &i2
, &i3
)) {
86 if (!test_SetDsPollingIntervalW(tctx
, b
, i1
, i2
, i3
)) {
93 if (!test_SetDsPollingIntervalW(tctx
, b
, k1
, k2
, k3
)) {
97 if (!test_GetDsPollingIntervalW(tctx
, b
, &k1
, &k2
, &k3
)) {
101 if ((i1
!= k1
) || (i2
!= k2
) || (i3
!= k3
)) {
108 static bool test_IsPathReplicated_err(struct torture_context
*tctx
,
109 struct dcerpc_binding_handle
*b
,
114 struct frsapi_IsPathReplicated r
;
116 uint32_t replicated
, primary
, root
;
121 r
.in
.replica_set_type
= type
;
122 r
.out
.replicated
= &replicated
;
123 r
.out
.primary
= &primary
;
125 r
.out
.replica_set_guid
= &guid
;
127 torture_assert_ntstatus_ok(tctx
,
128 dcerpc_frsapi_IsPathReplicated_r(b
, tctx
, &r
),
129 "IsPathReplicated failed");
131 torture_assert_werr_equal(tctx
, r
.out
.result
, werr
,
132 "GetDsPollingIntervalW failed");
137 static bool _test_IsPathReplicated(struct torture_context
*tctx
,
138 struct dcerpc_binding_handle
*b
,
142 return test_IsPathReplicated_err(tctx
, b
, path
, type
, WERR_OK
);
145 static bool test_IsPathReplicated(struct torture_context
*tctx
,
146 struct dcerpc_pipe
*p
)
148 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
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
, b
, NULL
, 0,
157 WERR_FRS_INVALID_SERVICE_PARAMETER
)) {
161 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
162 if (!_test_IsPathReplicated(tctx
, b
, 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
, b
, path
, lvls
[i
])) {
176 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
177 if (!_test_IsPathReplicated(tctx
, b
,
178 "C:\\windows\\sysvol\\domain",
187 static bool test_ForceReplication(struct torture_context
*tctx
,
188 struct dcerpc_pipe
*p
)
190 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
191 struct frsapi_ForceReplication r
;
195 r
.in
.replica_set_guid
= NULL
;
196 r
.in
.connection_guid
= NULL
;
197 r
.in
.replica_set_name
= lp_dnsdomain(tctx
->lp_ctx
);
198 r
.in
.partner_dns_name
= dcerpc_server_name(p
);
200 torture_assert_ntstatus_ok(tctx
,
201 dcerpc_frsapi_ForceReplication_r(b
, 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
)
213 struct dcerpc_binding_handle
*b
= p
->binding_handle
;
216 for (i
=0; i
<10; i
++) {
218 struct frsapi_InfoW r
;
219 struct frsapi_Info
*info
;
225 info
= talloc_zero(tctx
, struct frsapi_Info
);
227 r
.in
.length
= 0x1000;
228 r
.in
.info
= r
.out
.info
= info
;
230 info
->length
= r
.in
.length
;
231 info
->length2
= r
.in
.length
;
234 info
->blob_len
= 0x2c;
236 torture_assert_ntstatus_ok(tctx
,
237 dcerpc_frsapi_InfoW_r(b
, tctx
, &r
),
240 torture_assert_werr_ok(tctx
, r
.out
.result
, "InfoW failed");
242 /* display the formatted blob text */
243 blob
= r
.out
.info
->blob
;
244 for (d
= 0; d
< blob
.length
; d
++) {
246 printf("%c", blob
.data
[d
]);
255 struct torture_suite
*torture_rpc_frsapi(TALLOC_CTX
*mem_ctx
)
257 struct torture_rpc_tcase
*tcase
;
258 struct torture_suite
*suite
= torture_suite_create(mem_ctx
, "FRSAPI");
259 struct torture_test
*test
;
261 tcase
= torture_suite_add_rpc_iface_tcase(suite
, "frsapi",
264 test
= torture_rpc_tcase_add_test(tcase
, "DsPollingIntervalW",
265 test_DsPollingIntervalW
);
267 test
= torture_rpc_tcase_add_test(tcase
, "IsPathReplicated",
268 test_IsPathReplicated
);
270 test
= torture_rpc_tcase_add_test(tcase
, "ForceReplication",
271 test_ForceReplication
);
273 test
= torture_rpc_tcase_add_test(tcase
, "InfoW",