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-03-14 23:35:30 +00:00
# include "librpc/gen_ndr/ndr_atsvc_c.h"
2010-04-13 22:06:51 +02:00
# include "torture/rpc/torture_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
{
2010-03-15 10:49:02 +01:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 03:27:56 +00:00
struct atsvc_JobGetInfo r ;
2008-01-07 05:41:16 -06:00
struct atsvc_JobInfo * info = talloc ( tctx , struct atsvc_JobInfo ) ;
if ( ! info ) {
return false ;
}
2003-11-20 03:27:56 +00:00
r . in . servername = dcerpc_server_name ( p ) ;
r . in . job_id = job_id ;
2008-01-07 05:41:16 -06:00
r . out . job_info = & info ;
2003-11-20 03:27:56 +00:00
2010-03-19 12:26:27 +01: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 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
{
2010-03-15 10:49:02 +01:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 03:27:56 +00: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 12:26:27 +01: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 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
{
2010-03-15 10:49:02 +01:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 03:27:56 +00:00
struct atsvc_JobEnum r ;
struct atsvc_enum_ctr ctr ;
2008-08-15 09:46:51 +10:00
uint32_t resume_handle = 0 , i , total_entries = 0 ;
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 ;
2008-08-15 09:46:51 +10:00
r . out . total_entries = & total_entries ;
2003-11-20 03:27:56 +00:00
2010-03-19 12:26:27 +01: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 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 ) ) {
2007-10-06 22:28:14 +00:00
ret = false ;
2003-11-20 03:27:56 +00:00
}
}
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
{
2010-03-15 10:49:02 +01:00
struct dcerpc_binding_handle * b = p - > binding_handle ;
2003-11-20 03:27:56 +00: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-18 21:52:00 +00:00
r . in . job_info = & info ;
2003-11-20 03:27:56 +00:00
2010-03-19 12:26:27 +01: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 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
}
2007-08-31 22:34:52 +00:00
struct torture_suite * torture_rpc_atsvc ( TALLOC_CTX * mem_ctx )
2003-11-20 03:27:56 +00:00
{
2010-12-11 03:26:31 +01:00
struct torture_suite * suite = torture_suite_create ( mem_ctx , " atsvc " ) ;
2007-08-28 16:24:18 +00:00
struct torture_rpc_tcase * tcase ;
2006-10-16 13:06:41 +00:00
2007-08-31 22:34:52 +00:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " atsvc " , & ndr_table_atsvc ) ;
2006-10-16 13:06:41 +00:00
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
}