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_pipe
*p
,
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(p
, 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_pipe
*p
,
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(p
, 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
)
81 if (!test_GetDsPollingIntervalW(tctx
, p
, &i1
, &i2
, &i3
)) {
85 if (!test_SetDsPollingIntervalW(tctx
, p
, i1
, i2
, i3
)) {
92 if (!test_SetDsPollingIntervalW(tctx
, p
, k1
, k2
, k3
)) {
96 if (!test_GetDsPollingIntervalW(tctx
, p
, &k1
, &k2
, &k3
)) {
100 if ((i1
!= k1
) || (i2
!= k2
) || (i3
!= k3
)) {
107 static bool test_IsPathReplicated_err(struct torture_context
*tctx
,
108 struct dcerpc_pipe
*p
,
113 struct frsapi_IsPathReplicated r
;
115 uint32_t replicated
, primary
, root
;
120 r
.in
.replica_set_type
= type
;
121 r
.out
.replicated
= &replicated
;
122 r
.out
.primary
= &primary
;
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");
136 static bool _test_IsPathReplicated(struct torture_context
*tctx
,
137 struct dcerpc_pipe
*p
,
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
};
154 if (!test_IsPathReplicated_err(tctx
, p
, NULL
, 0,
155 WERR_FRS_INVALID_SERVICE_PARAMETER
)) {
159 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
160 if (!_test_IsPathReplicated(tctx
, p
, dcerpc_server_name(p
),
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
])) {
174 for (i
=0; i
<ARRAY_SIZE(lvls
); i
++) {
175 if (!_test_IsPathReplicated(tctx
, p
,
176 "C:\\windows\\sysvol\\domain",
185 static bool test_ForceReplication(struct torture_context
*tctx
,
186 struct dcerpc_pipe
*p
)
188 struct frsapi_ForceReplication 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");
207 static bool test_InfoW(struct torture_context
*tctx
,
208 struct dcerpc_pipe
*p
)
212 for (i
=0; i
<10; i
++) {
214 struct frsapi_InfoW r
;
215 struct frsapi_Info
*info
;
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
;
230 info
->blob_len
= 0x2c;
232 torture_assert_ntstatus_ok(tctx
,
233 dcerpc_frsapi_InfoW(p
, tctx
, &r
),
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
++) {
242 printf("%c", blob
.data
[d
]);
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",
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",