2003-11-20 03:27:56 +00:00
/*
Unix SMB / CIFS implementation .
2003-11-20 05:46:45 +00:00
test suite for atsvc rpc operations
2003-11-20 03:27:56 +00: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 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-11-20 03:27:56 +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/>.
2003-11-20 03:27:56 +00:00
*/
# include "includes.h"
2006-01-03 13:41:17 +00:00
# include "torture/torture.h"
2006-03-14 23:35:30 +00:00
# include "librpc/gen_ndr/ndr_atsvc_c.h"
2006-03-14 15:02:05 +00:00
# include "torture/rpc/rpc.h"
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
static bool test_JobGetInfo ( struct dcerpc_pipe * p , struct torture_context * tctx , uint32_t job_id )
2003-11-20 03:27:56 +00:00
{
NTSTATUS status ;
struct atsvc_JobGetInfo r ;
r . in . servername = dcerpc_server_name ( p ) ;
r . in . job_id = job_id ;
2006-10-16 13:06:41 +00:00
status = dcerpc_atsvc_JobGetInfo ( p , tctx , & r ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
torture_assert_ntstatus_ok ( tctx , status , " JobGetInfo failed " ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
return true ;
2003-11-20 03:27:56 +00:00
}
2006-10-16 13:06:41 +00:00
static bool test_JobDel ( struct dcerpc_pipe * p , struct torture_context * tctx , uint32_t min_job_id ,
2004-05-25 16:24:13 +00:00
uint32_t max_job_id )
2003-11-20 03:27:56 +00:00
{
NTSTATUS status ;
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 ;
2006-10-16 13:06:41 +00:00
status = dcerpc_atsvc_JobDel ( p , tctx , & r ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
torture_assert_ntstatus_ok ( tctx , status , " JobDel failed " ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
return true ;
2003-11-20 03:27:56 +00:00
}
2006-10-16 13:06:41 +00:00
static bool test_JobEnum ( struct torture_context * tctx , struct dcerpc_pipe * p )
2003-11-20 03:27:56 +00:00
{
NTSTATUS status ;
struct atsvc_JobEnum r ;
struct atsvc_enum_ctr ctr ;
2004-05-25 16:24:13 +00:00
uint32_t resume_handle = 0 , i ;
2006-10-16 13:06:41 +00:00
bool ret = true ;
2003-11-20 03:27:56 +00:00
r . in . servername = dcerpc_server_name ( p ) ;
ctr . entries_read = 0 ;
ctr . first_entry = NULL ;
2006-09-18 21:52:00 +00:00
r . in . ctr = r . out . ctr = & ctr ;
2003-11-20 03:27:56 +00:00
r . in . preferred_max_len = 0xffffffff ;
r . in . resume_handle = r . out . resume_handle = & resume_handle ;
2006-10-16 13:06:41 +00:00
status = dcerpc_atsvc_JobEnum ( p , tctx , & r ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
torture_assert_ntstatus_ok ( tctx , status , " JobEnum failed " ) ;
2003-11-20 03:27:56 +00:00
2006-09-18 21:52:00 +00:00
for ( i = 0 ; i < r . out . ctr - > entries_read ; i + + ) {
2006-10-16 13:06:41 +00:00
if ( ! test_JobGetInfo ( p , tctx , r . out . ctr - > first_entry [ i ] . job_id ) ) {
2003-11-20 03:27:56 +00:00
ret = False ;
}
}
return ret ;
}
2006-10-16 13:06:41 +00:00
static bool test_JobAdd ( struct torture_context * tctx , struct dcerpc_pipe * p )
2003-11-20 03:27:56 +00:00
{
NTSTATUS status ;
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-18 21:52:00 +00:00
r . in . job_info = & info ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
status = dcerpc_atsvc_JobAdd ( p , tctx , & r ) ;
2003-11-20 03:27:56 +00:00
2006-10-16 13:06:41 +00:00
torture_assert_ntstatus_ok ( tctx , status , " JobAdd failed " ) ;
2003-11-20 03:27:56 +00:00
/* Run EnumJobs again in case there were no jobs to begin with */
2006-10-16 13:06:41 +00:00
if ( ! test_JobEnum ( tctx , p ) ) {
return false ;
2003-11-20 03:27:56 +00:00
}
2006-11-22 14:56:40 +00:00
if ( ! test_JobGetInfo ( p , tctx , * r . out . job_id ) ) {
2006-10-16 13:06:41 +00:00
return false ;
2003-11-20 03:27:56 +00:00
}
2006-11-22 14:56:40 +00:00
if ( ! test_JobDel ( p , tctx , * r . out . job_id , * r . out . job_id ) ) {
2006-10-16 13:06:41 +00:00
return false ;
2003-11-20 03:27:56 +00:00
}
2006-10-16 13:06:41 +00:00
return true ;
2003-11-20 03:27:56 +00:00
}
2006-10-16 13:06:41 +00:00
struct torture_suite * torture_rpc_atsvc ( void )
2003-11-20 03:27:56 +00:00
{
2006-10-16 13:06:41 +00:00
struct torture_suite * suite = torture_suite_create (
talloc_autofree_context ( ) ,
" ATSVC " ) ;
struct torture_tcase * tcase ;
tcase = torture_suite_add_rpc_iface_tcase ( suite , " atsvc " ,
& dcerpc_table_atsvc ) ;
torture_rpc_tcase_add_test ( tcase , " JobEnum " , test_JobEnum ) ;
torture_rpc_tcase_add_test ( tcase , " JobAdd " , test_JobAdd ) ;
return suite ;
2003-11-20 03:27:56 +00:00
}