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"
2010-04-13 22:06:51 +02:00
# include "torture/rpc/torture_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-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
2010-04-09 09:03:43 +02: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 12:00:34 +01:00
if ( ! test_lsa_OpenPolicy2 ( p - > binding_handle , torture , & handle ) ) {
2007-09-02 13:30:28 +00:00
ret = false ;
2005-01-09 09:38:16 +00:00
}
2010-04-09 09:03:43 +02: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 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
2010-04-09 09:03:43 +02: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-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
2010-04-11 01:39:06 +02: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 ) {
2010-03-11 12:00:34 +01:00
ret & = test_lsa_Close ( p - > binding_handle , torture , handle ) ;
2005-01-09 09:38:16 +00:00
}
2010-04-09 09:03:43 +02: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 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 ) ;
2010-04-10 11:04:04 +02:00
if ( NT_STATUS_EQUAL ( status , NT_STATUS_RPC_PROTOCOL_ERROR ) ) {
2010-04-09 09:03:43 +02:00
ret & = test_lsa_OpenPolicy2_ex ( p - > binding_handle , torture , & handle ,
2015-06-29 09:49:05 +02:00
NT_STATUS_CONNECTION_DISCONNECTED ) ;
2014-01-22 11:18:35 +01:00
torture_assert ( torture , ! dcerpc_binding_handle_is_connected ( p - > binding_handle ) ,
" dcerpc disonnected " ) ;
2010-04-09 09:03:43 +02:00
return ret ;
}
2007-09-02 13:30:28 +00:00
torture_assert_ntstatus_ok ( torture , status , " dcerpc_alter_context failed " ) ;
2005-01-10 03:48:19 +00:00
2010-04-11 01:39:06 +02:00
torture_comment ( torture , " Testing DSSETUP pipe operations - should fault \n " ) ;
2010-03-29 22:45:05 +02:00
ret & = test_DsRoleGetPrimaryDomainInformation_ext ( torture , p , NT_STATUS_RPC_BAD_STUB_DATA ) ;
2005-01-10 03:48:19 +00:00
2010-03-11 12:00:34 +01:00
ret & = test_lsa_OpenPolicy2 ( p - > binding_handle , torture , & handle ) ;
2005-01-10 03:48:19 +00:00
2005-10-25 12:14:08 +00:00
if ( handle ) {
2010-03-11 12:00:34 +01:00
ret & = test_lsa_Close ( p - > binding_handle , torture , handle ) ;
2005-01-10 03:48:19 +00:00
}
2010-04-11 01:39:06 +02:00
torture_comment ( torture , " Testing DSSETUP pipe operations \n " ) ;
2007-08-29 00:56:13 +00:00
2007-09-02 13:30:28 +00:00
ret & = test_DsRoleGetPrimaryDomainInformation ( torture , p2 ) ;
2005-01-09 09:38:16 +00:00
return ret ;
}