2015-02-27 01:03:36 +03:00
/*
Unix SMB / CIFS implementation .
test suite for clusapi rpc operations
Copyright ( C ) Günther Deschner 2015
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
the Free Software Foundation ; either version 3 of the License , or
( 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 , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
# include "librpc/gen_ndr/ndr_clusapi_c.h"
# include "torture/rpc/torture_rpc.h"
# include "param/param.h"
static bool test_OpenCluster_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Cluster )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenCluster r ;
2015-03-02 22:52:59 +03:00
WERROR Status ;
2015-02-27 01:03:36 +03:00
r . out . Status = & Status ;
r . out . Cluster = Cluster ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenCluster_r ( b , tctx , & r ) ,
" OpenCluster failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
* r . out . Status ,
2015-02-27 01:03:36 +03:00
" OpenCluster failed " ) ;
return true ;
}
2015-03-05 23:31:17 +03:00
static bool test_OpenClusterEx_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Cluster )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenClusterEx r ;
uint32_t lpdwGrantedAccess ;
WERROR Status ;
r . in . dwDesiredAccess = SEC_FLAG_MAXIMUM_ALLOWED ;
r . out . lpdwGrantedAccess = & lpdwGrantedAccess ;
r . out . Status = & Status ;
r . out . hCluster = Cluster ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenClusterEx_r ( b , tctx , & r ) ,
" OpenClusterEx failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenClusterEx failed " ) ;
return true ;
}
2015-02-27 01:03:36 +03:00
static bool test_CloseCluster_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Cluster )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CloseCluster r ;
r . in . Cluster = Cluster ;
r . out . Cluster = Cluster ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CloseCluster_r ( b , tctx , & r ) ,
" CloseCluster failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-02-27 01:03:36 +03:00
" CloseCluster failed " ) ;
torture_assert ( tctx ,
ndr_policy_handle_empty ( Cluster ) ,
" policy_handle non empty after CloseCluster " ) ;
return true ;
}
static bool test_OpenCluster ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle Cluster ;
if ( ! test_OpenCluster_int ( tctx , p , & Cluster ) ) {
return false ;
}
test_CloseCluster_int ( tctx , p , & Cluster ) ;
return true ;
}
2015-03-05 23:31:17 +03:00
static bool test_OpenClusterEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle Cluster ;
if ( ! test_OpenClusterEx_int ( tctx , p , & Cluster ) ) {
return false ;
}
test_CloseCluster_int ( tctx , p , & Cluster ) ;
return true ;
}
2015-02-27 01:03:36 +03:00
static bool test_CloseCluster ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle Cluster ;
if ( ! test_OpenCluster_int ( tctx , p , & Cluster ) ) {
return false ;
}
return test_CloseCluster_int ( tctx , p , & Cluster ) ;
}
2015-03-04 17:34:29 +03:00
static bool test_GetClusterName_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * * ClusterName )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetClusterName r ;
const char * NodeName ;
r . out . ClusterName = ClusterName ;
r . out . NodeName = & NodeName ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetClusterName_r ( b , tctx , & r ) ,
" GetClusterName failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetClusterName failed " ) ;
return true ;
}
2015-02-27 19:45:02 +03:00
static bool test_SetClusterName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_SetClusterName r ;
2015-03-04 17:34:29 +03:00
const char * NewClusterName ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-02-27 19:45:02 +03:00
2015-03-04 17:34:29 +03:00
torture_assert ( tctx ,
test_GetClusterName_int ( tctx , p , & NewClusterName ) ,
" failed to query old ClusterName " ) ;
r . in . NewClusterName = NewClusterName ;
2015-02-27 19:45:02 +03:00
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_SetClusterName_r ( b , tctx , & r ) ,
" SetClusterName failed " ) ;
2015-03-04 17:34:29 +03:00
torture_assert_werr_equal ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-04 17:34:29 +03:00
WERR_RESOURCE_PROPERTIES_STORED ,
2015-02-27 19:45:02 +03:00
" SetClusterName failed " ) ;
return true ;
}
static bool test_GetClusterName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
const char * ClusterName ;
2015-03-04 17:34:29 +03:00
return test_GetClusterName_int ( tctx , p , & ClusterName ) ;
2015-02-27 19:45:02 +03:00
}
static bool test_GetClusterVersion ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetClusterVersion r ;
uint16_t lpwMajorVersion ;
uint16_t lpwMinorVersion ;
uint16_t lpwBuildNumber ;
const char * lpszVendorId ;
const char * lpszCSDVersion ;
r . out . lpwMajorVersion = & lpwMajorVersion ;
r . out . lpwMinorVersion = & lpwMinorVersion ;
r . out . lpwBuildNumber = & lpwBuildNumber ;
r . out . lpszVendorId = & lpszVendorId ;
r . out . lpszCSDVersion = & lpszCSDVersion ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetClusterVersion_r ( b , tctx , & r ) ,
" GetClusterVersion failed " ) ;
torture_assert_werr_equal ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-02-27 19:45:02 +03:00
WERR_CALL_NOT_IMPLEMENTED ,
" GetClusterVersion failed " ) ;
return true ;
}
2015-03-03 20:00:55 +03:00
static bool test_GetClusterVersion2 ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetClusterVersion2 r ;
uint16_t lpwMajorVersion ;
uint16_t lpwMinorVersion ;
uint16_t lpwBuildNumber ;
const char * lpszVendorId ;
const char * lpszCSDVersion ;
struct CLUSTER_OPERATIONAL_VERSION_INFO * ppClusterOpVerInfo ;
WERROR rpc_status ;
r . out . lpwMajorVersion = & lpwMajorVersion ;
r . out . lpwMinorVersion = & lpwMinorVersion ;
r . out . lpwBuildNumber = & lpwBuildNumber ;
r . out . lpszVendorId = & lpszVendorId ;
r . out . lpszCSDVersion = & lpszCSDVersion ;
r . out . ppClusterOpVerInfo = & ppClusterOpVerInfo ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetClusterVersion2_r ( b , tctx , & r ) ,
" GetClusterVersion2 failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetClusterVersion2 failed " ) ;
return true ;
}
2015-03-06 15:25:24 +03:00
static bool test_CreateEnum ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateEnum r ;
uint32_t dwType = CLUSTER_ENUM_RESOURCE ;
struct ENUM_LIST * ReturnEnum ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:25:24 +03:00
r . in . dwType = dwType ;
r . out . ReturnEnum = & ReturnEnum ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateEnum_r ( b , tctx , & r ) ,
" CreateEnum failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:25:24 +03:00
" CreateEnum failed " ) ;
return true ;
}
2015-03-06 15:34:44 +03:00
static bool test_GetQuorumResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetQuorumResource r ;
const char * lpszResourceName ;
const char * lpszDeviceName ;
uint32_t pdwMaxQuorumLogSize ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . out . lpszResourceName = & lpszResourceName ;
r . out . lpszDeviceName = & lpszDeviceName ;
r . out . pdwMaxQuorumLogSize = & pdwMaxQuorumLogSize ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetQuorumResource_r ( b , tctx , & r ) ,
" GetQuorumResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" GetQuorumResource failed " ) ;
return true ;
}
static bool test_SetQuorumResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_SetQuorumResource r ;
const char * lpszDeviceName = " " ;
uint32_t dwMaxQuorumLogSize = 0 ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
struct policy_handle hResource ;
/* we need to figure out how this call works and what we provide as
devicename and resource handle - gd
*/
torture_skip ( tctx , " skipping SetQuorumResource test " ) ;
ZERO_STRUCT ( hResource ) ;
r . in . hResource = hResource ;
r . in . lpszDeviceName = lpszDeviceName ;
r . in . dwMaxQuorumLogSize = dwMaxQuorumLogSize ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_SetQuorumResource_r ( b , tctx , & r ) ,
" SetQuorumResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" SetQuorumResource failed " ) ;
return true ;
}
static bool test_OpenResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
2015-03-05 18:39:37 +03:00
const char * lpszResourceName ,
2015-03-06 15:34:44 +03:00
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenResource r ;
2015-03-02 22:52:59 +03:00
WERROR Status ;
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . lpszResourceName = lpszResourceName ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hResource = hResource ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenResource_r ( b , tctx , & r ) ,
" OpenResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
* r . out . Status ,
2015-03-06 15:34:44 +03:00
" OpenResource failed " ) ;
return true ;
}
2015-03-06 01:43:40 +03:00
static bool test_OpenResourceEx_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * lpszResourceName ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenResourceEx r ;
uint32_t lpdwGrantedAccess ;
WERROR Status ;
WERROR rpc_status ;
r . in . lpszResourceName = lpszResourceName ;
r . in . dwDesiredAccess = SEC_FLAG_MAXIMUM_ALLOWED ;
r . out . lpdwGrantedAccess = & lpdwGrantedAccess ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hResource = hResource ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenResourceEx_r ( b , tctx , & r ) ,
" OpenResourceEx failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenResourceEx failed " ) ;
return true ;
}
2015-03-06 15:34:44 +03:00
static bool test_CloseResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CloseResource r ;
r . in . Resource = hResource ;
r . out . Resource = hResource ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CloseResource_r ( b , tctx , & r ) ,
" CloseResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" CloseResource failed " ) ;
torture_assert ( tctx ,
ndr_policy_handle_empty ( hResource ) ,
" policy_handle non empty after CloseResource " ) ;
return true ;
}
static bool test_OpenResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
test_CloseResource_int ( tctx , p , & hResource ) ;
return true ;
}
2015-03-06 01:43:40 +03:00
static bool test_OpenResourceEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
if ( ! test_OpenResourceEx_int ( tctx , p , " Cluster Name " , & hResource ) ) {
return false ;
}
test_CloseResource_int ( tctx , p , & hResource ) ;
return true ;
}
2015-03-06 15:34:44 +03:00
static bool test_CloseResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
return test_CloseResource_int ( tctx , p , & hResource ) ;
}
2015-03-06 15:51:34 +03:00
static bool test_OpenGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
2015-03-06 01:50:00 +03:00
const char * lpszGroupName ,
2015-03-06 15:51:34 +03:00
struct policy_handle * hGroup ) ;
static bool test_CloseGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Group ) ;
2015-03-06 15:34:44 +03:00
static bool test_CreateResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateResource r ;
2015-03-06 15:51:34 +03:00
const char * lpszResourceName = " wurst " ;
const char * lpszResourceType = " Generic Service " ;
2015-03-02 22:52:59 +03:00
WERROR Status ;
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
struct policy_handle hGroup ;
2015-03-06 15:51:34 +03:00
torture_assert ( tctx ,
2015-03-06 01:50:00 +03:00
test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ,
2015-03-06 15:51:34 +03:00
" failed to open group " ) ;
2015-03-06 15:34:44 +03:00
r . in . hGroup = hGroup ;
r . in . lpszResourceName = lpszResourceName ;
r . in . lpszResourceType = lpszResourceType ;
2015-03-05 14:04:02 +03:00
r . in . dwFlags = CLUSTER_RESOURCE_DEFAULT_MONITOR ;
2015-03-06 15:34:44 +03:00
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hResource = hResource ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateResource_r ( b , tctx , & r ) ,
" CreateResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
* r . out . Status ,
2015-03-06 15:34:44 +03:00
" CreateResource failed " ) ;
2015-03-06 15:51:34 +03:00
test_CloseGroup_int ( tctx , p , & hGroup ) ;
2015-03-06 15:34:44 +03:00
return true ;
}
static bool test_DeleteResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_DeleteResource r ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_DeleteResource_r ( b , tctx , & r ) ,
" DeleteResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" DeleteResource failed " ) ;
return true ;
}
static bool test_CreateResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
if ( ! test_CreateResource_int ( tctx , p , & hResource ) ) {
return false ;
}
test_DeleteResource_int ( tctx , p , & hResource ) ;
return true ;
}
static bool test_DeleteResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
if ( ! test_CreateResource_int ( tctx , p , & hResource ) ) {
return false ;
}
return test_DeleteResource_int ( tctx , p , & hResource ) ;
}
2015-03-05 14:04:54 +03:00
static bool test_SetResourceName_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_SetResourceName r ;
WERROR rpc_status ;
r . in . hResource = * hResource ;
r . in . lpszResourceName = " wurst " ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_SetResourceName_r ( b , tctx , & r ) ,
" SetResourceName failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" SetResourceName failed " ) ;
return true ;
}
static bool test_SetResourceName ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
if ( ! test_CreateResource_int ( tctx , p , & hResource ) ) {
return false ;
}
ret = test_SetResourceName_int ( tctx , p , & hResource ) ;
test_DeleteResource_int ( tctx , p , & hResource ) ;
return ret ;
}
2015-03-06 15:34:44 +03:00
static bool test_GetResourceState_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetResourceState r ;
2015-03-04 17:28:32 +03:00
enum clusapi_ClusterResourceState State ;
2015-03-06 15:34:44 +03:00
const char * NodeName ;
const char * GroupName ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . State = & State ;
r . out . NodeName = & NodeName ;
r . out . GroupName = & GroupName ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetResourceState_r ( b , tctx , & r ) ,
" GetResourceState failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" GetResourceState failed " ) ;
return true ;
}
static bool test_GetResourceState ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_GetResourceState_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
static bool test_GetResourceId_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetResourceId r ;
const char * pGuid ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . pGuid = & pGuid ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetResourceId_r ( b , tctx , & r ) ,
" GetResourceId failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" GetResourceId failed " ) ;
return true ;
}
static bool test_GetResourceId ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_GetResourceId_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
static bool test_GetResourceType_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetResourceType r ;
const char * lpszResourceType ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . lpszResourceType = & lpszResourceType ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetResourceType_r ( b , tctx , & r ) ,
" GetResourceType failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" GetResourceType failed " ) ;
return true ;
}
static bool test_GetResourceType ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_GetResourceType_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
static bool test_FailResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_FailResource r ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_FailResource_r ( b , tctx , & r ) ,
" FailResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" FailResource failed " ) ;
return true ;
}
static bool test_FailResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_FailResource_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
static bool test_OnlineResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OnlineResource r ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OnlineResource_r ( b , tctx , & r ) ,
" OnlineResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" OnlineResource failed " ) ;
return true ;
}
static bool test_OnlineResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_OnlineResource_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
static bool test_OfflineResource_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hResource )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OfflineResource r ;
2015-03-02 22:52:59 +03:00
WERROR rpc_status ;
2015-03-06 15:34:44 +03:00
r . in . hResource = * hResource ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OfflineResource_r ( b , tctx , & r ) ,
" OfflineResource failed " ) ;
torture_assert_werr_ok ( tctx ,
2015-03-02 22:52:59 +03:00
r . out . result ,
2015-03-06 15:34:44 +03:00
" OfflineResource failed " ) ;
return true ;
}
static bool test_OfflineResource ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hResource ;
bool ret = true ;
2015-03-05 18:39:37 +03:00
if ( ! test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ) {
2015-03-06 15:34:44 +03:00
return false ;
}
ret = test_OfflineResource_int ( tctx , p , & hResource ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return ret ;
}
2015-03-05 18:49:02 +03:00
static bool test_one_resource ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * resource_name )
{
struct policy_handle hResource ;
torture_assert ( tctx ,
test_OpenResource_int ( tctx , p , resource_name , & hResource ) ,
" failed to open resource " ) ;
2015-03-06 01:43:40 +03:00
test_CloseResource_int ( tctx , p , & hResource ) ;
torture_assert ( tctx ,
test_OpenResourceEx_int ( tctx , p , resource_name , & hResource ) ,
" failed to openex resource " ) ;
2015-03-05 18:49:02 +03:00
torture_assert ( tctx ,
test_GetResourceType_int ( tctx , p , & hResource ) ,
" failed to query resource type " ) ;
torture_assert ( tctx ,
test_GetResourceId_int ( tctx , p , & hResource ) ,
" failed to query resource id " ) ;
torture_assert ( tctx ,
test_GetResourceState_int ( tctx , p , & hResource ) ,
" failed to query resource id " ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return true ;
}
static bool test_all_resources ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateEnum r ;
uint32_t dwType = CLUSTER_ENUM_RESOURCE ;
struct ENUM_LIST * ReturnEnum ;
WERROR rpc_status ;
int i ;
r . in . dwType = dwType ;
r . out . ReturnEnum = & ReturnEnum ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateEnum_r ( b , tctx , & r ) ,
" CreateEnum failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CreateEnum failed " ) ;
for ( i = 0 ; i < ReturnEnum - > EntryCount ; i + + ) {
struct ENUM_ENTRY e = ReturnEnum - > Entry [ i ] ;
torture_assert_int_equal ( tctx , e . Type , CLUSTER_ENUM_RESOURCE , " type mismatch " ) ;
torture_assert ( tctx ,
test_one_resource ( tctx , p , e . Name ) ,
" failed to test one resource " ) ;
}
return true ;
}
2015-03-04 11:45:56 +03:00
static bool test_CreateResEnum ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateResEnum r ;
struct policy_handle hResource ;
uint32_t dwType = CLUSTER_ENUM_RESOURCE ;
struct ENUM_LIST * ReturnEnum ;
WERROR rpc_status ;
torture_assert ( tctx ,
2015-03-05 18:39:37 +03:00
test_OpenResource_int ( tctx , p , " Cluster Name " , & hResource ) ,
2015-03-04 11:45:56 +03:00
" OpenResource failed " ) ;
r . in . hResource = hResource ;
r . in . dwType = dwType ;
r . out . ReturnEnum = & ReturnEnum ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateResEnum_r ( b , tctx , & r ) ,
" CreateResEnum failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CreateResEnum failed " ) ;
test_CloseResource_int ( tctx , p , & hResource ) ;
return true ;
}
2015-03-06 15:34:44 +03:00
2015-03-06 15:49:13 +03:00
static bool test_OpenNode_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
2015-03-06 01:52:41 +03:00
const char * lpszNodeName ,
2015-03-06 15:49:13 +03:00
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenNode r ;
WERROR Status ;
WERROR rpc_status ;
r . in . lpszNodeName = lpszNodeName ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hNode = hNode ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenNode_r ( b , tctx , & r ) ,
" OpenNode failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenNode failed " ) ;
return true ;
}
2015-03-06 01:52:41 +03:00
static bool test_OpenNodeEx_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * lpszNodeName ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenNodeEx r ;
uint32_t lpdwGrantedAccess ;
WERROR Status ;
WERROR rpc_status ;
r . in . lpszNodeName = lpszNodeName ;
r . in . dwDesiredAccess = SEC_FLAG_MAXIMUM_ALLOWED ;
r . out . lpdwGrantedAccess = & lpdwGrantedAccess ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hNode = hNode ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenNodeEx_r ( b , tctx , & r ) ,
" OpenNodeEx failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenNodeEx failed " ) ;
return true ;
}
2015-03-06 15:49:13 +03:00
static bool test_CloseNode_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Node )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CloseNode r ;
r . in . Node = Node ;
r . out . Node = Node ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CloseNode_r ( b , tctx , & r ) ,
" CloseNode failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CloseNode failed " ) ;
torture_assert ( tctx ,
ndr_policy_handle_empty ( Node ) ,
" policy_handle non empty after CloseNode " ) ;
return true ;
}
static bool test_OpenNode ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
return false ;
}
test_CloseNode_int ( tctx , p , & hNode ) ;
return true ;
}
static bool test_OpenNodeEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
if ( ! test_OpenNodeEx_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
test_CloseNode_int ( tctx , p , & hNode ) ;
return true ;
}
static bool test_CloseNode ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
return test_CloseNode_int ( tctx , p , & hNode ) ;
}
static bool test_GetNodeState_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetNodeState r ;
2015-03-04 17:33:45 +03:00
enum clusapi_ClusterNodeState State ;
2015-03-06 15:49:13 +03:00
WERROR rpc_status ;
r . in . hNode = * hNode ;
r . out . State = & State ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetNodeState_r ( b , tctx , & r ) ,
" GetNodeState failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetNodeState failed " ) ;
return true ;
}
static bool test_GetNodeState ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
bool ret = true ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
ret = test_GetNodeState_int ( tctx , p , & hNode ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return ret ;
}
static bool test_GetNodeId_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetNodeId r ;
const char * pGuid ;
WERROR rpc_status ;
r . in . hNode = * hNode ;
r . out . pGuid = & pGuid ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetNodeId_r ( b , tctx , & r ) ,
" GetNodeId failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetNodeId failed " ) ;
return true ;
}
static bool test_GetNodeId ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
bool ret = true ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
ret = test_GetNodeId_int ( tctx , p , & hNode ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return ret ;
}
static bool test_PauseNode_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_PauseNode r ;
WERROR rpc_status ;
r . in . hNode = * hNode ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_PauseNode_r ( b , tctx , & r ) ,
" PauseNode failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" PauseNode failed " ) ;
return true ;
}
static bool test_PauseNode ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
bool ret = true ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
ret = test_PauseNode_int ( tctx , p , & hNode ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return ret ;
}
static bool test_ResumeNode_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_ResumeNode r ;
WERROR rpc_status ;
r . in . hNode = * hNode ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_ResumeNode_r ( b , tctx , & r ) ,
" ResumeNode failed " ) ;
torture_assert_werr_equal ( tctx ,
r . out . result ,
WERR_CLUSTER_NODE_NOT_PAUSED ,
" ResumeNode gave unexpected result " ) ;
return true ;
}
static bool test_ResumeNode ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
bool ret = true ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
ret = test_ResumeNode_int ( tctx , p , & hNode ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return ret ;
}
static bool test_EvictNode_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hNode )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_EvictNode r ;
WERROR rpc_status ;
r . in . hNode = * hNode ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_EvictNode_r ( b , tctx , & r ) ,
" EvictNode failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" EvictNode failed " ) ;
return true ;
}
static bool test_EvictNode ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hNode ;
bool ret = true ;
2015-03-06 01:52:41 +03:00
if ( ! test_OpenNode_int ( tctx , p , " NODE1 " , & hNode ) ) {
2015-03-06 15:49:13 +03:00
return false ;
}
ret = test_EvictNode_int ( tctx , p , & hNode ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return ret ;
}
2015-03-06 01:54:43 +03:00
static bool test_one_node ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * node_name )
{
struct policy_handle hNode ;
torture_assert ( tctx ,
test_OpenNode_int ( tctx , p , node_name , & hNode ) ,
" failed to open node " ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
torture_assert ( tctx ,
test_OpenNodeEx_int ( tctx , p , node_name , & hNode ) ,
" failed to openex node " ) ;
torture_assert ( tctx ,
test_GetNodeId_int ( tctx , p , & hNode ) ,
" failed to query node id " ) ;
torture_assert ( tctx ,
test_GetNodeState_int ( tctx , p , & hNode ) ,
" failed to query node id " ) ;
test_CloseNode_int ( tctx , p , & hNode ) ;
return true ;
}
static bool test_all_nodes ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateEnum r ;
uint32_t dwType = CLUSTER_ENUM_NODE ;
struct ENUM_LIST * ReturnEnum ;
WERROR rpc_status ;
int i ;
r . in . dwType = dwType ;
r . out . ReturnEnum = & ReturnEnum ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateEnum_r ( b , tctx , & r ) ,
" CreateEnum failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CreateEnum failed " ) ;
for ( i = 0 ; i < ReturnEnum - > EntryCount ; i + + ) {
struct ENUM_ENTRY e = ReturnEnum - > Entry [ i ] ;
torture_assert_int_equal ( tctx , e . Type , CLUSTER_ENUM_NODE , " type mismatch " ) ;
torture_assert ( tctx ,
test_one_node ( tctx , p , e . Name ) ,
" failed to test one node " ) ;
}
return true ;
}
2015-03-06 15:50:45 +03:00
static bool test_OpenGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
2015-03-06 01:50:00 +03:00
const char * lpszGroupName ,
2015-03-06 15:50:45 +03:00
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenGroup r ;
WERROR Status ;
WERROR rpc_status ;
r . in . lpszGroupName = lpszGroupName ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hGroup = hGroup ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenGroup_r ( b , tctx , & r ) ,
" OpenGroup failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenGroup failed " ) ;
return true ;
}
2015-03-06 01:51:41 +03:00
static bool test_OpenGroupEx_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * lpszGroupName ,
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OpenGroupEx r ;
uint32_t lpdwGrantedAccess ;
WERROR Status ;
WERROR rpc_status ;
r . in . lpszGroupName = lpszGroupName ;
r . in . dwDesiredAccess = SEC_FLAG_MAXIMUM_ALLOWED ;
r . out . lpdwGrantedAccess = & lpdwGrantedAccess ;
r . out . rpc_status = & rpc_status ;
r . out . Status = & Status ;
r . out . hGroup = hGroup ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OpenGroupEx_r ( b , tctx , & r ) ,
" OpenGroupEx failed " ) ;
torture_assert_werr_ok ( tctx ,
* r . out . Status ,
" OpenGroupEx failed " ) ;
return true ;
}
2015-03-06 15:50:45 +03:00
static bool test_CloseGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * Group )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CloseGroup r ;
r . in . Group = Group ;
r . out . Group = Group ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CloseGroup_r ( b , tctx , & r ) ,
" CloseGroup failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CloseGroup failed " ) ;
torture_assert ( tctx ,
ndr_policy_handle_empty ( Group ) ,
" policy_handle non empty after CloseGroup " ) ;
return true ;
}
static bool test_OpenGroup ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-06 15:50:45 +03:00
return false ;
}
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return true ;
}
2015-03-06 01:51:41 +03:00
static bool test_OpenGroupEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
if ( ! test_OpenGroupEx_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
return false ;
}
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return true ;
}
2015-03-06 15:50:45 +03:00
static bool test_CloseGroup ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-06 15:50:45 +03:00
return false ;
}
return test_CloseGroup_int ( tctx , p , & hGroup ) ;
}
2015-03-05 14:06:05 +03:00
static bool test_GetGroupState_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetGroupState r ;
enum clusapi_ClusterGroupState State ;
const char * NodeName ;
WERROR rpc_status ;
r . in . hGroup = * hGroup ;
r . out . State = & State ;
r . out . NodeName = & NodeName ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetGroupState_r ( b , tctx , & r ) ,
" GetGroupState failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetGroupState failed " ) ;
return true ;
}
static bool test_GetGroupState ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
bool ret = true ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-05 14:06:05 +03:00
return false ;
}
ret = test_GetGroupState_int ( tctx , p , & hGroup ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return ret ;
}
static bool test_GetGroupId_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_GetGroupId r ;
const char * pGuid ;
WERROR rpc_status ;
r . in . hGroup = * hGroup ;
r . out . pGuid = & pGuid ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_GetGroupId_r ( b , tctx , & r ) ,
" GetGroupId failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" GetGroupId failed " ) ;
return true ;
}
static bool test_GetGroupId ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
bool ret = true ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-05 14:06:05 +03:00
return false ;
}
ret = test_GetGroupId_int ( tctx , p , & hGroup ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return ret ;
}
static bool test_OnlineGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OnlineGroup r ;
WERROR rpc_status ;
r . in . hGroup = * hGroup ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OnlineGroup_r ( b , tctx , & r ) ,
" OnlineGroup failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" OnlineGroup failed " ) ;
return true ;
}
static bool test_OnlineGroup ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
bool ret = true ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-05 14:06:05 +03:00
return false ;
}
ret = test_OnlineGroup_int ( tctx , p , & hGroup ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return ret ;
}
static bool test_OfflineGroup_int ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
struct policy_handle * hGroup )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_OfflineGroup r ;
WERROR rpc_status ;
r . in . hGroup = * hGroup ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_OfflineGroup_r ( b , tctx , & r ) ,
" OfflineGroup failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" OfflineGroup failed " ) ;
return true ;
}
static bool test_OfflineGroup ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct policy_handle hGroup ;
bool ret = true ;
2015-03-06 01:50:00 +03:00
if ( ! test_OpenGroup_int ( tctx , p , " Cluster Group " , & hGroup ) ) {
2015-03-05 14:06:05 +03:00
return false ;
}
ret = test_OfflineGroup_int ( tctx , p , & hGroup ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return ret ;
}
2015-03-06 02:05:09 +03:00
static bool test_one_group ( struct torture_context * tctx ,
struct dcerpc_pipe * p ,
const char * node_name )
{
struct policy_handle hGroup ;
torture_assert ( tctx ,
test_OpenGroup_int ( tctx , p , node_name , & hGroup ) ,
" failed to open group " ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
torture_assert ( tctx ,
test_OpenGroupEx_int ( tctx , p , node_name , & hGroup ) ,
" failed to openex group " ) ;
torture_assert ( tctx ,
test_GetGroupId_int ( tctx , p , & hGroup ) ,
" failed to query group id " ) ;
torture_assert ( tctx ,
test_GetGroupState_int ( tctx , p , & hGroup ) ,
" failed to query group id " ) ;
test_CloseGroup_int ( tctx , p , & hGroup ) ;
return true ;
}
static bool test_all_groups ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
struct dcerpc_binding_handle * b = p - > binding_handle ;
struct clusapi_CreateEnum r ;
uint32_t dwType = CLUSTER_ENUM_GROUP ;
struct ENUM_LIST * ReturnEnum ;
WERROR rpc_status ;
int i ;
r . in . dwType = dwType ;
r . out . ReturnEnum = & ReturnEnum ;
r . out . rpc_status = & rpc_status ;
torture_assert_ntstatus_ok ( tctx ,
dcerpc_clusapi_CreateEnum_r ( b , tctx , & r ) ,
" CreateEnum failed " ) ;
torture_assert_werr_ok ( tctx ,
r . out . result ,
" CreateEnum failed " ) ;
for ( i = 0 ; i < ReturnEnum - > EntryCount ; i + + ) {
struct ENUM_ENTRY e = ReturnEnum - > Entry [ i ] ;
torture_assert_int_equal ( tctx , e . Type , CLUSTER_ENUM_GROUP , " type mismatch " ) ;
torture_assert ( tctx ,
test_one_group ( tctx , p , e . Name ) ,
" failed to test one group " ) ;
}
return true ;
}
2015-03-05 14:06:05 +03:00
2015-02-27 01:03:36 +03:00
struct torture_suite * torture_rpc_clusapi ( TALLOC_CTX * mem_ctx )
{
struct torture_rpc_tcase * tcase ;
struct torture_suite * suite = torture_suite_create ( mem_ctx , " clusapi " ) ;
2015-03-06 15:34:44 +03:00
struct torture_test * test ;
2015-02-27 01:03:36 +03:00
2015-03-06 15:52:46 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " cluster " ,
2015-02-27 01:03:36 +03:00
& ndr_table_clusapi ) ;
torture_rpc_tcase_add_test ( tcase , " OpenCluster " ,
test_OpenCluster ) ;
2015-03-05 23:31:17 +03:00
torture_rpc_tcase_add_test ( tcase , " OpenClusterEx " ,
test_OpenClusterEx ) ;
2015-02-27 01:03:36 +03:00
torture_rpc_tcase_add_test ( tcase , " CloseCluster " ,
test_CloseCluster ) ;
2015-02-27 19:45:02 +03:00
torture_rpc_tcase_add_test ( tcase , " SetClusterName " ,
test_SetClusterName ) ;
torture_rpc_tcase_add_test ( tcase , " GetClusterName " ,
test_GetClusterName ) ;
torture_rpc_tcase_add_test ( tcase , " GetClusterVersion " ,
test_GetClusterVersion ) ;
2015-03-06 15:25:24 +03:00
torture_rpc_tcase_add_test ( tcase , " CreateEnum " ,
test_CreateEnum ) ;
2015-03-05 18:49:02 +03:00
torture_rpc_tcase_add_test ( tcase , " GetClusterVersion2 " ,
test_GetClusterVersion2 ) ;
torture_rpc_tcase_add_test ( tcase , " CreateResEnum " ,
test_CreateResEnum ) ;
torture_rpc_tcase_add_test ( tcase , " all_resources " ,
test_all_resources ) ;
2015-03-06 15:53:13 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " resource " ,
& ndr_table_clusapi ) ;
2015-03-06 15:34:44 +03:00
torture_rpc_tcase_add_test ( tcase , " GetQuorumResource " ,
test_GetQuorumResource ) ;
torture_rpc_tcase_add_test ( tcase , " SetQuorumResource " ,
test_SetQuorumResource ) ;
torture_rpc_tcase_add_test ( tcase , " OpenResource " ,
test_OpenResource ) ;
2015-03-06 01:43:40 +03:00
torture_rpc_tcase_add_test ( tcase , " OpenResourceEx " ,
test_OpenResourceEx ) ;
2015-03-06 15:34:44 +03:00
torture_rpc_tcase_add_test ( tcase , " CloseResource " ,
test_CloseResource ) ;
torture_rpc_tcase_add_test ( tcase , " CreateResource " ,
test_CreateResource ) ;
torture_rpc_tcase_add_test ( tcase , " DeleteResource " ,
test_DeleteResource ) ;
2015-03-05 14:04:54 +03:00
torture_rpc_tcase_add_test ( tcase , " SetResourceName " ,
test_SetResourceName ) ;
2015-03-06 15:34:44 +03:00
torture_rpc_tcase_add_test ( tcase , " GetResourceState " ,
test_GetResourceState ) ;
torture_rpc_tcase_add_test ( tcase , " GetResourceId " ,
test_GetResourceId ) ;
torture_rpc_tcase_add_test ( tcase , " GetResourceType " ,
test_GetResourceType ) ;
test = torture_rpc_tcase_add_test ( tcase , " FailResource " ,
test_FailResource ) ;
test - > dangerous = true ;
torture_rpc_tcase_add_test ( tcase , " OnlineResource " ,
test_OnlineResource ) ;
test = torture_rpc_tcase_add_test ( tcase , " OfflineResource " ,
test_OfflineResource ) ;
test - > dangerous = true ;
2015-02-27 01:03:36 +03:00
2015-03-06 15:49:13 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " node " ,
& ndr_table_clusapi ) ;
torture_rpc_tcase_add_test ( tcase , " OpenNode " ,
test_OpenNode ) ;
2015-03-06 01:52:41 +03:00
torture_rpc_tcase_add_test ( tcase , " OpenNodeEx " ,
test_OpenNodeEx ) ;
2015-03-06 15:49:13 +03:00
torture_rpc_tcase_add_test ( tcase , " CloseNode " ,
test_CloseNode ) ;
torture_rpc_tcase_add_test ( tcase , " GetNodeState " ,
test_GetNodeState ) ;
torture_rpc_tcase_add_test ( tcase , " GetNodeId " ,
test_GetNodeId ) ;
test = torture_rpc_tcase_add_test ( tcase , " PauseNode " ,
test_PauseNode ) ;
test - > dangerous = true ;
torture_rpc_tcase_add_test ( tcase , " ResumeNode " ,
test_ResumeNode ) ;
test = torture_rpc_tcase_add_test ( tcase , " EvictNode " ,
test_EvictNode ) ;
test - > dangerous = true ;
2015-03-06 01:54:43 +03:00
torture_rpc_tcase_add_test ( tcase , " all_nodes " ,
test_all_nodes ) ;
2015-03-06 15:49:13 +03:00
2015-03-06 15:50:45 +03:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " group " ,
& ndr_table_clusapi ) ;
torture_rpc_tcase_add_test ( tcase , " OpenGroup " ,
test_OpenGroup ) ;
2015-03-06 01:51:41 +03:00
torture_rpc_tcase_add_test ( tcase , " OpenGroupEx " ,
test_OpenGroupEx ) ;
2015-03-06 15:50:45 +03:00
torture_rpc_tcase_add_test ( tcase , " CloseGroup " ,
test_CloseGroup ) ;
2015-03-05 14:06:05 +03:00
torture_rpc_tcase_add_test ( tcase , " GetGroupState " ,
test_GetGroupState ) ;
torture_rpc_tcase_add_test ( tcase , " GetGroupId " ,
test_GetGroupId ) ;
torture_rpc_tcase_add_test ( tcase , " OnlineGroup " ,
test_OnlineGroup ) ;
test = torture_rpc_tcase_add_test ( tcase , " OfflineGroup " ,
test_OfflineGroup ) ;
test - > dangerous = true ;
2015-03-06 02:05:09 +03:00
torture_rpc_tcase_add_test ( tcase , " all_groups " ,
test_all_groups ) ;
2015-03-06 15:50:45 +03:00
2015-02-27 01:03:36 +03:00
return suite ;
}