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-01-03 16:41:17 +03:00
# include "torture/torture.h"
2006-03-15 02:35:30 +03:00
# include "librpc/gen_ndr/ndr_atsvc_c.h"
2006-03-14 18:02:05 +03:00
# include "torture/rpc/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
{
NTSTATUS status ;
struct atsvc_JobGetInfo r ;
r . in . servername = dcerpc_server_name ( p ) ;
r . in . job_id = job_id ;
2006-10-16 17:06:41 +04:00
status = dcerpc_atsvc_JobGetInfo ( p , tctx , & r ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
torture_assert_ntstatus_ok ( tctx , status , " 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
{
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 17:06:41 +04:00
status = dcerpc_atsvc_JobDel ( p , tctx , & r ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
torture_assert_ntstatus_ok ( tctx , status , " 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
{
NTSTATUS status ;
struct atsvc_JobEnum r ;
struct atsvc_enum_ctr ctr ;
2004-05-25 20:24:13 +04:00
uint32_t resume_handle = 0 , i ;
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 ;
2006-10-16 17:06:41 +04:00
status = dcerpc_atsvc_JobEnum ( p , tctx , & r ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
torture_assert_ntstatus_ok ( tctx , status , " 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 ) ) {
2003-11-20 06:27:56 +03:00
ret = False ;
}
}
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
{
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-19 01:52:00 +04:00
r . in . job_info = & info ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
status = dcerpc_atsvc_JobAdd ( p , tctx , & r ) ;
2003-11-20 06:27:56 +03:00
2006-10-16 17:06:41 +04:00
torture_assert_ntstatus_ok ( tctx , status , " 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
{
2007-09-01 02:34:52 +04: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
}