s3/docs: Remove reference to nonexistent file.
[Samba/gbeck.git] / source4 / torture / ndr / winreg.c
blobde804b77218442942c18140aefead35cb2915987
1 /*
2 Unix SMB/CIFS implementation.
3 test suite for winreg ndr operations
5 Copyright (C) Jelmer Vernooij 2007
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, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "torture/ndr/ndr.h"
23 #include "librpc/gen_ndr/ndr_winreg.h"
24 #include "librpc/gen_ndr/ndr_security.h"
25 #include "libcli/security/security.h"
27 static const uint8_t closekey_in_data[] = {
28 0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48,
29 0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
32 static bool closekey_in_check(struct torture_context *tctx,
33 struct winreg_CloseKey *ck)
35 torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
36 torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
37 return true;
40 const static uint8_t closekey_out_data[] = {
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
45 static bool closekey_out_check(struct torture_context *tctx,
46 struct winreg_CloseKey *ck)
48 torture_assert_int_equal(tctx, ck->out.handle->handle_type, 0, "handle type");
49 torture_assert_werr_ok(tctx, ck->out.result, "return code");
50 return true;
53 static const uint8_t OpenHKLM_In[] = {
54 0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
57 static bool openhklm_in_check(struct torture_context *tctx,
58 struct winreg_OpenHKLM *r)
60 torture_assert(tctx, r->in.system_name != NULL, "system name pointer");
61 torture_assert_int_equal(tctx, *r->in.system_name, 34016, "system name");
62 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
63 return true;
66 static const uint8_t openhklm_out_data[] = {
67 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
68 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00
71 static bool openhklm_out_check(struct torture_context *tctx,
72 struct winreg_OpenHKLM *r)
74 torture_assert(tctx, r->out.handle != NULL, "handle pointer");
75 torture_assert_int_equal(tctx, r->out.handle->handle_type, 0, "handle_type");
76 torture_assert_werr_ok(tctx, r->out.result, "return code");
77 return true;
80 static const uint8_t createkey_in_data[] = {
81 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
82 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
83 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
85 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
88 0x00, 0x00, 0x00, 0x00
91 static bool createkey_in_check(struct torture_context *tctx,
92 struct winreg_CreateKey *r)
94 torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
95 torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
96 torture_assert_int_equal(tctx, r->in.options, 0, "option");
97 torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
98 torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
99 torture_assert(tctx, r->in.action_taken == NULL, "action_taken");
101 return true;
104 static const uint8_t createkey_out_data[] = {
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x57, 0x00, 0x00, 0x00
110 static bool createkey_out_check(struct torture_context *tctx,
111 struct winreg_CreateKey *r)
113 torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
114 torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
115 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM,
116 "return code");
118 return true;
121 static const uint8_t enumvalue_in_data[] = {
122 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
123 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x05, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
126 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
128 0xff, 0xff, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
131 static bool enumvalue_in_check(struct torture_context *tctx,
132 struct winreg_EnumValue *r)
134 torture_assert_int_equal(tctx, r->in.enum_index, 5, "enum index");
135 torture_assert(tctx, r->in.type != NULL, "type pointer");
136 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
137 torture_assert_int_equal(tctx, *r->in.size, 65535, "size");
138 torture_assert_int_equal(tctx, *r->in.length, 0, "length");
139 torture_assert_int_equal(tctx, r->in.name->size, 512, "name size");
140 torture_assert_int_equal(tctx, r->in.name->length, 0, "name length");
142 return true;
145 static const uint8_t enumvalue_out_data[] = {
146 0x12, 0x00, 0x00, 0x02, 0x28, 0x91, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
147 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
148 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0xd8, 0x8c, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
150 0xe0, 0x00, 0x0c, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
151 0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x63, 0x00,
152 0x75, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x73, 0x00,
153 0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x53, 0x00,
154 0x65, 0x00, 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00,
155 0x73, 0x00, 0x5c, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6d, 0x00, 0x69, 0x00,
156 0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00,
157 0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf0, 0x8c, 0x07, 0x00,
158 0x4c, 0x00, 0x00, 0x00, 0xf8, 0x8c, 0x07, 0x00, 0x4c, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00
162 static bool enumvalue_out_check(struct torture_context *tctx,
163 struct winreg_EnumValue *r)
165 torture_assert_int_equal(tctx, r->out.name->size, 512, "name size");
166 torture_assert_int_equal(tctx, r->out.name->length, 18, "name length");
167 torture_assert_str_equal(tctx, r->out.name->name, "HOMEPATH", "name");
168 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
169 torture_assert_int_equal(tctx, *r->out.size, 76, "size");
170 torture_assert_int_equal(tctx, *r->out.length, 76, "length");
171 torture_assert_werr_ok(tctx, r->out.result, "return code");
173 return true;
176 unsigned char enumvalue_in_data2[] = {
177 0x00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0xda, 0x45, 0x9c, 0xed, 0xe2, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x02, 0xcc, 0xf9, 0x06, 0x00, 0x00, 0x01, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xf9, 0x06, 0x00,
181 0x39, 0xa6, 0x07, 0x00, 0x00, 0xc4, 0x04, 0x01, 0x00, 0x80, 0x00, 0x00,
182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0xf9, 0x06, 0x00,
183 0x00, 0x80, 0x00, 0x00, 0x94, 0xf9, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00
186 static const uint8_t queryvalue_in_data[] = {
187 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
188 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x12, 0x00, 0x12, 0x00,
189 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00,
191 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,
192 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
193 0x03, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
194 0x00, 0x00, 0x00, 0x00
197 static bool queryvalue_in_check(struct torture_context *tctx,
198 struct winreg_QueryValue *r)
200 torture_assert_str_equal(tctx, r->in.value_name->name, "HOMEPATH", "name");
201 torture_assert_int_equal(tctx, *r->in.type, 0, "type");
202 torture_assert_int_equal(tctx, *r->in.data_size, 4095, "size");
203 torture_assert_int_equal(tctx, *r->in.data_length, 0, "length");
204 torture_assert(tctx, r->in.data == NULL, "data pointer");
206 return true;
209 static const uint8_t queryvalue_out_data[] = {
210 0xd8, 0xf5, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0xe4, 0xf5, 0x0b, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xec, 0xf5, 0x0b, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
215 static bool queryvalue_out_check(struct torture_context *tctx,
216 struct winreg_QueryValue *r)
218 torture_assert_werr_ok(tctx, r->out.result, "return code");
219 torture_assert_int_equal(tctx, *r->out.type, 1, "type");
220 torture_assert(tctx, r->out.data == NULL, "data pointer");
221 torture_assert_int_equal(tctx, *r->out.data_size, 76, "size");
222 torture_assert_int_equal(tctx, *r->out.data_length, 0, "length");
224 return true;
227 static const uint8_t querymultiplevalues_in_data[] = {
228 0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
229 0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x01, 0x00, 0x00, 0x00,
230 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232 0x12, 0x00, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
233 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
234 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
235 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
236 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00
242 static bool querymultiplevalues_in_check(struct torture_context *tctx,
243 struct winreg_QueryMultipleValues *r)
245 torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
246 torture_assert_str_equal(tctx, r->in.values[0].name->name, "HOMEPATH",
247 "name");
249 torture_assert_int_equal(tctx, r->in.values[0].type, 0, "type");
250 torture_assert_int_equal(tctx, r->in.values[0].offset, 0, "offset");
251 torture_assert_int_equal(tctx, r->in.values[0].length, 0, "length");
252 torture_assert_int_equal(tctx, *r->in.buffer_size, 76, "buffer size");
254 return true;
257 static const uint8_t querymultiplevalues_out_data[] = {
258 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
259 0xd8, 0x8c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
260 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x38, 0x87, 0x07, 0x00,
261 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
262 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00,
263 0x54, 0x00, 0x48, 0x00, 0xc8, 0x95, 0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,
264 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
267 0x00, 0x00, 0x00, 0x00, 0x4c, 0x4d, 0x45, 0x4d, 0xc8, 0x95, 0x08, 0x00,
268 0x50, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x07, 0x00,
269 0x00, 0x01, 0x0c, 0x00, 0x50, 0x95, 0x08, 0x00, 0x48, 0x96, 0x08, 0x00,
270 0xdc, 0x00, 0x00, 0x00, 0xc0, 0x83, 0x00, 0x01, 0x0d, 0xf0, 0xff, 0xff,
271 0x4c, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
274 static bool querymultiplevalues_out_check(struct torture_context *tctx,
275 struct winreg_QueryMultipleValues *r)
277 torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH",
278 "name");
280 torture_assert_int_equal(tctx, r->out.values[0].type, 0, "type");
281 torture_assert_int_equal(tctx, r->out.values[0].offset, 0, "offset");
282 torture_assert_int_equal(tctx, r->out.values[0].length, 0, "length");
283 /* FIXME: r->out.buffer */
284 torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size");
285 torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA,
286 "return code");
288 return true;
291 static const uint8_t flushkey_in_data[] = {
292 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
293 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
296 static bool flushkey_in_check(struct torture_context *tctx,
297 struct winreg_FlushKey *r)
299 torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle type");
300 return true;
303 static const uint8_t flushkey_out_data[] = {
304 0x00, 0x00, 0x00, 0x00
307 static bool flushkey_out_check(struct torture_context *tctx,
308 struct winreg_FlushKey *r)
310 torture_assert_werr_ok(tctx, r->out.result, "return code");
311 return true;
315 static const uint8_t openkey_in_data[] = {
316 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
317 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
318 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
319 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
320 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
324 static bool openkey_in_check(struct torture_context *tctx, struct winreg_OpenKey *r)
326 torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
327 torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
328 torture_assert_str_equal(tctx, r->in.keyname.name, "spottyfoot", "keyname");
329 /* FIXME: parent handle */
330 return true;
333 static const uint8_t openkey_out_data[] = {
334 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
335 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
338 static bool openkey_out_check(struct torture_context *tctx, struct winreg_OpenKey *r)
340 torture_assert(tctx, GUID_all_zero(&r->out.handle->uuid), "handle");
341 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
342 return true;
345 static const uint8_t deletekey_in_data[] = {
346 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
347 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
348 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
349 0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
350 0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
351 0x00, 0x00
354 static bool deletekey_in_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
356 /* FIXME: Handle */
357 torture_assert_str_equal(tctx, r->in.key.name, "spottyfoot", "key name");
358 return true;
361 static const uint8_t deletekey_out_data[] = {
362 0x02, 0x00, 0x00, 0x00
365 static bool deletekey_out_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
367 torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
368 return true;
371 static const uint8_t getversion_in_data[] = {
372 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
373 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
376 static bool getversion_in_check(struct torture_context *tctx, struct winreg_GetVersion *r)
378 /* FIXME: Handle */
379 return true;
382 static const uint8_t getversion_out_data[] = {
383 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
386 static bool getversion_out_check(struct torture_context *tctx, struct winreg_GetVersion *r)
388 torture_assert_int_equal(tctx, *r->out.version, 5, "version");
389 torture_assert_werr_ok(tctx, r->out.result, "return code");
390 return true;
393 static const uint8_t queryinfokey_in_data[] = {
394 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
395 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00,
396 0x00, 0x00, 0x00, 0x00
399 static bool queryinfokey_in_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
401 /* FIXME: Handle */
402 torture_assert(tctx, r->in.classname->name == NULL, "class in");
403 return true;
406 static const uint8_t queryinfokey_out_data[] = {
407 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
408 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
410 0x10, 0x48, 0x02, 0x3a, 0xcf, 0xfd, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00
413 static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
415 torture_assert(tctx, r->out.classname != NULL, "class out");
416 torture_assert(tctx, r->out.classname->name != NULL, "class out name");
417 torture_assert_str_equal(tctx, r->out.classname->name, "", "class out name");
418 torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys");
419 torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length");
420 torture_assert_int_equal(tctx, *r->out.max_classlen, 140, "subkey size");
421 torture_assert_werr_ok(tctx, r->out.result, "return code");
422 return true;
425 static const uint8_t notifychangekeyvalue_in_data[] = {
426 0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
427 0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x01, 0x00, 0x00, 0x00,
428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
429 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
430 0x00, 0x00, 0x00, 0x00
433 static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
435 torture_assert_int_equal(tctx, r->in.watch_subtree, 1, "watch subtree");
436 torture_assert_int_equal(tctx, r->in.notify_filter, 0, "notify filter");
437 torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
438 torture_assert(tctx, r->in.string1.name == NULL, "string1");
439 torture_assert(tctx, r->in.string2.name == NULL, "string2");
440 torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown2");
441 return true;
444 static const uint8_t notifychangekeyvalue_out_data[] = {
445 0x57, 0x00, 0x00, 0x00
448 static bool notifychangekeyvalue_out_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
450 torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "notify change key value");
451 return true;
454 static const uint8_t getkeysecurity_in_data[] = {
455 0x00, 0x00, 0x00, 0x00, 0xbd, 0xaa, 0xf6, 0x59, 0xc1, 0x82, 0x1f, 0x4d,
456 0x84, 0xa9, 0xdd, 0xae, 0x60, 0x77, 0x1e, 0x45, 0x00, 0x00, 0x00, 0x02,
457 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
460 static bool getkeysecurity_in_check(struct torture_context *tctx,
461 struct winreg_GetKeySecurity *r)
463 /* FIXME: Handle */
464 torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
465 torture_assert_int_equal(tctx, r->in.sd->size, 65536, "sd size");
466 torture_assert_int_equal(tctx, r->in.sd->len, 0, "sd len");
467 torture_assert(tctx, r->in.sd->data == NULL, "sd data");
468 return true;
471 static const uint8_t getkeysecurity_out_data[] = {
472 0x08, 0x91, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
473 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
474 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
478 static bool getkeysecurity_out_check(struct torture_context *tctx,
479 struct winreg_GetKeySecurity *r)
481 torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
482 torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
483 torture_assert_werr_ok(tctx, r->out.result, "return code");
484 return true;
487 static const uint8_t enumkey_in_data[] = {
488 0x00, 0x00, 0x00, 0x00, 0x85, 0xb8, 0x41, 0xb0, 0x17, 0xe4, 0x28, 0x45,
489 0x8a, 0x69, 0xbf, 0x40, 0x79, 0x82, 0x8b, 0xcb, 0x00, 0x00, 0x00, 0x00,
490 0x00, 0x00, 0x14, 0x04, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x02, 0x00, 0x00,
491 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
492 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
493 0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f
496 static bool enumkey_in_check(struct torture_context *tctx, struct winreg_EnumKey *r)
498 torture_assert_int_equal(tctx, r->in.enum_index, 0, "enum index");
499 torture_assert_int_equal(tctx, r->in.name->size, 1044, "name size");
500 torture_assert_int_equal(tctx, r->in.name->length, 0, "name len");
501 torture_assert(tctx, r->in.keyclass != NULL, "keyclass pointer");
502 torture_assert(tctx, r->in.keyclass->name == NULL, "keyclass");
503 torture_assert(tctx, r->in.last_changed_time != NULL, "last_changed_time != NULL");
504 return true;
507 static const uint8_t enumkey_out_data[] = {
508 0x08, 0x00, 0x14, 0x04, 0x18, 0xe8, 0x07, 0x00, 0x0a, 0x02, 0x00, 0x00,
509 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x53, 0x00, 0x41, 0x00,
510 0x4d, 0x00, 0x00, 0x00, 0xd0, 0x62, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
511 0x00, 0x00, 0x00, 0x00, 0xdc, 0x62, 0x07, 0x00, 0x50, 0x67, 0xd0, 0x8b,
512 0x16, 0x06, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x00
515 static bool enumkey_out_check(struct torture_context *tctx, struct winreg_EnumKey *r)
517 torture_assert_int_equal(tctx, r->out.name->size, 1044, "name size");
518 torture_assert_int_equal(tctx, r->out.name->length, 8, "name len");
519 torture_assert(tctx, r->out.keyclass != NULL, "keyclass pointer");
520 torture_assert(tctx, r->out.keyclass->name == NULL, "keyclass");
521 torture_assert(tctx, r->out.last_changed_time != NULL, "last_changed_time pointer");
522 /* FIXME: *last_changed_time */
523 return true;
526 struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
528 struct torture_suite *suite = torture_suite_create(ctx, "winreg");
530 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
531 torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_OUT, closekey_out_check );
533 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
534 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
536 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
537 torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
539 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
540 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
541 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data2, NDR_IN, NULL);
543 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
544 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
546 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
547 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_out_data, NDR_OUT, querymultiplevalues_out_check );*/
549 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_in_data, NDR_IN, flushkey_in_check );
550 torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_out_data, NDR_OUT, flushkey_out_check );
552 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_in_data, NDR_IN, openkey_in_check );
553 torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_out_data, NDR_OUT, openkey_out_check );
555 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_in_data, NDR_IN, deletekey_in_check );
556 torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_out_data, NDR_OUT, deletekey_out_check );
558 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_in_data, NDR_IN, getversion_in_check );
559 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_out_data, NDR_OUT, getversion_out_check );
561 torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_in_data, NDR_IN, queryinfokey_in_check );
562 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_out_data, NDR_OUT, queryinfokey_out_check );*/
564 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_in_data, NDR_IN, notifychangekeyvalue_in_check );
565 torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_out_data, NDR_OUT, notifychangekeyvalue_out_check );
567 /*torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_in_data, NDR_IN, getkeysecurity_in_check );
568 torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_out_data, NDR_OUT, getkeysecurity_out_check );*/
570 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_in_data, NDR_IN, enumkey_in_check );
571 torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_out_data, NDR_OUT, enumkey_out_check );
573 return suite;