Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 : test suite for epmapper rpc operations
4 :
5 : Copyright (C) Andrew Tridgell 2003
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 "librpc/gen_ndr/ndr_epmapper_c.h"
23 : #include "librpc/ndr/ndr_table.h"
24 : #include "librpc/rpc/dcerpc_proto.h"
25 : #include "torture/rpc/torture_rpc.h"
26 : #include "lib/util/util_net.h"
27 : #include "librpc/rpc/rpc_common.h"
28 :
29 : /*
30 : display any protocol tower
31 : */
32 618 : static void display_tower(struct torture_context *tctx, struct epm_tower *twr)
33 : {
34 : int i;
35 :
36 3672 : for (i = 0; i < twr->num_floors; i++) {
37 3054 : torture_comment(tctx,
38 : " %s",
39 3054 : epm_floor_string(tctx, &twr->floors[i]));
40 : }
41 618 : torture_comment(tctx, "\n");
42 618 : }
43 :
44 3 : static bool test_Insert(struct torture_context *tctx,
45 : struct dcerpc_binding_handle *h,
46 : struct ndr_syntax_id object,
47 : const char *annotation,
48 : const struct dcerpc_binding *b)
49 : {
50 : struct epm_Insert r;
51 : NTSTATUS status;
52 :
53 3 : r.in.num_ents = 1;
54 3 : r.in.entries = talloc_array(tctx, struct epm_entry_t, 1);
55 :
56 3 : if (torture_setting_bool(tctx, "samba4", false)) {
57 3 : torture_skip(tctx, "Skip Insert test against Samba4");
58 : }
59 :
60 : /* FIXME zero */
61 0 : ZERO_STRUCT(r.in.entries[0].object);
62 0 : r.in.entries[0].annotation = annotation;
63 :
64 0 : r.in.entries[0].tower = talloc(tctx, struct epm_twr_t);
65 :
66 0 : status = dcerpc_binding_build_tower(tctx,
67 : b,
68 0 : &r.in.entries[0].tower->tower);
69 :
70 0 : torture_assert_ntstatus_ok(tctx,
71 : status,
72 : "Unable to build tower from binding struct");
73 0 : r.in.replace = 0;
74 :
75 : /* shoot! */
76 0 : status = dcerpc_epm_Insert_r(h, tctx, &r);
77 :
78 0 : if (NT_STATUS_IS_ERR(status)) {
79 0 : torture_comment(tctx,
80 : "epm_Insert failed - %s\n",
81 : nt_errstr(status));
82 0 : return false;
83 : }
84 :
85 0 : if (r.out.result != EPMAPPER_STATUS_OK) {
86 0 : torture_comment(tctx,
87 : "epm_Insert failed - internal error: 0x%.4x\n",
88 : r.out.result);
89 0 : return false;
90 : }
91 :
92 0 : return true;
93 : }
94 :
95 0 : static bool test_Delete(struct torture_context *tctx,
96 : struct dcerpc_binding_handle *h,
97 : const char *annotation,
98 : const struct dcerpc_binding *b)
99 : {
100 : NTSTATUS status;
101 : struct epm_Delete r;
102 :
103 0 : r.in.num_ents = 1;
104 0 : r.in.entries = talloc_array(tctx, struct epm_entry_t, 1);
105 :
106 0 : ZERO_STRUCT(r.in.entries[0].object);
107 0 : r.in.entries[0].annotation = annotation;
108 :
109 0 : r.in.entries[0].tower = talloc(tctx, struct epm_twr_t);
110 :
111 0 : status = dcerpc_binding_build_tower(tctx,
112 : b,
113 0 : &r.in.entries[0].tower->tower);
114 :
115 0 : torture_assert_ntstatus_ok(tctx,
116 : status,
117 : "Unable to build tower from binding struct");
118 0 : r.in.num_ents = 1;
119 :
120 0 : status = dcerpc_epm_Delete_r(h, tctx, &r);
121 0 : if (NT_STATUS_IS_ERR(status)) {
122 0 : torture_comment(tctx,
123 : "epm_Delete failed - %s\n",
124 : nt_errstr(status));
125 0 : return false;
126 : }
127 :
128 0 : if (r.out.result != EPMAPPER_STATUS_OK) {
129 0 : torture_comment(tctx,
130 : "epm_Delete failed - internal error: 0x%.4x\n",
131 : r.out.result);
132 0 : return false;
133 : }
134 :
135 0 : return true;
136 : }
137 :
138 3 : static bool test_Map_tcpip(struct torture_context *tctx,
139 : struct dcerpc_binding_handle *h,
140 : struct ndr_syntax_id map_syntax)
141 : {
142 : struct epm_Map r;
143 : struct GUID uuid;
144 : struct policy_handle entry_handle;
145 : struct ndr_syntax_id syntax;
146 : struct dcerpc_binding *map_binding;
147 : struct epm_twr_t map_tower;
148 : struct epm_twr_p_t towers[20];
149 : struct epm_tower t;
150 : uint32_t num_towers;
151 : uint32_t port;
152 : uint32_t i;
153 : long int p;
154 : const char *tmp;
155 : const char *ip;
156 : char *ptr;
157 : NTSTATUS status;
158 :
159 3 : torture_comment(tctx, "Testing epm_Map\n");
160 :
161 3 : ZERO_STRUCT(uuid);
162 3 : ZERO_STRUCT(entry_handle);
163 :
164 3 : r.in.object = &uuid;
165 3 : r.in.map_tower = &map_tower;
166 3 : r.in.entry_handle = &entry_handle;
167 3 : r.out.entry_handle = &entry_handle;
168 3 : r.in.max_towers = 10;
169 3 : r.out.towers = towers;
170 3 : r.out.num_towers = &num_towers;
171 :
172 : /* Create map tower */
173 3 : status = dcerpc_parse_binding(tctx, "ncacn_ip_tcp:[135]", &map_binding);
174 3 : torture_assert_ntstatus_ok(tctx, status,
175 : "epm_Map_tcpip failed: can't create map_binding");
176 :
177 3 : status = dcerpc_binding_set_abstract_syntax(map_binding, &map_syntax);
178 3 : torture_assert_ntstatus_ok(tctx, status,
179 : "epm_Map_tcpip failed: set map_syntax");
180 :
181 3 : status = dcerpc_binding_build_tower(tctx, map_binding,
182 : &map_tower.tower);
183 3 : torture_assert_ntstatus_ok(tctx, status,
184 : "epm_Map_tcpip failed: can't create map_tower");
185 :
186 3 : torture_comment(tctx,
187 : "epm_Map request for '%s':\n",
188 : ndr_interface_name(&map_syntax.uuid, map_syntax.if_version));
189 3 : display_tower(tctx, &r.in.map_tower->tower);
190 :
191 3 : status = dcerpc_epm_Map_r(h, tctx, &r);
192 :
193 3 : torture_assert_ntstatus_ok(tctx, status, "epm_Map_simple failed");
194 3 : torture_assert(tctx, r.out.result == EPMAPPER_STATUS_OK,
195 : "epm_Map_tcpip failed: result is not EPMAPPER_STATUS_OK");
196 :
197 : /* Check the result */
198 0 : t = r.out.towers[0].twr->tower;
199 :
200 : /* Check if we got the correct RPC interface identifier */
201 0 : dcerpc_floor_get_lhs_data(&t.floors[0], &syntax);
202 0 : torture_assert(tctx, ndr_syntax_id_equal(&syntax, &map_syntax),
203 : "epm_Map_tcpip failed: Interface identifier mismatch");
204 :
205 0 : torture_comment(tctx,
206 : "epm_Map_tcpip response for '%s':\n",
207 : ndr_interface_name(&syntax.uuid, syntax.if_version));
208 :
209 0 : dcerpc_floor_get_lhs_data(&t.floors[1], &syntax);
210 0 : torture_assert(tctx, ndr_syntax_id_equal(&syntax, &ndr_transfer_syntax_ndr),
211 : "epm_Map_tcpip failed: floor 2 is not NDR encoded");
212 :
213 0 : torture_assert(tctx, t.floors[2].lhs.protocol == EPM_PROTOCOL_NCACN,
214 : "epm_Map_tcpip failed: floor 3 is not NCACN_IP_TCP");
215 :
216 0 : tmp = dcerpc_floor_get_rhs_data(tctx, &t.floors[3]);
217 0 : p = strtol(tmp, &ptr, 10);
218 0 : port = p & 0xffff;
219 0 : torture_assert(tctx, port > 1024 && port < 65535, "epm_Map_tcpip failed");
220 :
221 0 : ip = dcerpc_floor_get_rhs_data(tctx, &t.floors[4]);
222 0 : torture_assert(tctx, is_ipaddress(ip), "epm_Map_tcpip failed");
223 :
224 0 : for (i = 0; i < *r.out.num_towers; i++) {
225 0 : if (r.out.towers[i].twr) {
226 0 : display_tower(tctx, &t);
227 : }
228 : }
229 :
230 0 : return true;
231 : }
232 :
233 3 : static bool test_Map_full(struct torture_context *tctx,
234 : struct dcerpc_pipe *p)
235 : {
236 3 : const struct ndr_syntax_id obj = {
237 : { 0x8a885d04, 0x1ceb, 0x11c9, {0x9f, 0xe8}, {0x08,0x00,0x2b,0x10,0x48,0x60} },
238 : 2
239 : };
240 3 : struct dcerpc_binding_handle *h = p->binding_handle;
241 3 : const char *annotation = "SMBTORTURE";
242 : struct dcerpc_binding *b;
243 : NTSTATUS status;
244 : bool ok;
245 :
246 3 : status = dcerpc_parse_binding(tctx, "ncacn_ip_tcp:216.83.154.106[41768]", &b);
247 3 : torture_assert_ntstatus_ok(tctx,
248 : status,
249 : "Unable to generate dcerpc_binding struct");
250 3 : status = dcerpc_binding_set_abstract_syntax(b, &obj);
251 3 : torture_assert_ntstatus_ok(tctx, status, "dcerpc_binding_set_abstract_syntax");
252 :
253 3 : ok = test_Insert(tctx, h, obj, annotation, b);
254 3 : torture_assert(tctx, ok, "test_Insert failed");
255 :
256 3 : ok = test_Map_tcpip(tctx, h, obj);
257 3 : torture_assert(tctx, ok, "test_Map_tcpip failed");
258 :
259 0 : ok = test_Delete(tctx, h, annotation, b);
260 0 : torture_assert(tctx, ok, "test_Delete failed");
261 :
262 0 : return true;
263 : }
264 :
265 132 : static bool test_Map_display(struct dcerpc_binding_handle *b,
266 : struct torture_context *tctx,
267 : struct epm_entry_t *entry)
268 :
269 : {
270 : NTSTATUS status;
271 132 : struct epm_twr_t *twr = entry->tower;
272 : struct epm_Map r;
273 132 : struct GUID uuid = entry->object;
274 : struct policy_handle handle;
275 : struct ndr_syntax_id syntax;
276 : uint32_t num_towers;
277 : uint32_t i;
278 :
279 132 : ZERO_STRUCT(handle);
280 :
281 132 : r.in.object = &uuid;
282 132 : r.in.map_tower = twr;
283 132 : r.in.entry_handle = &handle;
284 132 : r.out.entry_handle = &handle;
285 132 : r.in.max_towers = 10;
286 132 : r.out.num_towers = &num_towers;
287 :
288 132 : dcerpc_floor_get_lhs_data(&twr->tower.floors[0], &syntax);
289 :
290 132 : torture_comment(tctx,
291 : "epm_Map results for '%s':\n",
292 : ndr_interface_name(&syntax.uuid, syntax.if_version));
293 :
294 132 : status = dcerpc_epm_Map_r(b, tctx, &r);
295 132 : if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
296 264 : for (i=0;i<*r.out.num_towers;i++) {
297 132 : if (r.out.towers[i].twr) {
298 132 : display_tower(tctx, &r.out.towers[i].twr->tower);
299 : }
300 : }
301 : }
302 :
303 : /* RPC protocol identifier */
304 132 : twr->tower.floors[2].lhs.protocol = EPM_PROTOCOL_NCACN;
305 132 : twr->tower.floors[2].lhs.lhs_data = data_blob(NULL, 0);
306 132 : twr->tower.floors[2].rhs.ncacn.minor_version = 0;
307 :
308 : /* Port address */
309 132 : twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_TCP;
310 132 : twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
311 132 : twr->tower.floors[3].rhs.tcp.port = 0;
312 :
313 : /* Transport */
314 132 : twr->tower.floors[4].lhs.protocol = EPM_PROTOCOL_IP;
315 132 : twr->tower.floors[4].lhs.lhs_data = data_blob(NULL, 0);
316 132 : twr->tower.floors[4].rhs.ip.ipaddr = "0.0.0.0";
317 :
318 132 : status = dcerpc_epm_Map_r(b, tctx, &r);
319 132 : if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
320 264 : for (i=0;i<*r.out.num_towers;i++) {
321 132 : if (r.out.towers[i].twr) {
322 132 : display_tower(tctx, &r.out.towers[i].twr->tower);
323 : }
324 : }
325 : }
326 :
327 132 : twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_HTTP;
328 132 : twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
329 132 : twr->tower.floors[3].rhs.http.port = 0;
330 :
331 132 : status = dcerpc_epm_Map_r(b, tctx, &r);
332 132 : if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
333 108 : for (i=0;i<*r.out.num_towers;i++) {
334 54 : if (r.out.towers[i].twr) {
335 54 : display_tower(tctx, &r.out.towers[i].twr->tower);
336 : }
337 : }
338 : }
339 :
340 132 : twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_UDP;
341 132 : twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
342 132 : twr->tower.floors[3].rhs.udp.port = 0;
343 :
344 132 : status = dcerpc_epm_Map_r(b, tctx, &r);
345 132 : if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
346 0 : for (i=0;i<*r.out.num_towers;i++) {
347 0 : if (r.out.towers[i].twr) {
348 0 : display_tower(tctx, &r.out.towers[i].twr->tower);
349 : }
350 : }
351 : }
352 :
353 132 : twr->tower.floors[3].lhs.protocol = EPM_PROTOCOL_SMB;
354 132 : twr->tower.floors[3].lhs.lhs_data = data_blob(NULL, 0);
355 132 : twr->tower.floors[3].rhs.smb.unc = "";
356 :
357 132 : twr->tower.floors[4].lhs.protocol = EPM_PROTOCOL_NETBIOS;
358 132 : twr->tower.floors[4].lhs.lhs_data = data_blob(NULL, 0);
359 132 : twr->tower.floors[4].rhs.netbios.name = "";
360 :
361 132 : status = dcerpc_epm_Map_r(b, tctx, &r);
362 132 : if (NT_STATUS_IS_OK(status) && r.out.result == 0) {
363 258 : for (i = 0; i < *r.out.num_towers; i++) {
364 129 : if (r.out.towers[i].twr) {
365 129 : display_tower(tctx, &r.out.towers[i].twr->tower);
366 : }
367 : }
368 : }
369 :
370 : /* FIXME: Extend to do other protocols as well (ncacn_unix_stream, ncalrpc) */
371 :
372 132 : return true;
373 : }
374 :
375 3 : static bool test_Map_simple(struct torture_context *tctx,
376 : struct dcerpc_pipe *p)
377 : {
378 : NTSTATUS status;
379 : struct epm_Lookup r;
380 : struct policy_handle entry_handle;
381 3 : uint32_t num_ents = 0;
382 3 : struct dcerpc_binding_handle *h = p->binding_handle;
383 :
384 3 : ZERO_STRUCT(entry_handle);
385 :
386 3 : torture_comment(tctx, "Testing epm_Map\n");
387 :
388 : /* get all elements */
389 3 : r.in.inquiry_type = RPC_C_EP_ALL_ELTS;
390 3 : r.in.object = NULL;
391 3 : r.in.interface_id = NULL;
392 3 : r.in.vers_option = RPC_C_VERS_ALL;
393 :
394 3 : r.in.entry_handle = &entry_handle;
395 3 : r.in.max_ents = 10;
396 :
397 3 : r.out.entry_handle = &entry_handle;
398 3 : r.out.num_ents = &num_ents;
399 :
400 : do {
401 : int i;
402 :
403 18 : status = dcerpc_epm_Lookup_r(h, tctx, &r);
404 36 : if (!NT_STATUS_IS_OK(status) ||
405 18 : r.out.result != EPMAPPER_STATUS_OK) {
406 : break;
407 : }
408 :
409 186 : for (i = 0; i < *r.out.num_ents; i++) {
410 168 : if (r.out.entries[i].tower->tower.num_floors == 5) {
411 132 : test_Map_display(h, tctx, &r.out.entries[i]);
412 : }
413 : }
414 36 : } while (NT_STATUS_IS_OK(status) &&
415 36 : r.out.result == EPMAPPER_STATUS_OK &&
416 33 : *r.out.num_ents == r.in.max_ents &&
417 33 : !ndr_policy_handle_empty(&entry_handle));
418 :
419 3 : torture_assert_ntstatus_ok(tctx, status, "epm_Map_simple failed");
420 :
421 3 : torture_assert(tctx,
422 : ndr_policy_handle_empty(&entry_handle),
423 : "epm_Map_simple failed - The policy handle should be empty.");
424 :
425 0 : return true;
426 : }
427 :
428 3 : static bool test_LookupHandleFree(struct torture_context *tctx,
429 : struct dcerpc_binding_handle *h,
430 : struct policy_handle *entry_handle) {
431 : NTSTATUS status;
432 : struct epm_LookupHandleFree r;
433 :
434 3 : if (ndr_policy_handle_empty(entry_handle)) {
435 0 : torture_comment(tctx,
436 : "epm_LookupHandleFree failed - empty policy_handle\n");
437 0 : return false;
438 : }
439 :
440 3 : r.in.entry_handle = entry_handle;
441 3 : r.out.entry_handle = entry_handle;
442 :
443 3 : status = dcerpc_epm_LookupHandleFree_r(h, tctx, &r);
444 3 : if (NT_STATUS_IS_ERR(status)) {
445 0 : torture_comment(tctx,
446 : "epm_LookupHandleFree failed - %s\n",
447 : nt_errstr(status));
448 0 : return false;
449 : }
450 :
451 3 : if (r.out.result != EPMAPPER_STATUS_OK) {
452 0 : torture_comment(tctx,
453 : "epm_LookupHandleFree failed - internal error: "
454 : "0x%.4x\n",
455 : r.out.result);
456 0 : return false;
457 : }
458 :
459 3 : return true;
460 : }
461 :
462 3 : static bool test_Lookup_simple(struct torture_context *tctx,
463 : struct dcerpc_pipe *p)
464 : {
465 : NTSTATUS status;
466 : struct epm_Lookup r;
467 : struct policy_handle entry_handle;
468 3 : uint32_t num_ents = 0;
469 3 : struct dcerpc_binding_handle *h = p->binding_handle;
470 :
471 3 : ZERO_STRUCT(entry_handle);
472 :
473 3 : torture_comment(tctx, "Testing epm_Lookup\n");
474 :
475 : /* get all elements */
476 3 : r.in.inquiry_type = RPC_C_EP_ALL_ELTS;
477 3 : r.in.object = NULL;
478 3 : r.in.interface_id = NULL;
479 3 : r.in.vers_option = RPC_C_VERS_ALL;
480 :
481 3 : r.in.entry_handle = &entry_handle;
482 3 : r.in.max_ents = 10;
483 :
484 3 : r.out.entry_handle = &entry_handle;
485 3 : r.out.num_ents = &num_ents;
486 :
487 : do {
488 : int i;
489 :
490 18 : status = dcerpc_epm_Lookup_r(h, tctx, &r);
491 36 : if (!NT_STATUS_IS_OK(status) ||
492 18 : r.out.result != EPMAPPER_STATUS_OK) {
493 : break;
494 : }
495 :
496 36 : torture_comment(tctx,
497 : "epm_Lookup returned %d events, entry_handle: %s\n",
498 18 : *r.out.num_ents,
499 : GUID_string(tctx, &entry_handle.uuid));
500 :
501 186 : for (i = 0; i < *r.out.num_ents; i++) {
502 336 : torture_comment(tctx,
503 : "\n Found '%s' Object[%s]\n",
504 168 : r.out.entries[i].annotation,
505 168 : GUID_string(tctx, &r.out.entries[i].object));
506 :
507 168 : display_tower(tctx, &r.out.entries[i].tower->tower);
508 : }
509 36 : } while (NT_STATUS_IS_OK(status) &&
510 36 : r.out.result == EPMAPPER_STATUS_OK &&
511 33 : *r.out.num_ents == r.in.max_ents &&
512 33 : !ndr_policy_handle_empty(&entry_handle));
513 :
514 3 : torture_assert_ntstatus_ok(tctx, status, "epm_Lookup failed");
515 3 : torture_assert(tctx, r.out.result == EPMAPPER_STATUS_NO_MORE_ENTRIES, "epm_Lookup failed");
516 :
517 0 : torture_assert(tctx,
518 : ndr_policy_handle_empty(&entry_handle),
519 : "epm_Lookup failed - The policy handle should be empty.");
520 :
521 0 : return true;
522 : }
523 :
524 : /*
525 : * This test starts a epm_Lookup request, but doesn't finish the
526 : * call terminates the search. So it will call epm_LookupHandleFree.
527 : */
528 3 : static bool test_Lookup_terminate_search(struct torture_context *tctx,
529 : struct dcerpc_pipe *p)
530 : {
531 : bool ok;
532 : NTSTATUS status;
533 : struct epm_Lookup r;
534 : struct policy_handle entry_handle;
535 3 : uint32_t i, num_ents = 0;
536 3 : struct dcerpc_binding_handle *h = p->binding_handle;
537 :
538 3 : ZERO_STRUCT(entry_handle);
539 :
540 3 : torture_comment(tctx, "Testing epm_Lookup and epm_LookupHandleFree\n");
541 :
542 : /* get all elements */
543 3 : r.in.inquiry_type = RPC_C_EP_ALL_ELTS;
544 3 : r.in.object = NULL;
545 3 : r.in.interface_id = NULL;
546 3 : r.in.vers_option = RPC_C_VERS_ALL;
547 :
548 3 : r.in.entry_handle = &entry_handle;
549 3 : r.in.max_ents = 2;
550 :
551 3 : r.out.entry_handle = &entry_handle;
552 3 : r.out.num_ents = &num_ents;
553 :
554 3 : status = dcerpc_epm_Lookup_r(h, tctx, &r);
555 :
556 3 : torture_assert_ntstatus_ok(tctx, status, "epm_Lookup failed");
557 3 : torture_assert(tctx, r.out.result == EPMAPPER_STATUS_OK, "epm_Lookup failed");
558 :
559 6 : torture_comment(tctx,
560 : "epm_Lookup returned %d events, entry_handle: %s\n",
561 3 : *r.out.num_ents,
562 : GUID_string(tctx, &entry_handle.uuid));
563 :
564 9 : for (i = 0; i < *r.out.num_ents; i++) {
565 6 : torture_comment(tctx,
566 : "\n Found '%s'\n",
567 6 : r.out.entries[i].annotation);
568 : }
569 :
570 3 : ok = test_LookupHandleFree(tctx,
571 : h,
572 : &entry_handle);
573 3 : if (!ok) {
574 0 : return false;
575 : }
576 :
577 3 : return true;
578 : }
579 :
580 3 : static bool test_Insert_noreplace(struct torture_context *tctx,
581 : struct dcerpc_pipe *p)
582 : {
583 : bool ok;
584 : NTSTATUS status;
585 : struct epm_Insert r;
586 : struct dcerpc_binding *b;
587 3 : struct dcerpc_binding_handle *h = p->binding_handle;
588 :
589 3 : torture_comment(tctx, "Testing epm_Insert(noreplace) and epm_Delete\n");
590 :
591 3 : if (torture_setting_bool(tctx, "samba4", false)) {
592 3 : torture_skip(tctx, "Skip Insert test against Samba4");
593 : }
594 :
595 0 : r.in.num_ents = 1;
596 0 : r.in.entries = talloc_array(tctx, struct epm_entry_t, 1);
597 :
598 0 : ZERO_STRUCT(r.in.entries[0].object);
599 0 : r.in.entries[0].annotation = "smbtorture endpoint";
600 :
601 0 : status = dcerpc_parse_binding(tctx, "ncalrpc:[SMBTORTURE]", &b);
602 0 : torture_assert_ntstatus_ok(tctx,
603 : status,
604 : "Unable to generate dcerpc_binding struct");
605 :
606 0 : r.in.entries[0].tower = talloc(tctx, struct epm_twr_t);
607 :
608 0 : status = dcerpc_binding_build_tower(tctx,
609 : b,
610 0 : &r.in.entries[0].tower->tower);
611 0 : torture_assert_ntstatus_ok(tctx,
612 : status,
613 : "Unable to build tower from binding struct");
614 0 : r.in.replace = 0;
615 :
616 0 : status = dcerpc_epm_Insert_r(h, tctx, &r);
617 0 : torture_assert_ntstatus_ok(tctx, status, "epm_Insert failed");
618 :
619 0 : torture_assert(tctx, r.out.result == 0, "epm_Insert failed");
620 :
621 0 : ok = test_Delete(tctx, h, "smbtorture", b);
622 0 : if (!ok) {
623 0 : return false;
624 : }
625 :
626 0 : return true;
627 : }
628 :
629 : #if 0
630 : /*
631 : * The MS-RPCE documentation states that this function isn't implemented and
632 : * SHOULD NOT be called by a client.
633 : */
634 : static bool test_InqObject(struct torture_context *tctx, struct dcerpc_pipe *p)
635 : {
636 : NTSTATUS status;
637 : struct epm_InqObject r;
638 : struct dcerpc_binding_handle *b = p->binding_handle;
639 :
640 : r.in.epm_object = talloc(tctx, struct GUID);
641 : *r.in.epm_object = ndr_table_epmapper.syntax_id.uuid;
642 :
643 : status = dcerpc_epm_InqObject_r(b, tctx, &r);
644 : torture_assert_ntstatus_ok(tctx, status, "InqObject failed");
645 :
646 : return true;
647 : }
648 : #endif
649 :
650 964 : struct torture_suite *torture_rpc_epmapper(TALLOC_CTX *mem_ctx)
651 : {
652 964 : struct torture_suite *suite = torture_suite_create(mem_ctx, "epmapper");
653 : struct torture_rpc_tcase *tcase;
654 :
655 964 : tcase = torture_suite_add_rpc_iface_tcase(suite,
656 : "epmapper",
657 : &ndr_table_epmapper);
658 :
659 : /* This is a stack */
660 964 : torture_rpc_tcase_add_test(tcase,
661 : "Map_simple",
662 : test_Map_simple);
663 964 : torture_rpc_tcase_add_test(tcase,
664 : "Map_full",
665 : test_Map_full);
666 964 : torture_rpc_tcase_add_test(tcase,
667 : "Lookup_simple",
668 : test_Lookup_simple);
669 964 : torture_rpc_tcase_add_test(tcase,
670 : "Lookup_terminate_search",
671 : test_Lookup_terminate_search);
672 964 : torture_rpc_tcase_add_test(tcase,
673 : "Insert_noreplace",
674 : test_Insert_noreplace);
675 :
676 964 : return suite;
677 : }
678 :
679 : /* vim: set ts=8 sw=8 noet cindent syntax=c.doxygen: */
|