2007-10-16 15:44:43 +04:00
/*
Unix SMB / CIFS implementation .
test suite for rpc frsapi operations
Copyright ( C ) Guenther Deschner 2007
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2008-03-28 09:08:49 +03:00
the Free Software Foundation ; either version 3 of the License , or
2007-10-16 15:44:43 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2007-10-16 15:44:43 +04:00
# include "librpc/gen_ndr/ndr_frsapi_c.h"
2007-10-18 23:23:25 +04:00
# include "param/param.h"
2007-10-16 15:44:43 +04:00
static bool test_GetDsPollingIntervalW ( struct torture_context * tctx ,
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b ,
2007-10-16 15:44:43 +04:00
uint32_t * CurrentInterval ,
uint32_t * DsPollingLongInterval ,
uint32_t * DsPollingShortInterval )
{
struct frsapi_GetDsPollingIntervalW r ;
ZERO_STRUCT ( r ) ;
r . out . CurrentInterval = CurrentInterval ;
r . out . DsPollingLongInterval = DsPollingLongInterval ;
r . out . DsPollingShortInterval = DsPollingShortInterval ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:24:56 +03:00
dcerpc_frsapi_GetDsPollingIntervalW_r ( b , tctx , & r ) ,
2007-10-16 15:44:43 +04:00
" GetDsPollingIntervalW failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" GetDsPollingIntervalW failed " ) ;
return true ;
}
static bool test_SetDsPollingIntervalW ( struct torture_context * tctx ,
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b ,
2007-10-16 15:44:43 +04:00
uint32_t CurrentInterval ,
uint32_t DsPollingLongInterval ,
uint32_t DsPollingShortInterval )
{
struct frsapi_SetDsPollingIntervalW r ;
ZERO_STRUCT ( r ) ;
r . in . CurrentInterval = CurrentInterval ;
r . in . DsPollingLongInterval = DsPollingLongInterval ;
r . in . DsPollingShortInterval = DsPollingShortInterval ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:24:56 +03:00
dcerpc_frsapi_SetDsPollingIntervalW_r ( b , tctx , & r ) ,
2007-10-16 15:44:43 +04:00
" SetDsPollingIntervalW failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" SetDsPollingIntervalW failed " ) ;
return true ;
}
static bool test_DsPollingIntervalW ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-10-16 15:44:43 +04:00
uint32_t i1 , i2 , i3 ;
uint32_t k1 , k2 , k3 ;
2010-03-18 12:24:56 +03:00
if ( ! test_GetDsPollingIntervalW ( tctx , b , & i1 , & i2 , & i3 ) ) {
2007-10-16 15:44:43 +04:00
return false ;
}
2010-03-18 12:24:56 +03:00
if ( ! test_SetDsPollingIntervalW ( tctx , b , i1 , i2 , i3 ) ) {
2007-10-16 15:44:43 +04:00
return false ;
}
k1 = i1 ;
k2 = k3 = 0 ;
2010-03-18 12:24:56 +03:00
if ( ! test_SetDsPollingIntervalW ( tctx , b , k1 , k2 , k3 ) ) {
2007-10-16 15:44:43 +04:00
return false ;
}
2010-03-18 12:24:56 +03:00
if ( ! test_GetDsPollingIntervalW ( tctx , b , & k1 , & k2 , & k3 ) ) {
2007-10-16 15:44:43 +04:00
return false ;
}
if ( ( i1 ! = k1 ) | | ( i2 ! = k2 ) | | ( i3 ! = k3 ) ) {
return false ;
}
return true ;
}
2007-10-16 16:33:34 +04:00
static bool test_IsPathReplicated_err ( struct torture_context * tctx ,
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b ,
2007-10-16 16:33:34 +04:00
const char * path ,
uint32_t type ,
WERROR werr )
{
struct frsapi_IsPathReplicated r ;
struct GUID guid ;
2009-07-21 18:04:07 +04:00
uint32_t replicated , primary , root ;
2007-10-16 16:33:34 +04:00
ZERO_STRUCT ( r ) ;
r . in . path = path ;
r . in . replica_set_type = type ;
2009-07-21 18:04:07 +04:00
r . out . replicated = & replicated ;
r . out . primary = & primary ;
r . out . root = & root ;
2007-10-16 16:33:34 +04:00
r . out . replica_set_guid = & guid ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:24:56 +03:00
dcerpc_frsapi_IsPathReplicated_r ( b , tctx , & r ) ,
2007-10-16 16:33:34 +04:00
" IsPathReplicated failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result , werr ,
" GetDsPollingIntervalW failed " ) ;
return true ;
}
static bool _test_IsPathReplicated ( struct torture_context * tctx ,
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b ,
2007-10-16 16:33:34 +04:00
const char * path ,
uint32_t type )
{
2010-03-18 12:24:56 +03:00
return test_IsPathReplicated_err ( tctx , b , path , type , WERR_OK ) ;
2007-10-16 16:33:34 +04:00
}
static bool test_IsPathReplicated ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-10-16 16:33:34 +04:00
const uint32_t lvls [ ] = {
FRSAPI_REPLICA_SET_TYPE_0 ,
FRSAPI_REPLICA_SET_TYPE_DOMAIN ,
FRSAPI_REPLICA_SET_TYPE_DFS } ;
int i ;
2007-10-18 23:23:25 +04:00
bool ret = true ;
2007-10-16 16:33:34 +04:00
2010-03-18 12:24:56 +03:00
if ( ! test_IsPathReplicated_err ( tctx , b , NULL , 0 ,
2007-10-16 16:33:34 +04:00
WERR_FRS_INVALID_SERVICE_PARAMETER ) ) {
2007-10-18 23:23:25 +04:00
ret = false ;
2007-10-16 16:33:34 +04:00
}
for ( i = 0 ; i < ARRAY_SIZE ( lvls ) ; i + + ) {
2010-03-18 12:24:56 +03:00
if ( ! _test_IsPathReplicated ( tctx , b , dcerpc_server_name ( p ) ,
2007-10-16 16:33:34 +04:00
lvls [ i ] ) ) {
2007-10-18 23:23:25 +04:00
ret = false ;
2007-10-16 16:33:34 +04:00
}
}
for ( i = 0 ; i < ARRAY_SIZE ( lvls ) ; i + + ) {
const char * path = talloc_asprintf ( tctx , " \\ \\ %s \\ SYSVOL " ,
dcerpc_server_name ( p ) ) ;
2010-03-18 12:24:56 +03:00
if ( ! _test_IsPathReplicated ( tctx , b , path , lvls [ i ] ) ) {
2007-10-18 23:23:25 +04:00
ret = false ;
2007-10-16 16:33:34 +04:00
}
}
for ( i = 0 ; i < ARRAY_SIZE ( lvls ) ; i + + ) {
2010-03-18 12:24:56 +03:00
if ( ! _test_IsPathReplicated ( tctx , b ,
2007-10-16 16:33:34 +04:00
" C: \\ windows \\ sysvol \\ domain " ,
lvls [ i ] ) ) {
2007-10-18 23:23:25 +04:00
ret = false ;
2007-10-16 16:33:34 +04:00
}
}
2007-10-18 23:23:25 +04:00
return ret ;
}
static bool test_ForceReplication ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-10-18 23:23:25 +04:00
struct frsapi_ForceReplication r ;
ZERO_STRUCT ( r ) ;
2009-07-21 18:04:07 +04:00
r . in . replica_set_guid = NULL ;
r . in . connection_guid = NULL ;
2010-07-16 08:32:42 +04:00
r . in . replica_set_name = lpcfg_dnsdomain ( tctx - > lp_ctx ) ;
2009-07-21 18:04:07 +04:00
r . in . partner_dns_name = dcerpc_server_name ( p ) ;
2007-10-18 23:23:25 +04:00
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:24:56 +03:00
dcerpc_frsapi_ForceReplication_r ( b , tctx , & r ) ,
2007-10-18 23:23:25 +04:00
" ForceReplication failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" ForceReplication failed " ) ;
2007-10-16 16:33:34 +04:00
return true ;
}
2007-11-02 17:43:09 +03:00
static bool test_InfoW ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
2010-03-18 12:24:56 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2007-11-02 17:43:09 +03:00
int i ;
for ( i = 0 ; i < 10 ; i + + ) {
struct frsapi_InfoW r ;
struct frsapi_Info * info ;
int d ;
DATA_BLOB blob ;
ZERO_STRUCT ( r ) ;
info = talloc_zero ( tctx , struct frsapi_Info ) ;
r . in . length = 0x1000 ;
r . in . info = r . out . info = info ;
info - > length = r . in . length ;
info - > length2 = r . in . length ;
info - > level = i ;
info - > offset = 0x2c ;
info - > blob_len = 0x2c ;
torture_assert_ntstatus_ok ( tctx ,
2010-03-18 12:24:56 +03:00
dcerpc_frsapi_InfoW_r ( b , tctx , & r ) ,
2007-11-02 17:43:09 +03:00
" InfoW failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result , " InfoW failed " ) ;
/* display the formatted blob text */
blob = r . out . info - > blob ;
for ( d = 0 ; d < blob . length ; d + + ) {
if ( blob . data [ d ] ) {
printf ( " %c " , blob . data [ d ] ) ;
}
}
printf ( " \n " ) ;
}
return true ;
}
2007-10-16 15:44:43 +04:00
struct torture_suite * torture_rpc_frsapi ( TALLOC_CTX * mem_ctx )
{
struct torture_rpc_tcase * tcase ;
2010-12-11 05:26:31 +03:00
struct torture_suite * suite = torture_suite_create ( mem_ctx , " frsapi " ) ;
2007-10-16 15:44:43 +04:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " frsapi " ,
& ndr_table_frsapi ) ;
2014-02-04 13:08:48 +04:00
torture_rpc_tcase_add_test ( tcase , " DsPollingIntervalW " ,
test_DsPollingIntervalW ) ;
2007-10-16 15:44:43 +04:00
2014-02-04 13:08:48 +04:00
torture_rpc_tcase_add_test ( tcase , " IsPathReplicated " ,
test_IsPathReplicated ) ;
2007-10-16 16:33:34 +04:00
2014-02-04 13:08:48 +04:00
torture_rpc_tcase_add_test ( tcase , " ForceReplication " ,
test_ForceReplication ) ;
torture_rpc_tcase_add_test ( tcase , " InfoW " ,
test_InfoW ) ;
2007-10-18 23:23:25 +04:00
2007-10-16 15:44:43 +04:00
return suite ;
}