r23792: convert Samba4 to GPLv3
[samba.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 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/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"
26
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
30 };
31
32 static bool closekey_in_check(struct torture_context *tctx, 
33                                                                   struct winreg_CloseKey *ck)
34 {
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;
38 }
39
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
43 };
44
45 static bool closekey_out_check(struct torture_context *tctx, 
46                                                            struct winreg_CloseKey *ck)
47 {
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;
51 }
52
53 static const uint8_t OpenHKLM_In[] = {
54   0x01, 0x00, 0x00, 0x00, 0xe0, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02
55 };
56
57 static bool openhklm_in_check(struct torture_context *tctx, 
58                                                                   struct winreg_OpenHKLM *r)
59 {
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;
64 }
65
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
69 };
70
71 static bool openhklm_out_check(struct torture_context *tctx, 
72                                                                   struct winreg_OpenHKLM *r)
73 {
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;
78 }
79
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
89 };
90
91 static bool createkey_in_check(struct torture_context *tctx, 
92                                                                   struct winreg_CreateKey *r)
93 {
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");
100
101         return true;
102 }
103
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
108 };
109
110 static bool createkey_out_check(struct torture_context *tctx, 
111                                                                   struct winreg_CreateKey *r)
112 {
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");
117
118         return true;
119 }
120
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
129 };
130
131 static bool enumvalue_in_check(struct torture_context *tctx, 
132                                                                   struct winreg_EnumValue *r)
133 {
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");
141
142         return true;
143 }
144
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
160 };
161
162 static bool enumvalue_out_check(struct torture_context *tctx, 
163                                                                   struct winreg_EnumValue *r)
164 {
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");
172
173         return true;
174 }
175
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
184 };
185
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
195 };
196
197 static bool queryvalue_in_check(struct torture_context *tctx, 
198                                                                   struct winreg_QueryValue *r)
199 {
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.size, 4095, "size");
203         torture_assert_int_equal(tctx, *r->in.length, 0, "length");
204         torture_assert(tctx, r->in.data == NULL, "data pointer");
205
206         return true;
207 }
208
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
213 };
214
215 static bool queryvalue_out_check(struct torture_context *tctx, 
216                                                                   struct winreg_QueryValue *r)
217 {
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.size, 76, "size");
222         torture_assert_int_equal(tctx, *r->out.length, 0, "length");
223
224         return true;
225 }
226
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
240 };
241
242 static bool querymultiplevalues_in_check(struct torture_context *tctx, 
243                                                                                  struct winreg_QueryMultipleValues *r)
244 {
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");
248
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");
253
254         return true;
255 }
256
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
272 };
273
274 static bool querymultiplevalues_out_check(struct torture_context *tctx, 
275                                                                                  struct winreg_QueryMultipleValues *r)
276 {
277         torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH", 
278                                                          "name");
279
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");
287
288         return true;
289 }
290
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
294 };
295
296 static bool flushkey_in_check(struct torture_context *tctx, 
297                                                            struct winreg_FlushKey *r)
298 {
299         torture_assert_int_equal(tctx, r->in.handle->handle_type, 0, "handle type");
300         return true;
301 }
302
303 static const uint8_t flushkey_out_data[] = {
304   0x00, 0x00, 0x00, 0x00
305 };
306
307 static bool flushkey_out_check(struct torture_context *tctx, 
308                                                            struct winreg_FlushKey *r)
309 {
310         torture_assert_werr_ok(tctx, r->out.result, "return code");
311         return true;
312 }
313
314
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
322 };
323
324 static bool openkey_in_check(struct torture_context *tctx, struct winreg_OpenKey *r)
325 {
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;
331 }
332
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
336 };
337
338 static bool openkey_out_check(struct torture_context *tctx, struct winreg_OpenKey *r)
339 {
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;
343 }
344
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
352 };
353
354 static bool deletekey_in_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
355 {
356         /* FIXME: Handle */
357         torture_assert_str_equal(tctx, r->in.key.name, "spottyfoot", "key name");
358         return true;
359 }
360
361 static const uint8_t deletekey_out_data[] = {
362   0x02, 0x00, 0x00, 0x00
363 };
364
365 static bool deletekey_out_check(struct torture_context *tctx, struct winreg_DeleteKey *r)
366 {
367         torture_assert_werr_equal(tctx, r->out.result, WERR_BADFILE, "return code");
368         return true;
369 }
370
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
374 };
375
376 static bool getversion_in_check(struct torture_context *tctx, struct winreg_GetVersion *r)
377 {
378         /* FIXME: Handle */
379         return true;
380 }
381
382 static const uint8_t getversion_out_data[] = {
383   0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
384 };
385
386 static bool getversion_out_check(struct torture_context *tctx, struct winreg_GetVersion *r)
387 {
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;
391 }
392
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
397 };
398
399 static bool queryinfokey_in_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
400 {
401         /* FIXME: Handle */
402         torture_assert(tctx, r->in.classname->name == NULL, "class in");
403         return true;
404 }
405
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
411 };
412
413 static bool queryinfokey_out_check(struct torture_context *tctx, struct winreg_QueryInfoKey *r)
414 {
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_subkeysize, 140, "subkey size");
421         torture_assert_werr_ok(tctx, r->out.result, "return code");
422         return true;
423 }
424
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
431 };
432
433 static bool notifychangekeyvalue_in_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
434 {
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;
442 }
443
444 static const uint8_t notifychangekeyvalue_out_data[] = {
445   0x57, 0x00, 0x00, 0x00
446 };
447
448 static bool notifychangekeyvalue_out_check(struct torture_context *tctx, struct winreg_NotifyChangeKeyValue *r)
449 {
450         torture_assert_werr_equal(tctx, r->out.result, WERR_INVALID_PARAM, "notify change key value");
451         return true;
452 }
453
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
458 };
459
460 static bool getkeysecurity_in_check(struct torture_context *tctx, struct winreg_GetKeySecurity *r)
461 {
462         /* FIXME: Handle */
463         torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info");
464         torture_assert_int_equal(tctx, r->in.sd->size, 65536, "sd size");
465         torture_assert_int_equal(tctx, r->in.sd->len, 0, "sd len");
466         torture_assert(tctx, r->in.sd->data == NULL, "sd data");
467         return true;
468 }
469
470 static const uint8_t getkeysecurity_out_data[] = {
471   0x08, 0x91, 0x08, 0x00, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
472   0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
473   0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
474   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
475 };
476
477 static bool getkeysecurity_out_check(struct torture_context *tctx, struct winreg_GetKeySecurity *r)
478 {
479         torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size");
480         torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len");
481         torture_assert_werr_ok(tctx, r->out.result, "return code");
482         return true;
483 }
484
485 static const uint8_t enumkey_in_data[] = {
486   0x00, 0x00, 0x00, 0x00, 0x85, 0xb8, 0x41, 0xb0, 0x17, 0xe4, 0x28, 0x45,
487   0x8a, 0x69, 0xbf, 0x40, 0x79, 0x82, 0x8b, 0xcb, 0x00, 0x00, 0x00, 0x00,
488   0x00, 0x00, 0x14, 0x04, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x02, 0x00, 0x00,
489   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
490   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
491   0xff, 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f
492 };
493
494 static bool enumkey_in_check(struct torture_context *tctx, struct winreg_EnumKey *r)
495 {
496         torture_assert_int_equal(tctx, r->in.enum_index, 0, "enum index");
497         torture_assert_int_equal(tctx, r->in.name->size, 1044, "name size");
498         torture_assert_int_equal(tctx, r->in.name->length, 0, "name len");
499         torture_assert(tctx, r->in.keyclass != NULL, "keyclass pointer");
500         torture_assert(tctx, r->in.keyclass->name == NULL, "keyclass");
501         torture_assert(tctx, r->in.last_changed_time != NULL, "last_changed_time != NULL");
502         return true;
503 }
504
505 static const uint8_t enumkey_out_data[] = {
506   0x08, 0x00, 0x14, 0x04, 0x18, 0xe8, 0x07, 0x00, 0x0a, 0x02, 0x00, 0x00,
507   0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x53, 0x00, 0x41, 0x00,
508   0x4d, 0x00, 0x00, 0x00, 0xd0, 0x62, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
509   0x00, 0x00, 0x00, 0x00, 0xdc, 0x62, 0x07, 0x00, 0x50, 0x67, 0xd0, 0x8b,
510   0x16, 0x06, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x00
511 };
512
513 static bool enumkey_out_check(struct torture_context *tctx, struct winreg_EnumKey *r)
514 {
515         torture_assert_int_equal(tctx, r->out.name->size, 1044, "name size");
516         torture_assert_int_equal(tctx, r->out.name->length, 8, "name len");
517         torture_assert(tctx, r->out.keyclass != NULL, "keyclass pointer");
518         torture_assert(tctx, r->out.keyclass->name == NULL, "keyclass");
519         torture_assert(tctx, r->out.last_changed_time != NULL, "last_changed_time pointer");
520         /* FIXME: *last_changed_time */
521         return true;
522 }
523
524 struct torture_suite *ndr_winreg_suite(TALLOC_CTX *ctx)
525 {
526         struct torture_suite *suite = torture_suite_create(ctx, "winreg");
527
528         torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_in_data, NDR_IN, closekey_in_check );
529         torture_suite_add_ndr_pull_fn_test(suite, winreg_CloseKey, closekey_out_data, NDR_OUT, closekey_out_check );
530
531         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, OpenHKLM_In, NDR_IN, openhklm_in_check );
532         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenHKLM, openhklm_out_data, NDR_OUT, openhklm_out_check );
533
534         torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_in_data, NDR_IN, createkey_in_check );
535         torture_suite_add_ndr_pull_fn_test(suite, winreg_CreateKey, createkey_out_data, NDR_OUT, createkey_out_check );
536
537         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data, NDR_IN, enumvalue_in_check );
538         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_out_data, NDR_OUT, enumvalue_out_check );
539         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumValue, enumvalue_in_data2, NDR_IN, NULL);
540
541         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_in_data, NDR_IN, queryvalue_in_check );
542         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryValue, queryvalue_out_data, NDR_OUT, queryvalue_out_check );
543
544         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_in_data, NDR_IN, querymultiplevalues_in_check );
545         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryMultipleValues, querymultiplevalues_out_data, NDR_OUT, querymultiplevalues_out_check );*/
546
547         torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_in_data, NDR_IN, flushkey_in_check );
548         torture_suite_add_ndr_pull_fn_test(suite, winreg_FlushKey, flushkey_out_data, NDR_OUT, flushkey_out_check );
549
550         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_in_data, NDR_IN, openkey_in_check );
551         torture_suite_add_ndr_pull_fn_test(suite, winreg_OpenKey, openkey_out_data, NDR_OUT, openkey_out_check );
552
553         torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_in_data, NDR_IN, deletekey_in_check );
554         torture_suite_add_ndr_pull_fn_test(suite, winreg_DeleteKey, deletekey_out_data, NDR_OUT, deletekey_out_check );
555
556         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_in_data, NDR_IN, getversion_in_check );
557         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetVersion, getversion_out_data, NDR_OUT, getversion_out_check );
558
559         torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_in_data, NDR_IN, queryinfokey_in_check );
560         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_QueryInfoKey, queryinfokey_out_data, NDR_OUT, queryinfokey_out_check );*/
561
562         torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_in_data, NDR_IN, notifychangekeyvalue_in_check );
563         torture_suite_add_ndr_pull_fn_test(suite, winreg_NotifyChangeKeyValue, notifychangekeyvalue_out_data, NDR_OUT, notifychangekeyvalue_out_check );
564
565         /*torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_in_data, NDR_IN, getkeysecurity_in_check );
566         torture_suite_add_ndr_pull_fn_test(suite, winreg_GetKeySecurity, getkeysecurity_out_data, NDR_OUT, getkeysecurity_out_check );*/
567
568         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_in_data, NDR_IN, enumkey_in_check );
569         torture_suite_add_ndr_pull_fn_test(suite, winreg_EnumKey, enumkey_out_data, NDR_OUT, enumkey_out_check );
570
571         return suite;
572 }
573