s3-schannel: use NL_AUTH_SIGNATURE for schannel sign & seal (client & server).
[Samba/aatanasov.git] / source4 / torture / rpc / ntsvcs.c
blob04494b3223bc8877e6069e2aedea7167e7921a5a
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 "lib/torture/torture.h"
24 #include "torture/rpc/rpc.h"
25 #include "librpc/gen_ndr/ndr_ntsvcs_c.h"
26 #include "torture/util.h"
27 #include "param/param.h"
29 static bool test_PNP_GetVersion(struct torture_context *tctx,
30 struct dcerpc_pipe *p)
32 NTSTATUS status;
33 struct PNP_GetVersion r;
34 uint16_t version = 0;
36 r.out.version = &version;
38 status = dcerpc_PNP_GetVersion(p, tctx, &r);
40 torture_assert_ntstatus_ok(tctx, status, "PNP_GetVersion");
41 torture_assert_werr_ok(tctx, r.out.result, "PNP_GetVersion");
42 torture_assert_int_equal(tctx, version, 0x400, "invalid version");
44 return true;
47 static bool test_PNP_GetDeviceListSize(struct torture_context *tctx,
48 struct dcerpc_pipe *p)
50 struct PNP_GetDeviceListSize r;
51 uint32_t size = 0;
53 r.in.devicename = NULL;
54 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
55 r.out.size = &size;
57 torture_assert_ntstatus_ok(tctx,
58 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
59 "PNP_GetDeviceListSize");
60 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
61 "PNP_GetDeviceListSize");
63 r.in.devicename = "Spooler";
65 torture_assert_ntstatus_ok(tctx,
66 dcerpc_PNP_GetDeviceListSize(p, tctx, &r),
67 "PNP_GetDeviceListSize");
68 torture_assert_werr_ok(tctx, r.out.result,
69 "PNP_GetDeviceListSize");
71 return true;
74 static bool test_PNP_GetDeviceList(struct torture_context *tctx,
75 struct dcerpc_pipe *p)
77 struct PNP_GetDeviceList r;
78 uint16_t *buffer = NULL;
79 uint32_t length = 0;
81 buffer = talloc_array(tctx, uint16_t, 0);
83 r.in.filter = NULL;
84 r.in.flags = CM_GETIDLIST_FILTER_SERVICE;
85 r.in.length = &length;
86 r.out.length = &length;
87 r.out.buffer = buffer;
89 torture_assert_ntstatus_ok(tctx,
90 dcerpc_PNP_GetDeviceList(p, tctx, &r),
91 "PNP_GetDeviceList failed");
92 torture_assert_werr_equal(tctx, r.out.result, WERR_CM_INVALID_POINTER,
93 "PNP_GetDeviceList failed");
95 r.in.filter = "Spooler";
97 torture_assert_ntstatus_ok(tctx,
98 dcerpc_PNP_GetDeviceList(p, tctx, &r),
99 "PNP_GetDeviceList failed");
101 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
102 struct PNP_GetDeviceListSize s;
104 s.in.devicename = "Spooler";
105 s.in.flags = CM_GETIDLIST_FILTER_SERVICE;
106 s.out.size = &length;
108 torture_assert_ntstatus_ok(tctx,
109 dcerpc_PNP_GetDeviceListSize(p, tctx, &s),
110 "PNP_GetDeviceListSize failed");
111 torture_assert_werr_ok(tctx, s.out.result,
112 "PNP_GetDeviceListSize failed");
115 buffer = talloc_array(tctx, uint16_t, length);
117 r.in.length = &length;
118 r.out.length = &length;
119 r.out.buffer = buffer;
121 torture_assert_ntstatus_ok(tctx,
122 dcerpc_PNP_GetDeviceList(p, tctx, &r),
123 "PNP_GetDeviceList failed");
125 torture_assert_werr_ok(tctx, r.out.result,
126 "PNP_GetDeviceList failed");
128 return true;
131 static bool test_PNP_GetDeviceRegProp(struct torture_context *tctx,
132 struct dcerpc_pipe *p)
134 NTSTATUS status;
135 struct PNP_GetDeviceRegProp r;
137 enum winreg_Type reg_data_type = REG_NONE;
138 uint32_t buffer_size = 0;
139 uint32_t needed = 0;
140 uint8_t *buffer;
142 buffer = talloc(tctx, uint8_t);
144 r.in.devicepath = "ACPI\\ACPI0003\\1";
145 r.in.property = DEV_REGPROP_DESC;
146 r.in.flags = 0;
147 r.in.reg_data_type = &reg_data_type;
148 r.in.buffer_size = &buffer_size;
149 r.in.needed = &needed;
150 r.out.buffer = buffer;
151 r.out.reg_data_type = &reg_data_type;
152 r.out.buffer_size = &buffer_size;
153 r.out.needed = &needed;
155 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
156 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
158 if (W_ERROR_EQUAL(r.out.result, WERR_CM_BUFFER_SMALL)) {
160 buffer = talloc_array(tctx, uint8_t, needed);
161 r.in.buffer_size = &needed;
163 status = dcerpc_PNP_GetDeviceRegProp(p, tctx, &r);
164 torture_assert_ntstatus_ok(tctx, status, "PNP_GetDeviceRegProp");
167 return true;
170 struct torture_suite *torture_rpc_ntsvcs(TALLOC_CTX *mem_ctx)
172 struct torture_rpc_tcase *tcase;
173 struct torture_suite *suite = torture_suite_create(mem_ctx, "NTSVCS");
174 struct torture_test *test;
176 tcase = torture_suite_add_rpc_iface_tcase(suite, "ntsvcs",
177 &ndr_table_ntsvcs);
179 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceRegProp",
180 test_PNP_GetDeviceRegProp);
181 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceList",
182 test_PNP_GetDeviceList);
183 test = torture_rpc_tcase_add_test(tcase, "PNP_GetDeviceListSize",
184 test_PNP_GetDeviceListSize);
185 test = torture_rpc_tcase_add_test(tcase, "PNP_GetVersion",
186 test_PNP_GetVersion);
188 return suite;