2005-01-09 09:38:16 +00:00
/*
Unix SMB / CIFS implementation .
test suite for dcerpc alter_context operations
Copyright ( C ) Andrew Tridgell 2005
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
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2005-01-09 09:38:16 +00: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
2007-07-10 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-01-09 09:38:16 +00:00
*/
# include "includes.h"
# include "librpc/gen_ndr/ndr_lsa.h"
# include "librpc/gen_ndr/ndr_dssetup.h"
2006-03-14 15:02:05 +00:00
# include "torture/rpc/rpc.h"
2005-01-09 09:38:16 +00:00
2007-08-29 00:56:13 +00:00
bool torture_rpc_alter_context ( struct torture_context * torture )
2005-01-09 09:38:16 +00:00
{
2007-09-02 17:27:40 +00:00
NTSTATUS status ;
struct dcerpc_pipe * p , * p2 , * p3 ;
2005-10-25 12:14:08 +00:00
struct policy_handle * handle ;
2007-08-19 20:46:45 +00:00
struct ndr_interface_table tmptbl ;
2007-08-18 06:57:49 +00:00
struct ndr_syntax_id syntax ;
struct ndr_syntax_id transfer_syntax ;
2007-09-02 13:30:28 +00:00
bool ret = true ;
2005-01-09 09:38:16 +00:00
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " opening LSA connection \n " ) ;
2007-08-28 12:54:27 +00:00
status = torture_rpc_connection ( torture , & p , & ndr_table_lsarpc ) ;
2007-09-02 13:30:28 +00:00
torture_assert_ntstatus_ok ( torture , status , " connecting " ) ;
2005-01-09 09:38:16 +00:00
2007-09-02 13:30:28 +00:00
if ( ! test_lsa_OpenPolicy2 ( p , torture , & handle ) ) {
ret = false ;
2005-01-09 09:38:16 +00:00
}
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " Opening secondary DSSETUP context \n " ) ;
2007-08-19 21:23:03 +00:00
status = dcerpc_secondary_context ( p , & p2 , & ndr_table_dssetup ) ;
2007-09-02 13:30:28 +00:00
torture_assert_ntstatus_ok ( torture , status , " dcerpc_alter_context failed " ) ;
2005-01-09 09:38:16 +00:00
2007-08-19 21:23:03 +00:00
tmptbl = ndr_table_dssetup ;
2006-03-26 00:59:17 +00:00
tmptbl . syntax_id . if_version + = 100 ;
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " Opening bad secondary connection \n " ) ;
2007-09-02 17:27:40 +00:00
status = dcerpc_secondary_context ( p , & p3 , & tmptbl ) ;
2007-09-02 15:02:17 +00:00
torture_assert_ntstatus_equal ( torture , status , NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX ,
" dcerpc_alter_context with wrong version should fail " ) ;
2005-01-09 11:32:12 +00:00
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " testing DSSETUP pipe operations \n " ) ;
2007-09-02 13:30:28 +00:00
ret & = test_DsRoleGetPrimaryDomainInformation ( torture , p2 ) ;
2005-01-09 09:38:16 +00:00
2005-10-25 12:14:08 +00:00
if ( handle ) {
2007-09-02 17:27:40 +00:00
ret & = test_lsa_Close ( p , torture , handle ) ;
2005-01-09 09:38:16 +00:00
}
2005-01-10 03:48:19 +00:00
syntax = p - > syntax ;
transfer_syntax = p - > transfer_syntax ;
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " Testing change of primary context \n " ) ;
2007-09-02 13:30:28 +00:00
status = dcerpc_alter_context ( p , torture , & p2 - > syntax , & p2 - > transfer_syntax ) ;
torture_assert_ntstatus_ok ( torture , status , " dcerpc_alter_context failed " ) ;
2005-01-10 03:48:19 +00:00
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " testing DSSETUP pipe operations - should fault \n " ) ;
2007-09-02 17:27:40 +00:00
ret & = test_DsRoleGetPrimaryDomainInformation_ext ( torture , p , NT_STATUS_NET_WRITE_FAULT ) ;
2005-01-10 03:48:19 +00:00
2007-09-02 17:27:40 +00:00
ret & = test_lsa_OpenPolicy2 ( p , torture , & handle ) ;
2005-01-10 03:48:19 +00:00
2005-10-25 12:14:08 +00:00
if ( handle ) {
2007-09-02 17:27:40 +00:00
ret & = test_lsa_Close ( p , torture , handle ) ;
2005-01-10 03:48:19 +00:00
}
2007-08-29 00:56:13 +00:00
torture_comment ( torture , " testing DSSETUP pipe operations \n " ) ;
2007-09-02 13:30:28 +00:00
ret & = test_DsRoleGetPrimaryDomainInformation ( torture , p2 ) ;
2005-01-09 09:38:16 +00:00
return ret ;
}