r21372: Tests, more tests! Some are still commented out, because the code they test...
[ira/wip.git] / source / torture / ndr / winreg.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for winreg ndr operations
4
5    Copyright (C) Jelmer Vernooij 2007
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 2 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, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23 #include "torture/ndr/ndr.h"
24 #include "librpc/gen_ndr/ndr_winreg.h"
25 #include "librpc/gen_ndr/ndr_security.h"
26 #include "libcli/security/security.h"
27
28 static const uint8_t closekey_in_data[] = { 
29         0x00, 0x00, 0x00, 0x00, 0x1d, 0xd8, 0xd7, 0xaa, 0x8d, 0x6c, 0x3f, 0x48, 
30         0xa7, 0x1e, 0x02, 0x6a, 0x47, 0xf6, 0x7b, 0xae
31 };
32
33 static bool closekey_in_check(struct torture_context *tctx, 
34                                                                   struct winreg_CloseKey *ck)
35 {
36         torture_assert(tctx, ck->in.handle != NULL, "handle invalid");
37         torture_assert_int_equal(tctx, ck->in.handle->handle_type, 0, "handle type");
38         return true;
39 }
40
41 const static uint8_t closekey_out_data[] = {
42   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
44 };
45
46 static bool closekey_out_check(struct torture_context *tctx, 
47                                                            struct winreg_CloseKey *ck)
48 {
49         torture_assert_int_equal(tctx, ck->out.handle->handle_type, 0, "handle type");
50         torture_assert_werr_ok(tctx, ck->out.result, "return code");
51         return true;
52 }
53
54 static const uint8_t OpenHKLM_In[] = {
55   0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
56 };
57
58 static bool openhklm_in_check(struct torture_context *tctx, 
59                                                                   struct winreg_OpenHKLM *r)
60 {
61         torture_assert(tctx, r->in.system_name != NULL, "system name pointer");
62         torture_assert_int_equal(tctx, *r->in.system_name, 34016, "system name");
63         torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
64         return true;
65 }
66
67 static const uint8_t openhklm_out_data[] = {
68   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
69   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00
70 };
71
72 static bool openhklm_out_check(struct torture_context *tctx, 
73                                                                   struct winreg_OpenHKLM *r)
74 {
75         torture_assert(tctx, r->out.handle != NULL, "handle pointer");
76         torture_assert_int_equal(tctx, r->out.handle->handle_type, 0, "handle_type");
77         torture_assert_werr_ok(tctx, r->out.result, "return code");
78         return true;
79 }
80
81 static const uint8_t createkey_in_data[] = {
82   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
83   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
84   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85   0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
86   0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
87   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
88   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
89   0x00, 0x00, 0x00, 0x00
90 };
91
92 static bool createkey_in_check(struct torture_context *tctx, 
93                                                                   struct winreg_CreateKey *r)
94 {
95         torture_assert_str_equal(tctx, r->in.name.name, "spottyfoot", "name");
96         torture_assert(tctx, r->in.keyclass.name == NULL, "keyclass");
97         torture_assert_int_equal(tctx, r->in.options, 0, "option");
98         torture_assert_int_equal(tctx, r->in.access_mask, 0x2000000, "access mask");
99         torture_assert(tctx, r->in.secdesc == NULL, "secdesc");
100         torture_assert(tctx, r->in.action_taken == NULL, "action_taken");
101
102         return true;
103 }
104
105 static const uint8_t createkey_out_data[] = {
106   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108   0x57, 0x00, 0x00, 0x00
109 };
110
111 static bool createkey_out_check(struct torture_context *tctx, 
112                                                                   struct winreg_CreateKey *r)
113 {
114         torture_assert(tctx, GUID_all_zero(&r->out.new_handle->uuid), "new_handle");
115         torture_assert(tctx, r->out.action_taken == NULL, "action_taken pointer");
116         torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, 
117                                                           "return code");
118
119         return true;
120 }
121
122 static const uint8_t enumvalue_in_data[] = {
123   0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
124   0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x05, 0x00, 0x00, 0x00,
125   0x00, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
126   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
127   0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
128   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
129   0xff, 0xff, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
130 };
131
132 static bool enumvalue_in_check(struct torture_context *tctx, 
133                                                                   struct winreg_EnumValue *r)
134 {
135         torture_assert_int_equal(tctx, r->in.enum_index, 5, "enum index");
136         torture_assert(tctx, r->in.type != NULL, "type pointer");
137         torture_assert_int_equal(tctx, *r->in.type, 0, "type");
138         torture_assert_int_equal(tctx, *r->in.size, 65535, "size");
139         torture_assert_int_equal(tctx, *r->in.length, 0, "length");
140         torture_assert_int_equal(tctx, r->in.name->size, 512, "name size");
141         torture_assert_int_equal(tctx, r->in.name->length, 0, "name length");
142
143         return true;
144 }
145
146 static const uint8_t enumvalue_out_data[] = {
147   0x12, 0x00, 0x00, 0x02, 0x28, 0x91, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00,
148   0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
149   0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
150   0x00, 0x00, 0x00, 0x00, 0xd8, 0x8c, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00,
151   0xe0, 0x00, 0x0c, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
152   0x4c, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x44, 0x00, 0x6f, 0x00, 0x63, 0x00,
153   0x75, 0x00, 0x6d, 0x00, 0x65, 0x00, 0x6e, 0x00, 0x74, 0x00, 0x73, 0x00,
154   0x20, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x64, 0x00, 0x20, 0x00, 0x53, 0x00,
155   0x65, 0x00, 0x74, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6e, 0x00, 0x67, 0x00,
156   0x73, 0x00, 0x5c, 0x00, 0x41, 0x00, 0x64, 0x00, 0x6d, 0x00, 0x69, 0x00,
157   0x6e, 0x00, 0x69, 0x00, 0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x61, 0x00,
158   0x74, 0x00, 0x6f, 0x00, 0x72, 0x00, 0x00, 0x00, 0xf0, 0x8c, 0x07, 0x00,
159   0x4c, 0x00, 0x00, 0x00, 0xf8, 0x8c, 0x07, 0x00, 0x4c, 0x00, 0x00, 0x00,
160   0x00, 0x00, 0x00, 0x00
161 };
162
163 static bool enumvalue_out_check(struct torture_context *tctx, 
164                                                                   struct winreg_EnumValue *r)
165 {
166         torture_assert_int_equal(tctx, r->out.name->size, 512, "name size");
167         torture_assert_int_equal(tctx, r->out.name->length, 18, "name length");
168         torture_assert_str_equal(tctx, r->out.name->name, "HOMEPATH", "name");
169         torture_assert_int_equal(tctx, *r->out.type, 1, "type");
170         torture_assert_int_equal(tctx, *r->out.size, 76, "size");
171         torture_assert_int_equal(tctx, *r->out.length, 76, "length");
172         torture_assert_werr_ok(tctx, r->out.result, "return code");
173
174         return true;
175 }
176
177 static const uint8_t queryvalue_in_data[] = {
178   0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
179   0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x12, 0x00, 0x12, 0x00,
180   0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181   0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00,
182   0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00,
183   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
184   0x03, 0x00, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
185   0x00, 0x00, 0x00, 0x00
186 };
187
188 static bool queryvalue_in_check(struct torture_context *tctx, 
189                                                                   struct winreg_QueryValue *r)
190 {
191         torture_assert_str_equal(tctx, r->in.value_name.name, "HOMEPATH", "name");
192         torture_assert_int_equal(tctx, *r->in.type, 0, "type");
193         torture_assert_int_equal(tctx, *r->in.size, 4095, "size");
194         torture_assert_int_equal(tctx, *r->in.length, 0, "length");
195         torture_assert(tctx, r->in.data == NULL, "data pointer");
196
197         return true;
198 }
199
200 static const uint8_t queryvalue_out_data[] = {
201   0xd8, 0xf5, 0x0b, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202   0xe4, 0xf5, 0x0b, 0x00, 0x4c, 0x00, 0x00, 0x00, 0xec, 0xf5, 0x0b, 0x00,
203   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
204 };
205
206 static bool queryvalue_out_check(struct torture_context *tctx, 
207                                                                   struct winreg_QueryValue *r)
208 {
209         torture_assert_werr_ok(tctx, r->out.result, "return code");
210         torture_assert_int_equal(tctx, *r->out.type, 1, "type");
211         torture_assert(tctx, r->out.data == NULL, "data pointer");
212         torture_assert_int_equal(tctx, *r->out.size, 76, "size");
213         torture_assert_int_equal(tctx, *r->out.length, 0, "length");
214
215         return true;
216 }
217
218 static const uint8_t querymultiplevalues_in_data[] = {
219   0x00, 0x00, 0x00, 0x00, 0xae, 0x1a, 0xbd, 0xbe, 0xbb, 0x94, 0xce, 0x4e,
220   0xba, 0xcf, 0x56, 0xeb, 0xe5, 0xb3, 0x6c, 0xa3, 0x01, 0x00, 0x00, 0x00,
221   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
222   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
223   0x12, 0x00, 0x12, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
224   0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4f, 0x00,
225   0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00, 0x54, 0x00, 0x48, 0x00,
226   0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
227   0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
228   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
229   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
230   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00
231 };
232
233 static bool querymultiplevalues_in_check(struct torture_context *tctx, 
234                                                                                  struct winreg_QueryMultipleValues *r)
235 {
236         torture_assert_int_equal(tctx, r->in.num_values, 1, "num values");
237         torture_assert_str_equal(tctx, r->in.values[0].name->name, "HOMEPATH", 
238                                                          "name");
239
240         torture_assert_int_equal(tctx, r->in.values[0].type, 0, "type");
241         torture_assert_int_equal(tctx, r->in.values[0].offset, 0, "offset");
242         torture_assert_int_equal(tctx, r->in.values[0].length, 0, "length");
243         torture_assert_int_equal(tctx, *r->in.buffer_size, 76, "buffer size");
244
245         return true;
246 }
247
248 static const uint8_t querymultiplevalues_out_data[] = {
249   0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
250   0xd8, 0x8c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
251   0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x12, 0x00, 0x38, 0x87, 0x07, 0x00,
252   0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
253   0x48, 0x00, 0x4f, 0x00, 0x4d, 0x00, 0x45, 0x00, 0x50, 0x00, 0x41, 0x00,
254   0x54, 0x00, 0x48, 0x00, 0xc8, 0x95, 0x08, 0x00, 0x4c, 0x00, 0x00, 0x00,
255   0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
256   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
257   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
258   0x00, 0x00, 0x00, 0x00, 0x4c, 0x4d, 0x45, 0x4d, 0xc8, 0x95, 0x08, 0x00,
259   0x50, 0x87, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x07, 0x00,
260   0x00, 0x01, 0x0c, 0x00, 0x50, 0x95, 0x08, 0x00, 0x48, 0x96, 0x08, 0x00,
261   0xdc, 0x00, 0x00, 0x00, 0xc0, 0x83, 0x00, 0x01, 0x0d, 0xf0, 0xff, 0xff,
262   0x4c, 0x00, 0x00, 0x00, 0xea, 0x00, 0x00, 0x00
263 };
264
265 static bool querymultiplevalues_out_check(struct torture_context *tctx, 
266                                                                                  struct winreg_QueryMultipleValues *r)
267 {
268         torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH", 
269                                                          "name");
270
271         torture_assert_int_equal(tctx, r->out.values[0].type, 0, "type");
272         torture_assert_int_equal(tctx, r->out.values[0].offset, 0, "offset");
273         torture_assert_int_equal(tctx, r->out.values[0].length, 0, "length");
274         /* FIXME: r->out.buffer */
275         torture_assert_int_equal(tctx, *r->out.buffer_size, 76, "buffer size");
276         torture_assert_werr_equal(tctx, r->out.result, WERR_MORE_DATA, 
277                                                                   "return code");
278
279         return true;
280 }
281
282 static const uint8_t flushkey_in_data[] = {
283   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
284   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
285 };
286
287 static bool flushkey_in_check(struct torture_context *tctx, 
288                                                            struct winreg_FlushKey *r)
289 {
290         torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle type");
291         return true;
292 }
293
294 static const uint8_t flushkey_out_data[] = {
295   0x00, 0x00, 0x00, 0x00
296 };
297
298 static bool flushkey_out_check(struct torture_context *tctx, 
299                                                            struct winreg_FlushKey *r)
300 {
301         torture_assert_werr_ok(tctx, r->out.result, "return code");
302         return true;
303 }
304
305
306 static const uint8_t openkey_in_data[] = {
307   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
308   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
309   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
310   0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
311   0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
312   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
313 };
314
315 static bool openkey_in_check(struct torture_context *tctx, struct winreg_OpenKey *r)
316 {
317         torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
318         torture_assert_int_equal(tctx, r->in.access_mask, 0x02000000, "access mask");
319         torture_assert_str_equal(tctx, r->in.keyname.name, "spottyfoot", "keyname");
320         /* FIXME: parent handle */
321         return true;
322 }
323
324 static const uint8_t openkey_out_data[] = {
325   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
326   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00
327 };
328
329 static bool openkey_out_check(struct torture_context *tctx, struct winreg_OpenKey *r)
330 {
331         torture_assert(tctx, GUID_all_zero(&r->out.handle->uuid), "handle");
332         torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
333         return true;
334 }
335
336 static const uint8_t deletekey_in_data[] = {
337   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
338   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x16, 0x00, 0x16, 0x00,
339   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
340   0x0b, 0x00, 0x00, 0x00, 0x73, 0x00, 0x70, 0x00, 0x6f, 0x00, 0x74, 0x00,
341   0x74, 0x00, 0x79, 0x00, 0x66, 0x00, 0x6f, 0x00, 0x6f, 0x00, 0x74, 0x00,
342   0x00, 0x00
343 };
344
345 static bool deletekey_in_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
346 {
347         /* FIXME: Handle */
348         torture_assert_str_equal(tctx, r->in.key.name, "spottyfoot", "key name");
349         return true;
350 }
351
352 static const uint8_t deletekey_out_data[] = {
353   0x02, 0x00, 0x00, 0x00
354 };
355
356 static bool deletekey_out_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
357 {
358         torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
359         return true;
360 }
361
362 static const uint8_t getversion_in_data[] = {
363   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
364   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3
365 };
366
367 static bool getversion_in_check(struct torture_context *tctx, struct winreg_GetVersion *r)
368 {
369         /* FIXME: Handle */
370         return true;
371 }
372
373 static const uint8_t getversion_out_data[] = {
374   0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
375 };
376
377 static bool getversion_out_check(struct torture_context *tctx, struct winreg_GetVersion *r)
378 {
379         torture_assert_int_equal(tctx, *r->out.version, 5, "version");
380         torture_assert_werr_ok(tctx, r->out.result, "return code");
381         return true;
382 }
383
384 static const uint8_t queryinfokey_in_data[] = {
385   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
386   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x00, 0x00, 0x00, 0x00,
387   0x00, 0x00, 0x00, 0x00
388 };
389
390 static bool queryinfokey_in_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
391 {
392         /* FIXME: Handle */
393         torture_assert(tctx, r->in.class_in->name == NULL, "class in");
394         return true;
395 }
396
397 static const uint8_t queryinfokey_out_data[] = {
398   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
399   0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
400   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
401   0x10, 0x48, 0x02, 0x3a, 0xcf, 0xfd, 0xc4, 0x01, 0x00, 0x00, 0x00, 0x00
402 };
403
404 static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
405 {
406         torture_assert(tctx, r->out.class_in != NULL, "class out");
407         torture_assert(tctx, r->out.class_in->name != NULL, "class out name");
408         torture_assert_str_equal(tctx, r->out.class_in->name, "", "class out name");
409         torture_assert_int_equal(tctx, *r->out.num_subkeys, 0, "num subkeys");
410         torture_assert_int_equal(tctx, *r->out.max_subkeylen, 0, "subkey length");
411         torture_assert_int_equal(tctx, *r->out.max_subkeysize, 140, "subkey size");
412         torture_assert_werr_ok(tctx, r->out.result, "return code");
413         return true;
414 }
415
416 static const uint8_t notifychangekeyvalue_in_data[] = {
417   0x00, 0x00, 0x00, 0x00, 0xb2, 0x64, 0xbc, 0xb3, 0x7f, 0x90, 0x29, 0x4a,
418   0xb4, 0xb3, 0x91, 0xe7, 0xe4, 0x4a, 0x58, 0xe3, 0x01, 0x00, 0x00, 0x00,
419   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
420   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
421   0x00, 0x00, 0x00, 0x00
422 };
423
424 static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
425 {
426         torture_assert_int_equal(tctx, r->in.watch_subtree, 1, "watch subtree");
427         torture_assert_int_equal(tctx, r->in.notify_filter, 0, "notify filter");
428         torture_assert_int_equal(tctx, r->in.unknown, 0, "unknown");
429         torture_assert(tctx, r->in.string1.name == NULL, "string1");
430         torture_assert(tctx, r->in.string2.name == NULL, "string2");
431         torture_assert_int_equal(tctx, r->in.unknown2, 0, "unknown2");
432         return true;
433 }
434
435 static const uint8_t notifychangekeyvalue_out_data[] = {
436   0x57, 0x00, 0x00, 0x00
437 };
438
439 static bool notifychangekeyvalue_out_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
440 {
441         torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "notify change key value");
442         return true;
443 }
444
445 static const uint8_t getkeysecurity_in_data[] = {
446   0x00, 0x00, 0x00, 0x00, 0xbd, 0xaa, 0xf6, 0x59, 0xc1, 0x82, 0x1f, 0x4d,
447   0x84, 0xa9, 0xdd, 0xae, 0x60, 0x77, 0x1e, 0x45, 0x00, 0x00, 0x00, 0x02,
448   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
449 };
450
451 static bool getkeysecurity_in_check(struct torture_context *tctx, struct winreg_GetKeySecurity *r)
452 {
453         /* FIXME: Handle */
454         torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
455         torture_assert_int_equal(tctx, r->in.sd->size, 65536, "sd size");
456         torture_assert_int_equal(tctx, r->in.sd->len, 0, "sd len");
457         torture_assert(tctx, r->in.sd->data == NULL, "sd data");
458         return true;
459 }
460
461 static const uint8_t getkeysecurity_out_data[] = {
462   0x08, 0x91, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
463   0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
464   0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
465   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
466 };
467
468 static bool getkeysecurity_out_check(struct torture_context *tctx, struct winreg_GetKeySecurity *r)
469 {
470         torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
471         torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
472         torture_assert_werr_ok(tctx, r->out.result, "return code");
473         return true;
474 }
475
476 struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
477 {
478         struct torture_suite *suite = torture_suite_create(ctx, "winreg");
479
480         torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
481         torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_IN, closekey_out_check );
482
483         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
484         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
485
486         torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
487         torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
488
489         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
490         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
491
492         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
493         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
494
495         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
496         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_out_data, NDR_OUT, querymultiplevalues_out_check );*/
497
498         torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_in_data, NDR_IN, flushkey_in_check );
499         torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_out_data, NDR_OUT, flushkey_out_check );
500
501         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_in_data, NDR_IN, openkey_in_check );
502         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_out_data, NDR_OUT, openkey_out_check );
503
504         torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_in_data, NDR_IN, deletekey_in_check );
505         torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_out_data, NDR_OUT, deletekey_out_check );
506
507         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_in_data, NDR_IN, getversion_in_check );
508         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_out_data, NDR_OUT, getversion_out_check );
509
510         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_in_data, NDR_IN, queryinfokey_in_check );
511         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_out_data, NDR_OUT, queryinfokey_out_check );*/
512
513         torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_in_data, NDR_IN, notifychangekeyvalue_in_check );
514         torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_out_data, NDR_OUT, notifychangekeyvalue_out_check );
515
516         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_in_data, NDR_IN, getkeysecurity_in_check );
517         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_out_data, NDR_OUT, getkeysecurity_out_check );*/
518
519         return suite;
520 }
521