2005-03-17 23:28:01 +03:00
/*
Unix SMB / CIFS implementation .
test suite for initshutdown operations
Copyright ( C ) Tim Potter 2003
Copyright ( C ) Jelmer Vernooij 2004 - 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-03-17 23:28:01 +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-03-17 23:28:01 +03:00
*/
# include "includes.h"
2006-01-03 16:41:17 +03:00
# include "torture/torture.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_initshutdown_c.h"
2006-03-14 18:02:05 +03:00
# include "torture/rpc/rpc.h"
2005-03-17 23:28:01 +03:00
2008-02-19 16:58:33 +03:00
static void init_lsa_StringLarge ( struct lsa_StringLarge * name , const char * s )
2005-03-17 23:28:01 +03:00
{
2008-02-19 16:58:33 +03:00
name - > string = s ;
2005-03-17 23:28:01 +03:00
}
2007-08-28 20:24:18 +04:00
static bool test_Abort ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2005-03-17 23:28:01 +03:00
{
2007-08-28 20:24:18 +04:00
struct initshutdown_Abort r ;
2005-03-17 23:28:01 +03:00
NTSTATUS status ;
2007-08-28 20:24:18 +04:00
uint16_t server = 0x0 ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
r . in . server = & server ;
status = dcerpc_initshutdown_Abort ( p , tctx , & r ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
torture_assert_ntstatus_ok ( tctx , status ,
" initshutdown_Abort failed " ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
torture_assert_werr_ok ( tctx , r . out . result , " initshutdown_Abort failed " ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
return true ;
2005-03-17 23:28:01 +03:00
}
2007-08-28 20:24:18 +04:00
static bool test_Init ( struct torture_context * tctx ,
2007-08-31 19:43:03 +04:00
struct dcerpc_pipe * p )
2005-03-17 23:28:01 +03:00
{
2007-08-28 20:24:18 +04:00
struct initshutdown_Init r ;
2005-03-17 23:28:01 +03:00
NTSTATUS status ;
uint16_t hostname = 0x0 ;
2007-08-28 20:24:18 +04:00
2005-03-17 23:28:01 +03:00
r . in . hostname = & hostname ;
2008-02-19 16:58:33 +03:00
r . in . message = talloc ( tctx , struct lsa_StringLarge ) ;
init_lsa_StringLarge ( r . in . message , " spottyfood " ) ;
2005-03-17 23:28:01 +03:00
r . in . force_apps = 1 ;
2007-08-28 20:24:18 +04:00
r . in . timeout = 30 ;
2008-10-15 18:25:06 +04:00
r . in . do_reboot = 1 ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
status = dcerpc_initshutdown_Init ( p , tctx , & r ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
torture_assert_ntstatus_ok ( tctx , status , " initshutdown_Init failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result , " initshutdown_Init failed " ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
return test_Abort ( tctx , p ) ;
2005-03-17 23:28:01 +03:00
}
2007-08-28 20:24:18 +04:00
static bool test_InitEx ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
2005-03-17 23:28:01 +03:00
{
2007-08-28 20:24:18 +04:00
struct initshutdown_InitEx r ;
2005-03-17 23:28:01 +03:00
NTSTATUS status ;
2007-08-28 20:24:18 +04:00
uint16_t hostname = 0x0 ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
r . in . hostname = & hostname ;
2008-02-19 16:58:33 +03:00
r . in . message = talloc ( tctx , struct lsa_StringLarge ) ;
init_lsa_StringLarge ( r . in . message , " spottyfood " ) ;
2007-08-28 20:24:18 +04:00
r . in . force_apps = 1 ;
r . in . timeout = 30 ;
2008-10-15 18:25:06 +04:00
r . in . do_reboot = 1 ;
2007-08-28 20:24:18 +04:00
r . in . reason = 0 ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
status = dcerpc_initshutdown_InitEx ( p , tctx , & r ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
torture_assert_ntstatus_ok ( tctx , status , " initshutdown_InitEx failed " ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
torture_assert_werr_ok ( tctx , r . out . result , " initshutdown_InitEx failed " ) ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
return test_Abort ( tctx , p ) ;
}
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
struct torture_suite * torture_rpc_initshutdown ( TALLOC_CTX * mem_ctx )
{
struct torture_suite * suite = torture_suite_create ( mem_ctx , " INITSHUTDOWN " ) ;
struct torture_rpc_tcase * tcase ;
2007-08-31 19:43:03 +04:00
struct torture_test * test ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " initshutdown " ,
2007-08-31 19:43:03 +04:00
& ndr_table_initshutdown ) ;
2005-03-17 23:28:01 +03:00
2007-08-31 19:43:03 +04:00
test = torture_rpc_tcase_add_test ( tcase , " Init " , test_Init ) ;
test - > dangerous = true ;
test = torture_rpc_tcase_add_test ( tcase , " InitEx " , test_InitEx ) ;
test - > dangerous = true ;
2005-03-17 23:28:01 +03:00
2007-08-28 20:24:18 +04:00
return suite ;
2005-03-17 23:28:01 +03:00
}