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