2007-11-27 11:35:10 +03:00
/*
2003-11-17 15:43:18 +03:00
Unix SMB / CIFS implementation .
test suite for wkssvc rpc operations
Copyright ( C ) Andrew Tridgell 2003
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +03:00
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-17 15:43:18 +03:00
( at your option ) any later version .
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +03:00
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 .
2007-11-27 11:35:10 +03:00
2003-11-17 15:43:18 +03:00
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-17 15:43:18 +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_wkssvc_c.h"
2006-03-14 18:02:05 +03:00
# include "torture/rpc/rpc.h"
2007-11-27 11:41:50 +03:00
# include "lib/cmdline/popt_common.h"
# include "param/param.h"
2003-11-17 15:43:18 +03:00
2007-11-27 11:49:19 +03:00
# define SMBTORTURE_TRANSPORT_NAME "\\Device\\smbtrt_transport_name"
2007-11-27 11:35:10 +03:00
static bool test_NetWkstaGetInfo ( struct torture_context * tctx ,
2007-04-12 15:35:00 +04:00
struct dcerpc_pipe * p )
2003-11-17 15:43:18 +03:00
{
NTSTATUS status ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaGetInfo r ;
2006-07-26 16:25:16 +04:00
union wkssvc_NetWkstaInfo info ;
2004-05-25 21:24:24 +04:00
uint16_t levels [ ] = { 100 , 101 , 102 , 502 } ;
2003-11-18 04:18:24 +03:00
int i ;
2003-11-17 15:43:18 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2006-07-26 16:25:16 +04:00
r . out . info = & info ;
2003-11-17 15:43:18 +03:00
2003-11-18 04:18:24 +03:00
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
r . in . level = levels [ i ] ;
2007-04-12 15:35:00 +04:00
torture_comment ( tctx , " testing NetWkstaGetInfo level %u \n " , r . in . level ) ;
2006-10-16 17:06:41 +04:00
status = dcerpc_wkssvc_NetWkstaGetInfo ( p , tctx , & r ) ;
2007-11-27 11:35:10 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
2006-10-16 17:06:41 +04:00
talloc_asprintf ( tctx , " NetWkstaGetInfo level %u failed " , r . in . level ) ) ;
2007-11-27 11:35:10 +03:00
torture_assert_werr_ok ( tctx , r . out . result ,
2006-10-16 17:06:41 +04:00
talloc_asprintf ( tctx , " NetWkstaGetInfo level %u failed " , r . in . level ) ) ;
2003-11-17 15:43:18 +03:00
}
2006-10-16 17:06:41 +04:00
return true ;
2003-11-17 15:43:18 +03:00
}
2006-10-16 17:06:41 +04:00
static bool test_NetWkstaTransportEnum ( struct torture_context * tctx ,
2007-04-12 15:35:00 +04:00
struct dcerpc_pipe * p )
2003-11-18 06:28:01 +03:00
{
NTSTATUS status ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaTransportEnum r ;
2004-05-25 20:24:13 +04:00
uint32_t resume_handle = 0 ;
2007-11-27 11:49:19 +03:00
struct wkssvc_NetWkstaTransportInfo info ;
2005-12-06 06:53:51 +03:00
union wkssvc_NetWkstaTransportCtr ctr ;
2003-12-21 10:53:57 +03:00
struct wkssvc_NetWkstaTransportCtr0 ctr0 ;
2007-11-27 11:49:19 +03:00
uint32_t total_entries = 0 ;
2003-11-18 06:28:01 +03:00
2003-12-21 10:53:57 +03:00
ZERO_STRUCT ( ctr0 ) ;
2005-12-06 06:53:51 +03:00
ctr . ctr0 = & ctr0 ;
2003-11-18 06:28:01 +03:00
2007-11-27 11:49:19 +03:00
info . level = 0 ;
info . ctr = ctr ;
2003-11-18 06:28:01 +03:00
r . in . server_name = dcerpc_server_name ( p ) ;
2007-11-27 11:49:19 +03:00
r . in . info = & info ;
2004-05-25 20:24:13 +04:00
r . in . max_buffer = ( uint32_t ) - 1 ;
2003-11-18 06:28:01 +03:00
r . in . resume_handle = & resume_handle ;
2007-11-27 11:49:19 +03:00
r . out . total_entries = & total_entries ;
r . out . info = & info ;
2003-11-18 06:28:01 +03:00
r . out . resume_handle = & resume_handle ;
2007-11-27 11:49:19 +03:00
torture_comment ( tctx , " testing NetWkstaTransportEnum level 0 \n " ) ;
2006-10-16 17:06:41 +04:00
status = dcerpc_wkssvc_NetWkstaTransportEnum ( p , tctx , & r ) ;
2007-11-27 11:49:19 +03:00
torture_assert_ntstatus_ok ( tctx , status ,
" NetWkstaTransportEnum failed " ) ;
2007-11-27 11:35:10 +03:00
torture_assert_werr_ok ( tctx , r . out . result , talloc_asprintf ( tctx ,
2007-11-27 11:49:19 +03:00
" NetWkstaTransportEnum level %u failed " ,
info . level ) ) ;
return true ;
}
static bool test_NetrWkstaTransportAdd ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaTransportAdd r ;
struct wkssvc_NetWkstaTransportInfo0 info0 ;
uint32_t parm_err = 0 ;
ZERO_STRUCT ( info0 ) ;
info0 . quality_of_service = 0xffff ;
info0 . vc_count = 0 ;
info0 . name = SMBTORTURE_TRANSPORT_NAME ;
info0 . address = " 000000000000 " ;
info0 . wan_link = 0x400 ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . level = 0 ;
r . in . info0 = & info0 ;
r . in . parm_err = r . out . parm_err = & parm_err ;
torture_comment ( tctx , " testing NetrWkstaTransportAdd level 0 \n " ) ;
status = dcerpc_wkssvc_NetrWkstaTransportAdd ( p , tctx , & r ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaTransportAdd failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
WERR_INVALID_PARAM ,
" NetrWkstaTransportAdd level 0 failed " ) ;
return true ;
}
static bool test_NetrWkstaTransportDel ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaTransportDel r ;
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . transport_name = SMBTORTURE_TRANSPORT_NAME ;
r . in . unknown3 = 0 ;
torture_comment ( tctx , " testing NetrWkstaTransportDel \n " ) ;
status = dcerpc_wkssvc_NetrWkstaTransportDel ( p , tctx , & r ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaTransportDel failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrWkstaTransportDel " ) ;
2003-11-18 06:28:01 +03:00
2006-10-16 17:06:41 +04:00
return true ;
2003-11-18 06:28:01 +03:00
}
2007-11-27 11:35:10 +03:00
static bool test_NetWkstaEnumUsers ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetWkstaEnumUsers r ;
uint32_t handle = 0 ;
uint32_t entries_read = 0 ;
struct wkssvc_NetWkstaEnumUsersInfo info ;
struct wkssvc_NetWkstaEnumUsersCtr0 * user0 ;
struct wkssvc_NetWkstaEnumUsersCtr1 * user1 ;
uint32_t levels [ ] = { 0 , 1 } ;
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
ZERO_STRUCT ( info ) ;
info . level = levels [ i ] ;
switch ( info . level ) {
case 0 :
user0 = talloc_zero ( tctx ,
struct wkssvc_NetWkstaEnumUsersCtr0 ) ;
info . ctr . user0 = user0 ;
break ;
case 1 :
user1 = talloc_zero ( tctx ,
struct wkssvc_NetWkstaEnumUsersCtr1 ) ;
info . ctr . user1 = user1 ;
break ;
default :
break ;
}
r . in . server_name = dcerpc_server_name ( p ) ;
r . in . prefmaxlen = ( uint32_t ) - 1 ;
r . in . info = r . out . info = & info ;
r . in . resume_handle = r . out . resume_handle = & handle ;
r . out . entries_read = & entries_read ;
torture_comment ( tctx , " testing NetWkstaEnumUsers level %u \n " ,
levels [ i ] ) ;
status = dcerpc_wkssvc_NetWkstaEnumUsers ( p , tctx , & r ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" NetWkstaEnumUsers failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetWkstaEnumUsers failed " ) ;
}
return true ;
}
2007-11-27 11:41:50 +03:00
static bool test_NetrWkstaUserGetInfo ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrWkstaUserGetInfo r ;
union wkssvc_NetrWkstaUserInfo info ;
const char * dom = lp_workgroup ( global_loadparm ) ;
struct cli_credentials * creds = cmdline_credentials ;
const char * user = cli_credentials_get_username ( creds ) ;
int i ;
const struct {
const char * unknown ;
uint32_t level ;
WERROR result ;
} tests [ ] = {
{ NULL , 0 , WERR_NO_SUCH_LOGON_SESSION } ,
{ NULL , 1 , WERR_NO_SUCH_LOGON_SESSION } ,
{ NULL , 1101 , WERR_OK } ,
{ dom , 0 , WERR_INVALID_PARAM } ,
{ dom , 1 , WERR_INVALID_PARAM } ,
{ dom , 1101 , WERR_INVALID_PARAM } ,
{ user , 0 , WERR_INVALID_PARAM } ,
{ user , 1 , WERR_INVALID_PARAM } ,
{ user , 1101 , WERR_INVALID_PARAM } ,
} ;
for ( i = 0 ; i < ARRAY_SIZE ( tests ) ; i + + ) {
r . in . unknown = tests [ i ] . unknown ;
r . in . level = tests [ i ] . level ;
r . out . info = & info ;
torture_comment ( tctx , " testing NetrWkstaUserGetInfo level %u \n " ,
r . in . level ) ;
status = dcerpc_wkssvc_NetrWkstaUserGetInfo ( p , tctx , & r ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" NetrWkstaUserGetInfo failed " ) ;
torture_assert_werr_equal ( tctx , r . out . result ,
tests [ i ] . result ,
" NetrWkstaUserGetInfo failed " ) ;
}
return true ;
}
2007-11-27 12:07:00 +03:00
static bool test_NetrUseEnum ( struct torture_context * tctx ,
struct dcerpc_pipe * p )
{
NTSTATUS status ;
struct wkssvc_NetrUseEnum r ;
uint32_t handle = 0 ;
uint32_t entries_read = 0 ;
struct wkssvc_NetrUseEnumInfo info ;
struct wkssvc_NetrUseEnumCtr0 * use0 ;
struct wkssvc_NetrUseEnumCtr1 * use1 ;
struct wkssvc_NetrUseEnumCtr2 * use2 ;
uint32_t levels [ ] = { 0 , 1 , 2 } ;
int i ;
for ( i = 0 ; i < ARRAY_SIZE ( levels ) ; i + + ) {
ZERO_STRUCT ( info ) ;
info . level = levels [ i ] ;
switch ( info . level ) {
case 0 :
use0 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr0 ) ;
info . ctr . ctr0 = use0 ;
break ;
case 1 :
use1 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr1 ) ;
info . ctr . ctr1 = use1 ;
break ;
case 2 :
use2 = talloc_zero ( tctx , struct wkssvc_NetrUseEnumCtr2 ) ;
info . ctr . ctr2 = use2 ;
break ;
default :
break ;
}
r . in . server_name = talloc_asprintf ( tctx , " \\ \\ %s " , dcerpc_server_name ( p ) ) ;
r . in . prefmaxlen = ( uint32_t ) - 1 ;
r . in . info = r . out . info = & info ;
r . in . resume_handle = r . out . resume_handle = & handle ;
r . out . entries_read = & entries_read ;
torture_comment ( tctx , " testing NetrUseEnum level %u \n " ,
levels [ i ] ) ;
status = dcerpc_wkssvc_NetrUseEnum ( p , tctx , & r ) ;
torture_assert_ntstatus_ok ( tctx , status ,
" NetrUseEnum failed " ) ;
torture_assert_werr_ok ( tctx , r . out . result ,
" NetrUseEnum failed " ) ;
}
return true ;
}
2007-08-28 23:03:08 +04:00
struct torture_suite * torture_rpc_wkssvc ( TALLOC_CTX * mem_ctx )
2003-11-17 15:43:18 +03:00
{
2006-10-16 17:06:41 +04:00
struct torture_suite * suite ;
2007-08-28 20:24:18 +04:00
struct torture_rpc_tcase * tcase ;
2003-11-18 06:28:01 +03:00
2007-08-28 23:03:08 +04:00
suite = torture_suite_create ( mem_ctx , " WKSSVC " ) ;
2007-04-12 15:35:00 +04:00
tcase = torture_suite_add_rpc_iface_tcase ( suite , " wkssvc " ,
2007-08-20 01:23:03 +04:00
& ndr_table_wkssvc ) ;
2003-11-22 11:11:32 +03:00
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaGetInfo " ,
test_NetWkstaGetInfo ) ;
2007-11-27 11:49:19 +03:00
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaTransportEnum " ,
2007-04-12 15:35:00 +04:00
test_NetWkstaTransportEnum ) ;
2007-11-27 11:49:19 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrWkstaTransportDel " ,
test_NetrWkstaTransportDel ) ;
torture_rpc_tcase_add_test ( tcase , " NetrWkstaTransportAdd " ,
test_NetrWkstaTransportAdd ) ;
2007-11-27 11:35:10 +03:00
torture_rpc_tcase_add_test ( tcase , " NetWkstaEnumUsers " ,
test_NetWkstaEnumUsers ) ;
2007-11-27 11:41:50 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrWkstaUserGetInfo " ,
test_NetrWkstaUserGetInfo ) ;
2007-11-27 11:35:10 +03:00
2007-11-27 12:07:00 +03:00
torture_rpc_tcase_add_test ( tcase , " NetrUseEnum " ,
test_NetrUseEnum ) ;
2006-10-16 17:06:41 +04:00
return suite ;
2003-11-17 15:43:18 +03:00
}