s4-smbtorture: fix smbtorture after GetPrinterData{Ex} after IDL changes.
[Samba/cd1.git] / source4 / torture / rpc / ntsvcs.c
blobd985244f9814da5769b5e8e14f29a928a8a014c8
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for rpc ntsvcs operations
5 Copyright (C) Guenther Deschner 2008
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.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "includes.h"
23 #include "torture/rpc/rpc.h"
24 #include "librpc/gen_ndr/ndr_ntsvcs_c.h"
26 static bool test_PNP_GetVersion(struct torture_context *tctx,
27 struct dcerpc_pipe *p)
29 NTSTATUS status;
30 struct PNP_GetVersion r;
31 uint16_t version = 0;
33 r.out.version = &version;
35 status = dcerpc_PNP_GetVersion(p, tctx, &r);
37 torture_assert_ntstatus_ok(tctx, status, "PNP_GetVersion");
38 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetVersion");
39 torture_assert_int_equal(tctx, version, 0x400, "invalid version");
41 return true;
44 static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
45 struct dcerpc_pipe *p)
47 struct PNP_GetDeviceListSize r;
48 uint32_t size = 0;
50 r.in.devicename = NULL;
51 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
52 r.out.size = &size;
54 torture_assert_ntstatus_ok(tctx,
55 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
56 "PNP_GetDeviceListSize");
57 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
58 "PNP_GetDeviceListSize");
60 r.in.devicename = "Spooler";
62 torture_assert_ntstatus_ok(tctx,
63 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
64 "PNP_GetDeviceListSize");
65 torture_assert_werr_ok(tctx, r.out.result,
66 "PNP_GetDeviceListSize");
68 return true;
71 static bool test_PNP_GetDeviceList(struct torture_context *tctx,
72 struct dcerpc_pipe *p)
74 struct PNP_GetDeviceList r;
75 uint16_t *buffer = NULL;
76 uint32_t length = 0;
78 buffer = talloc_array(tctx, uint16_t, 0);
80 r.in.filter = NULL;
81 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
82 r.in.length = &length;
83 r.out.length = &length;
84 r.out.buffer = buffer;
86 torture_assert_ntstatus_ok(tctx,
87 dcerpc_PNP_GetDeviceList(p, tctx, &r),
88 "PNP_GetDeviceList failed");
89 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
90 "PNP_GetDeviceList failed");
92 r.in.filter = "Spooler";
94 torture_assert_ntstatus_ok(tctx,
95 dcerpc_PNP_GetDeviceList(p, tctx, &r),
96 "PNP_GetDeviceList failed");
98 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
99 struct PNP_GetDeviceListSize s;
101 s.in.devicename = "Spooler";
102 s.in.flags = CM_GETIDLIST_FILTER_SERVICE;
103 s.out.size = &length;
105 torture_assert_ntstatus_ok(tctx,
106 dcerpc_PNP_GetDeviceListSize(p, tctx, &s),
107 "PNP_GetDeviceListSize failed");
108 torture_assert_werr_ok(tctx, s.out.result,
109 "PNP_GetDeviceListSize failed");
112 buffer = talloc_array(tctx, uint16_t, length);
114 r.in.length = &length;
115 r.out.length = &length;
116 r.out.buffer = buffer;
118 torture_assert_ntstatus_ok(tctx,
119 dcerpc_PNP_GetDeviceList(p, tctx, &r),
120 "PNP_GetDeviceList failed");
122 torture_assert_werr_ok(tctx, r.out.result,
123 "PNP_GetDeviceList failed");
125 return true;
128 static bool test_PNP_GetDeviceRegProp(struct torture_context *tctx,
129 struct dcerpc_pipe *p)
131 NTSTATUS status;
132 struct PNP_GetDeviceRegProp r;
134 enum winreg_Type reg_data_type = REG_NONE;
135 uint32_t buffer_size = 0;
136 uint32_t needed = 0;
137 uint8_t *buffer;
139 buffer = talloc(tctx, uint8_t);
141 r.in.devicepath = "ACPI\\ACPI0003\\1";
142 r.in.property = DEV_REGPROP_DESC;
143 r.in.flags = 0;
144 r.in.reg_data_type = &reg_data_type;
145 r.in.buffer_size = &buffer_size;
146 r.in.needed = &needed;
147 r.out.buffer = buffer;
148 r.out.reg_data_type = &reg_data_type;
149 r.out.buffer_size = &buffer_size;
150 r.out.needed = &needed;
152 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
153 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
155 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
157 buffer = talloc_array(tctx, uint8_t, needed);
158 r.in.buffer_size = &needed;
160 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
161 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
164 return true;
167 struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
169 struct torture_rpc_tcase *tcase;
170 struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
171 struct torture_test *test;
173 tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
174 &ndr_table_ntsvcs);
176 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceRegProp",
177 test_PNP_GetDeviceRegProp);
178 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
179 test_PNP_GetDeviceList);
180 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
181 test_PNP_GetDeviceListSize);
182 test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
183 test_PNP_GetVersion);
185 return suite;