r24557: rename 'dcerpc_table_' -> 'ndr_table_'
[jelmer/samba4-debian.git] / source / torture / rpc / wkssvc.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for wkssvc rpc operations
4
5    Copyright (C) Andrew Tridgell 2003
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "torture/torture.h"
23 #include "librpc/gen_ndr/ndr_wkssvc_c.h"
24 #include "torture/rpc/rpc.h"
25
26 static bool test_NetWkstaGetInfo(struct torture_context *tctx, 
27                                  struct dcerpc_pipe *p)
28 {
29         NTSTATUS status;
30         struct wkssvc_NetWkstaGetInfo r;
31         union wkssvc_NetWkstaInfo info;
32         uint16_t levels[] = {100, 101, 102, 502};
33         int i;
34
35         r.in.server_name = dcerpc_server_name(p);
36         r.out.info = &info;
37
38         for (i=0;i<ARRAY_SIZE(levels);i++) {
39                 r.in.level = levels[i];
40                 torture_comment(tctx, "testing NetWkstaGetInfo level %u\n", r.in.level);
41                 status = dcerpc_wkssvc_NetWkstaGetInfo(p, tctx, &r);
42                 torture_assert_ntstatus_ok(tctx, status, 
43                         talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed", r.in.level));
44                 torture_assert_werr_ok(tctx, r.out.result, 
45                         talloc_asprintf(tctx, "NetWkstaGetInfo level %u failed", r.in.level));
46         }
47
48         return true;
49 }
50
51
52 static bool test_NetWkstaTransportEnum(struct torture_context *tctx,
53                                        struct dcerpc_pipe *p)
54 {
55         NTSTATUS status;
56         struct wkssvc_NetWkstaTransportEnum r;
57         uint32_t resume_handle = 0;
58         union wkssvc_NetWkstaTransportCtr ctr;
59         struct wkssvc_NetWkstaTransportCtr0 ctr0;
60
61         ZERO_STRUCT(ctr0);
62         ctr.ctr0 = &ctr0;
63
64         r.in.server_name = dcerpc_server_name(p);
65         r.in.level = 0;
66         r.in.ctr = &ctr;
67         r.in.max_buffer = (uint32_t)-1;
68         r.in.resume_handle = &resume_handle;
69         r.out.ctr = &ctr;
70         r.out.resume_handle = &resume_handle;
71
72         status = dcerpc_wkssvc_NetWkstaTransportEnum(p, tctx, &r);
73         torture_assert_ntstatus_ok(tctx, status, "NetWkstaTransportEnum failed");
74         torture_assert_werr_ok(tctx, r.out.result, talloc_asprintf(tctx, 
75                 "NetWkstaTransportEnum level %u failed", r.in.level));
76
77         return true;
78 }
79
80 struct torture_suite *torture_rpc_wkssvc(void)
81 {
82         struct torture_suite *suite;
83         struct torture_tcase *tcase;
84
85         suite = torture_suite_create(talloc_autofree_context(), "WKSSVC");
86         tcase = torture_suite_add_rpc_iface_tcase(suite, "wkssvc",
87                                                   &ndr_table_wkssvc);
88
89         torture_rpc_tcase_add_test(tcase, "NetWkstaGetInfo", test_NetWkstaGetInfo);
90         torture_rpc_tcase_add_test(tcase, "NetWkstaTransportEnum", 
91                                    test_NetWkstaTransportEnum);
92         return suite;
93 }