2003-11-20 06:27:56 +03:00
/*
Unix SMB / CIFS implementation .
2003-11-20 08:46:45 +03:00
test suite for atsvc rpc operations
2003-11-20 06:27:56 +03:00
Copyright ( C ) Tim Potter 2003
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
2003-11-20 06:27:56 +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/>.
2003-11-20 06:27:56 +03:00
*/
# include "includes.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_atsvc_c.h"
2010-04-14 00:06:51 +04:00
# include "torture/rpc/torture_rpc.h"
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
static bool test_JobGetInfo ( struct dcerpc_pipe * p , struct torture_context * tctx , uint32_t job_id )
2003-11-20 06:27:56 +03:00
{
2010-03-15 12:49:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 06:27:56 +03:00
struct atsvc_JobGetInfo r ;
2008-01-07 14:41:16 +03:00
struct atsvc_JobInfo * info = talloc ( tctx , struct atsvc_JobInfo ) ;
if ( ! info ) {
return false ;
}
2003-11-20 06:27:56 +03:00
r . in . servername = dcerpc_server_name ( p ) ;
r . in . job_id = job_id ;
2008-01-07 14:41:16 +03:00
r . out . job_info = & info ;
2003-11-20 06:27:56 +03:00
2010-03-19 14:26:27 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_atsvc_JobGetInfo_r ( b , tctx , & r ) ,
" JobGetInfo failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " JobGetInfo failed " ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-20 06:27:56 +03:00
}
2006-10-16 17:06:41 +04:00
static bool test_JobDel ( struct dcerpc_pipe * p , struct torture_context * tctx , uint32_t min_job_id ,
2004-05-25 20:24:13 +04:00
uint32_t max_job_id )
2003-11-20 06:27:56 +03:00
{
2010-03-15 12:49:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 06:27:56 +03:00
struct atsvc_JobDel r ;
r . in . servername = dcerpc_server_name ( p ) ;
r . in . min_job_id = min_job_id ;
r . in . max_job_id = max_job_id ;
2010-03-19 14:26:27 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_atsvc_JobDel_r ( b , tctx , & r ) ,
" JobDel failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " JobDel failed " ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-20 06:27:56 +03:00
}
2006-10-16 17:06:41 +04:00
static bool test_JobEnum ( struct torture_context * tctx , struct dcerpc_pipe * p )
2003-11-20 06:27:56 +03:00
{
2010-03-15 12:49:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 06:27:56 +03:00
struct atsvc_JobEnum r ;
struct atsvc_enum_ctr ctr ;
2008-08-15 03:46:51 +04:00
uint32_t resume_handle = 0 , i , total_entries = 0 ;
2006-10-16 17:06:41 +04:00
bool ret = true ;
2003-11-20 06:27:56 +03:00
r . in . servername = dcerpc_server_name ( p ) ;
ctr . entries_read = 0 ;
ctr . first_entry = NULL ;
2006-09-19 01:52:00 +04:00
r . in . ctr = r . out . ctr = & ctr ;
2003-11-20 06:27:56 +03:00
r . in . preferred_max_len = 0xffffffff ;
r . in . resume_handle = r . out . resume_handle = & resume_handle ;
2008-08-15 03:46:51 +04:00
r . out . total_entries = & total_entries ;
2003-11-20 06:27:56 +03:00
2010-03-19 14:26:27 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_atsvc_JobEnum_r ( b , tctx , & r ) ,
" JobEnum failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " JobEnum failed " ) ;
2003-11-20 06:27:56 +03:00
2006-09-19 01:52:00 +04:00
for ( i = 0 ; i < r . out . ctr - > entries_read ; i + + ) {
2006-10-16 17:06:41 +04:00
if ( ! test_JobGetInfo ( p , tctx , r . out . ctr - > first_entry [ i ] . job_id ) ) {
2007-10-07 02:28:14 +04:00
ret = false ;
2003-11-20 06:27:56 +03:00
}
}
return ret ;
}
2006-10-16 17:06:41 +04:00
static bool test_JobAdd ( struct torture_context * tctx , struct dcerpc_pipe * p )
2003-11-20 06:27:56 +03:00
{
2010-03-15 12:49:02 +03:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 06:27:56 +03:00
struct atsvc_JobAdd r ;
struct atsvc_JobInfo info ;
r . in . servername = dcerpc_server_name ( p ) ;
info . job_time = 0x050ae4c0 ; /* 11:30pm */
info . days_of_month = 0 ; /* n/a */
info . days_of_week = 0x02 ; /* Tuesday */
info . flags = 0x11 ; /* periodic, non-interactive */
info . command = " foo.exe " ;
2006-09-19 01:52:00 +04:00
r . in . job_info = & info ;
2003-11-20 06:27:56 +03:00
2010-03-19 14:26:27 +03:00
torture_assert_ntstatus_ok ( tctx , dcerpc_atsvc_JobAdd_r ( b , tctx , & r ) ,
" JobAdd failed " ) ;
torture_assert_ntstatus_ok ( tctx , r . out . result , " JobAdd failed " ) ;
2003-11-20 06:27:56 +03:00
/* Run EnumJobs again in case there were no jobs to begin with */
2006-10-16 17:06:41 +04:00
if ( ! test_JobEnum ( tctx , p ) ) {
return false ;
2003-11-20 06:27:56 +03:00
}
2006-11-22 17:56:40 +03:00
if ( ! test_JobGetInfo ( p , tctx , * r . out . job_id ) ) {
2006-10-16 17:06:41 +04:00
return false ;
2003-11-20 06:27:56 +03:00
}
2006-11-22 17:56:40 +03:00
if ( ! test_JobDel ( p , tctx , * r . out . job_id , * r . out . job_id ) ) {
2006-10-16 17:06:41 +04:00
return false ;
2003-11-20 06:27:56 +03:00
}
2006-10-16 17:06:41 +04:00
return true ;
2003-11-20 06:27:56 +03:00
}
2007-09-01 02:34:52 +04:00
struct torture_suite * torture_rpc_atsvc ( TALLOC_CTX * mem_ctx )
2003-11-20 06:27:56 +03:00
{
2010-12-11 05:26:31 +03:00
struct torture_suite * suite = torture_suite_create ( mem_ctx , " atsvc " ) ;
2007-08-28 20:24:18 +04:00
struct torture_rpc_tcase * tcase ;
2006-10-16 17:06:41 +04:00
2007-09-01 02:34:52 +04:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " atsvc " , & ndr_table_atsvc ) ;
2006-10-16 17:06:41 +04:00
torture_rpc_tcase_add_test ( tcase , " JobEnum " , test_JobEnum ) ;
torture_rpc_tcase_add_test ( tcase , " JobAdd " , test_JobAdd ) ;
return suite ;
2003-11-20 06:27:56 +03:00
}