1 /*
2 Unix SMB/CIFS implementation.
3 SMB torture tester
4 Copyright (C) Andrew Bartlett 2012
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "torture/smbtorture.h"
22 #include "dns_server/dlz_minimal.h"
23 #include <talloc.h>
24 #include <ldb.h>
25 #include "lib/param/param.h"
26 #include "dsdb/samdb/samdb.h"
27 #include "dsdb/common/util.h"
28 #include "auth/session.h"
29 #include "auth/gensec/gensec.h"
30 #include "auth/credentials/credentials.h"
31 #include "lib/cmdline/popt_common.h"
32
33 /* Tests that configure multiple DLZs will use this. Increase to add stress. */
34 #define NUM_DLZS_TO_CONFIGURE 4
35
36 struct torture_context *tctx_static;
37
38 static void dlz_bind9_log_wrapper(int level, const char *fmt, ...)
39 PRINTF_ATTRIBUTE(2,3);
40
dlz_bind9_log_wrapper(int level,const char * fmt,...)41 static void dlz_bind9_log_wrapper(int level, const char *fmt, ...)
42 {
43 va_list ap;
44 char *msg;
45 va_start(ap, fmt);
46 msg = talloc_vasprintf(NULL, fmt, ap);
47 torture_comment(tctx_static, "%s\n", msg);
48 TALLOC_FREE(msg);
49 va_end(ap);
50 }
51
test_dlz_bind9_version(struct torture_context * tctx)52 static bool test_dlz_bind9_version(struct torture_context *tctx)
53 {
54 unsigned int flags = 0;
55 torture_assert_int_equal(tctx, dlz_version(&flags),
56 DLZ_DLOPEN_VERSION, "got wrong DLZ version");
57 return true;
58 }
59
test_dlz_bind9_binddns_dir(struct torture_context * tctx,const char * file)60 static char *test_dlz_bind9_binddns_dir(struct torture_context *tctx,
61 const char *file)
62 {
63 return talloc_asprintf(tctx,
64 "ldb://%s/%s",
65 lpcfg_binddns_dir(tctx->lp_ctx),
66 file);
67 }
68
test_dlz_bind9_create(struct torture_context * tctx)69 static bool test_dlz_bind9_create(struct torture_context *tctx)
70 {
71 void *dbdata;
72 const char *argv[] = {
73 "samba_dlz",
74 "-H",
75 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
76 NULL
77 };
78 tctx_static = tctx;
79 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
80 "log", dlz_bind9_log_wrapper, NULL), ISC_R_SUCCESS,
81 "Failed to create samba_dlz");
82
83 dlz_destroy(dbdata);
84
85 return true;
86 }
87
88 static bool calls_zone_hook = false;
89
dlz_bind9_writeable_zone_hook(dns_view_t * view,const char * zone_name)90 static isc_result_t dlz_bind9_writeable_zone_hook(dns_view_t *view,
91 const char *zone_name)
92 {
93 struct torture_context *tctx = talloc_get_type((void *)view, struct torture_context);
94 struct ldb_context *samdb = NULL;
95 char *errstring = NULL;
96 int ret = samdb_connect_url(
97 tctx,
98 NULL,
99 tctx->lp_ctx,
100 system_session(tctx->lp_ctx),
101 0,
102 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
103 NULL,
104 &samdb,
105 &errstring);
106 struct ldb_message *msg;
107 const char *attrs[] = {
108 NULL
109 };
110 if (ret != LDB_SUCCESS) {
111 torture_fail(tctx, "Failed to connect to samdb");
112 return ISC_R_FAILURE;
113 }
114
115 ret = dsdb_search_one(samdb, tctx, &msg, NULL,
116 LDB_SCOPE_SUBTREE, attrs, DSDB_SEARCH_SEARCH_ALL_PARTITIONS,
117 "(&(objectClass=dnsZone)(name=%s))", zone_name);
118 if (ret != LDB_SUCCESS) {
119 torture_fail(tctx, talloc_asprintf(tctx, "Failed to search for %s: %s", zone_name, ldb_errstring(samdb)));
120 return ISC_R_FAILURE;
121 }
122 talloc_free(msg);
123
124 calls_zone_hook = true;
125
126 return ISC_R_SUCCESS;
127 }
128
test_dlz_bind9_configure(struct torture_context * tctx)129 static bool test_dlz_bind9_configure(struct torture_context *tctx)
130 {
131 void *dbdata;
132 const char *argv[] = {
133 "samba_dlz",
134 "-H",
135 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
136 NULL
137 };
138 tctx_static = tctx;
139 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
140 "log", dlz_bind9_log_wrapper,
141 "writeable_zone", dlz_bind9_writeable_zone_hook, NULL),
142 ISC_R_SUCCESS,
143 "Failed to create samba_dlz");
144
145 calls_zone_hook = false;
146 torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
147 ISC_R_SUCCESS,
148 "Failed to configure samba_dlz");
149
150 dlz_destroy(dbdata);
151
152 torture_assert_int_equal(tctx, calls_zone_hook, 1, "Hasn't called zone hook");
153
154 return true;
155 }
156
test_dlz_bind9_multiple_configure(struct torture_context * tctx)157 static bool test_dlz_bind9_multiple_configure(struct torture_context *tctx)
158 {
159 int i;
160 for(i = 0; i < NUM_DLZS_TO_CONFIGURE; i++){
161 test_dlz_bind9_configure(tctx);
162 }
163 return true;
164 }
165
configure_multiple_dlzs(struct torture_context * tctx,void ** dbdata,int count)166 static bool configure_multiple_dlzs(struct torture_context *tctx,
167 void **dbdata, int count)
168 {
169 int i, res;
170 const char *argv[] = {
171 "samba_dlz",
172 "-H",
173 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
174 NULL
175 };
176
177 tctx_static = tctx;
178 for(i = 0; i < count; i++){
179 res = dlz_create("samba_dlz", 3, argv, &(dbdata[i]),
180 "log", dlz_bind9_log_wrapper,
181 "writeable_zone",
182 dlz_bind9_writeable_zone_hook, NULL);
183 torture_assert_int_equal(tctx, res, ISC_R_SUCCESS,
184 "Failed to create samba_dlz");
185
186 res = dlz_configure((void*)tctx, dbdata[i]);
187 torture_assert_int_equal(tctx, res, ISC_R_SUCCESS,
188 "Failed to configure samba_dlz");
189 }
190
191 return true;
192 }
193
test_dlz_bind9_destroy_oldest_first(struct torture_context * tctx)194 static bool test_dlz_bind9_destroy_oldest_first(struct torture_context *tctx)
195 {
196 void *dbdata[NUM_DLZS_TO_CONFIGURE];
197 int i;
198
199 configure_multiple_dlzs(tctx, dbdata, NUM_DLZS_TO_CONFIGURE);
200
201 /* Reload faults are reported to happen on the first destroy */
202 dlz_destroy(dbdata[0]);
203
204 for(i = 1; i < NUM_DLZS_TO_CONFIGURE; i++){
205 dlz_destroy(dbdata[i]);
206 }
207
208 return true;
209 }
210
test_dlz_bind9_destroy_newest_first(struct torture_context * tctx)211 static bool test_dlz_bind9_destroy_newest_first(struct torture_context *tctx)
212 {
213 void *dbdata[NUM_DLZS_TO_CONFIGURE];
214 int i;
215
216 configure_multiple_dlzs(tctx, dbdata, NUM_DLZS_TO_CONFIGURE);
217
218 for(i = NUM_DLZS_TO_CONFIGURE - 1; i >= 0; i--) {
219 dlz_destroy(dbdata[i]);
220 }
221
222 return true;
223 }
224
225 /*
226 * Test that a ticket obtained for the DNS service will be accepted on the Samba DLZ side
227 *
228 */
test_dlz_bind9_gensec(struct torture_context * tctx,const char * mech)229 static bool test_dlz_bind9_gensec(struct torture_context *tctx, const char *mech)
230 {
231 NTSTATUS status;
232
233 struct gensec_security *gensec_client_context;
234
235 DATA_BLOB client_to_server, server_to_client;
236
237 void *dbdata;
238 const char *argv[] = {
239 "samba_dlz",
240 "-H",
241 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
242 NULL
243 };
244 tctx_static = tctx;
245 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
246 "log", dlz_bind9_log_wrapper,
247 "writeable_zone", dlz_bind9_writeable_zone_hook, NULL),
248 ISC_R_SUCCESS,
249 "Failed to create samba_dlz");
250
251 torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
252 ISC_R_SUCCESS,
253 "Failed to configure samba_dlz");
254
255 status = gensec_client_start(tctx, &gensec_client_context,
256 lpcfg_gensec_settings(tctx, tctx->lp_ctx));
257 torture_assert_ntstatus_ok(tctx, status, "gensec_client_start (client) failed");
258
259 /*
260 * dlz_bind9 use the special dns/host.domain account
261 */
262 status = gensec_set_target_hostname(gensec_client_context,
263 talloc_asprintf(tctx,
264 "%s.%s",
265 torture_setting_string(tctx, "host", NULL),
266 lpcfg_dnsdomain(tctx->lp_ctx)));
267 torture_assert_ntstatus_ok(tctx, status, "gensec_set_target_hostname (client) failed");
268
269 status = gensec_set_target_service(gensec_client_context, "dns");
270 torture_assert_ntstatus_ok(tctx, status, "gensec_set_target_service failed");
271
272 status = gensec_set_credentials(gensec_client_context,
273 popt_get_cmdline_credentials());
274 torture_assert_ntstatus_ok(tctx, status, "gensec_set_credentials (client) failed");
275
276 status = gensec_start_mech_by_sasl_name(gensec_client_context, mech);
277 torture_assert_ntstatus_ok(tctx, status, "gensec_start_mech_by_sasl_name (client) failed");
278
279 server_to_client = data_blob(NULL, 0);
280
281 /* Do one step of the client-server update dance */
282 status = gensec_update(gensec_client_context, tctx, server_to_client, &client_to_server);
283 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {;
284 torture_assert_ntstatus_ok(tctx, status, "gensec_update (client) failed");
285 }
286
287 torture_assert_int_equal(tctx, dlz_ssumatch(
288 cli_credentials_get_username(
289 popt_get_cmdline_credentials()),
290 lpcfg_dnsdomain(tctx->lp_ctx),
291 "127.0.0.1", "type", "key",
292 client_to_server.length,
293 client_to_server.data,
294 dbdata),
295 ISC_TRUE,
296 "Failed to check key for update rights samba_dlz");
297
298 dlz_destroy(dbdata);
299
300 return true;
301 }
302
test_dlz_bind9_gssapi(struct torture_context * tctx)303 static bool test_dlz_bind9_gssapi(struct torture_context *tctx)
304 {
305 return test_dlz_bind9_gensec(tctx, "GSSAPI");
306 }
307
test_dlz_bind9_spnego(struct torture_context * tctx)308 static bool test_dlz_bind9_spnego(struct torture_context *tctx)
309 {
310 return test_dlz_bind9_gensec(tctx, "GSS-SPNEGO");
311 }
312
313 struct test_expected_record {
314 const char *name;
315 const char *type;
316 const char *data;
317 int ttl;
318 bool printed;
319 };
320
321 struct test_expected_rr {
322 struct torture_context *tctx;
323 const char *query_name;
324 size_t num_records;
325 struct test_expected_record *records;
326 size_t num_rr;
327 };
328
dlz_bind9_putnamedrr_torture_hook(struct test_expected_rr * expected,const char * name,const char * type,dns_ttl_t ttl,const char * data)329 static bool dlz_bind9_putnamedrr_torture_hook(struct test_expected_rr *expected,
330 const char *name,
331 const char *type,
332 dns_ttl_t ttl,
333 const char *data)
334 {
335 size_t i;
336
337 torture_assert(expected->tctx, name != NULL,
338 talloc_asprintf(expected->tctx,
339 "Got unnamed record type[%s] data[%s]\n",
340 type, data));
341
342 expected->num_rr++;
343 torture_comment(expected->tctx, "%u: name[%s] type[%s] ttl[%u] data[%s]\n",
344 (unsigned)expected->num_rr, name, type, (unsigned)ttl, data);
345
346 for (i = 0; i < expected->num_records; i++) {
347 if (expected->records[i].name != NULL) {
348 if (strcmp(name, expected->records[i].name) != 0) {
349 continue;
350 }
351 }
352
353 if (strcmp(type, expected->records[i].type) != 0) {
354 continue;
355 }
356
357 if (expected->records[i].data != NULL) {
358 if (strcmp(data, expected->records[i].data) != 0) {
359 continue;
360 }
361 }
362
363 torture_assert_int_equal(expected->tctx, ttl,
364 expected->records[i].ttl,
365 talloc_asprintf(expected->tctx,
366 "TTL did not match expectations for type %s",
367 type));
368
369 expected->records[i].printed = true;
370 }
371
372 return true;
373 }
374
dlz_bind9_putrr_hook(dns_sdlzlookup_t * lookup,const char * type,dns_ttl_t ttl,const char * data)375 static isc_result_t dlz_bind9_putrr_hook(dns_sdlzlookup_t *lookup,
376 const char *type,
377 dns_ttl_t ttl,
378 const char *data)
379 {
380 struct test_expected_rr *expected =
381 talloc_get_type_abort(lookup, struct test_expected_rr);
382 bool ok;
383
384 ok = dlz_bind9_putnamedrr_torture_hook(expected, expected->query_name,
385 type, ttl, data);
386 if (!ok) {
387 return ISC_R_FAILURE;
388 }
389
390 return ISC_R_SUCCESS;
391 }
392
dlz_bind9_putnamedrr_hook(dns_sdlzallnodes_t * allnodes,const char * name,const char * type,dns_ttl_t ttl,const char * data)393 static isc_result_t dlz_bind9_putnamedrr_hook(dns_sdlzallnodes_t *allnodes,
394 const char *name,
395 const char *type,
396 dns_ttl_t ttl,
397 const char *data)
398 {
399 struct test_expected_rr *expected =
400 talloc_get_type_abort(allnodes, struct test_expected_rr);
401 bool ok;
402
403 ok = dlz_bind9_putnamedrr_torture_hook(expected, name, type, ttl, data);
404 if (!ok) {
405 return ISC_R_FAILURE;
406 }
407
408 return ISC_R_SUCCESS;
409 }
410
411 /*
412 * Tests some lookups
413 */
test_dlz_bind9_lookup(struct torture_context * tctx)414 static bool test_dlz_bind9_lookup(struct torture_context *tctx)
415 {
416 size_t i;
417 void *dbdata;
418 const char *argv[] = {
419 "samba_dlz",
420 "-H",
421 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
422 NULL
423 };
424 struct test_expected_rr *expected1 = NULL;
425 struct test_expected_rr *expected2 = NULL;
426
427 tctx_static = tctx;
428 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
429 "log", dlz_bind9_log_wrapper,
430 "writeable_zone", dlz_bind9_writeable_zone_hook,
431 "putrr", dlz_bind9_putrr_hook,
432 "putnamedrr", dlz_bind9_putnamedrr_hook,
433 NULL),
434 ISC_R_SUCCESS,
435 "Failed to create samba_dlz");
436
437 torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
438 ISC_R_SUCCESS,
439 "Failed to configure samba_dlz");
440
441 expected1 = talloc_zero(tctx, struct test_expected_rr);
442 torture_assert(tctx, expected1 != NULL, "talloc failed");
443 expected1->tctx = tctx;
444
445 expected1->query_name = "@";
446
447 expected1->num_records = 4;
448 expected1->records = talloc_zero_array(expected1,
449 struct test_expected_record,
450 expected1->num_records);
451 torture_assert(tctx, expected1->records != NULL, "talloc failed");
452
453 expected1->records[0].name = expected1->query_name;
454 expected1->records[0].type = "soa";
455 expected1->records[0].ttl = 3600;
456 expected1->records[0].data = talloc_asprintf(expected1->records,
457 "%s.%s. hostmaster.%s. 1 900 600 86400 3600",
458 torture_setting_string(tctx, "host", NULL),
459 lpcfg_dnsdomain(tctx->lp_ctx),
460 lpcfg_dnsdomain(tctx->lp_ctx));
461 torture_assert(tctx, expected1->records[0].data != NULL, "talloc failed");
462
463 expected1->records[1].name = expected1->query_name;
464 expected1->records[1].type = "ns";
465 expected1->records[1].ttl = 900;
466 expected1->records[1].data = talloc_asprintf(expected1->records, "%s.%s.",
467 torture_setting_string(tctx, "host", NULL),
468 lpcfg_dnsdomain(tctx->lp_ctx));
469 torture_assert(tctx, expected1->records[1].data != NULL, "talloc failed");
470
471 expected1->records[2].name = expected1->query_name;
472 expected1->records[2].type = "aaaa";
473 expected1->records[2].ttl = 900;
474
475 expected1->records[3].name = expected1->query_name;
476 expected1->records[3].type = "a";
477 expected1->records[3].ttl = 900;
478
479 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
480 expected1->query_name, dbdata,
481 (dns_sdlzlookup_t *)expected1),
482 ISC_R_SUCCESS,
483 "Failed to lookup @");
484 for (i = 0; i < expected1->num_records; i++) {
485 torture_assert(tctx, expected1->records[i].printed,
486 talloc_asprintf(tctx,
487 "Failed to have putrr callback run for type %s",
488 expected1->records[i].type));
489 }
490 torture_assert_int_equal(tctx, expected1->num_rr,
491 expected1->num_records,
492 "Got too much data");
493
494 expected2 = talloc_zero(tctx, struct test_expected_rr);
495 torture_assert(tctx, expected2 != NULL, "talloc failed");
496 expected2->tctx = tctx;
497
498 expected2->query_name = torture_setting_string(tctx, "host", NULL);
499 torture_assert(tctx, expected2->query_name != NULL, "unknown host");
500
501 expected2->num_records = 2;
502 expected2->records = talloc_zero_array(expected2,
503 struct test_expected_record,
504 expected2->num_records);
505 torture_assert(tctx, expected2->records != NULL, "talloc failed");
506
507 expected2->records[0].name = expected2->query_name;
508 expected2->records[0].type = "aaaa";
509 expected2->records[0].ttl = 900;
510
511 expected2->records[1].name = expected2->query_name;
512 expected2->records[1].type = "a";
513 expected2->records[1].ttl = 900;
514
515 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
516 expected2->query_name, dbdata,
517 (dns_sdlzlookup_t *)expected2),
518 ISC_R_SUCCESS,
519 "Failed to lookup hostname");
520 for (i = 0; i < expected2->num_records; i++) {
521 torture_assert(tctx, expected2->records[i].printed,
522 talloc_asprintf(tctx,
523 "Failed to have putrr callback run name[%s] for type %s",
524 expected2->records[i].name,
525 expected2->records[i].type));
526 }
527 torture_assert_int_equal(tctx, expected2->num_rr,
528 expected2->num_records,
529 "Got too much data");
530
531 dlz_destroy(dbdata);
532
533 return true;
534 }
535
536 /*
537 * Test some zone dumps
538 */
test_dlz_bind9_zonedump(struct torture_context * tctx)539 static bool test_dlz_bind9_zonedump(struct torture_context *tctx)
540 {
541 size_t i;
542 void *dbdata;
543 const char *argv[] = {
544 "samba_dlz",
545 "-H",
546 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
547 NULL
548 };
549 struct test_expected_rr *expected1 = NULL;
550
551 tctx_static = tctx;
552 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
553 "log", dlz_bind9_log_wrapper,
554 "writeable_zone", dlz_bind9_writeable_zone_hook,
555 "putrr", dlz_bind9_putrr_hook,
556 "putnamedrr", dlz_bind9_putnamedrr_hook,
557 NULL),
558 ISC_R_SUCCESS,
559 "Failed to create samba_dlz");
560
561 torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
562 ISC_R_SUCCESS,
563 "Failed to configure samba_dlz");
564
565 expected1 = talloc_zero(tctx, struct test_expected_rr);
566 torture_assert(tctx, expected1 != NULL, "talloc failed");
567 expected1->tctx = tctx;
568
569 expected1->num_records = 7;
570 expected1->records = talloc_zero_array(expected1,
571 struct test_expected_record,
572 expected1->num_records);
573 torture_assert(tctx, expected1->records != NULL, "talloc failed");
574
575 expected1->records[0].name = talloc_asprintf(expected1->records,
576 "%s.", lpcfg_dnsdomain(tctx->lp_ctx));
577 expected1->records[0].type = "soa";
578 expected1->records[0].ttl = 3600;
579 expected1->records[0].data = talloc_asprintf(expected1->records,
580 "%s.%s. hostmaster.%s. 1 900 600 86400 3600",
581 torture_setting_string(tctx, "host", NULL),
582 lpcfg_dnsdomain(tctx->lp_ctx),
583 lpcfg_dnsdomain(tctx->lp_ctx));
584 torture_assert(tctx, expected1->records[0].data != NULL, "talloc failed");
585
586 expected1->records[1].name = talloc_asprintf(expected1->records,
587 "%s.", lpcfg_dnsdomain(tctx->lp_ctx));
588 expected1->records[1].type = "ns";
589 expected1->records[1].ttl = 900;
590 expected1->records[1].data = talloc_asprintf(expected1->records, "%s.%s.",
591 torture_setting_string(tctx, "host", NULL),
592 lpcfg_dnsdomain(tctx->lp_ctx));
593 torture_assert(tctx, expected1->records[1].data != NULL, "talloc failed");
594
595 expected1->records[2].name = talloc_asprintf(expected1->records,
596 "%s.", lpcfg_dnsdomain(tctx->lp_ctx));
597 expected1->records[2].type = "aaaa";
598 expected1->records[2].ttl = 900;
599
600 expected1->records[3].name = talloc_asprintf(expected1->records,
601 "%s.", lpcfg_dnsdomain(tctx->lp_ctx));
602 expected1->records[3].type = "a";
603 expected1->records[3].ttl = 900;
604
605 expected1->records[4].name = talloc_asprintf(expected1->records, "%s.%s.",
606 torture_setting_string(tctx, "host", NULL),
607 lpcfg_dnsdomain(tctx->lp_ctx));
608 torture_assert(tctx, expected1->records[4].name != NULL, "unknown host");
609 expected1->records[4].type = "aaaa";
610 expected1->records[4].ttl = 900;
611
612 expected1->records[5].name = talloc_asprintf(expected1->records, "%s.%s.",
613 torture_setting_string(tctx, "host", NULL),
614 lpcfg_dnsdomain(tctx->lp_ctx));
615 torture_assert(tctx, expected1->records[5].name != NULL, "unknown host");
616 expected1->records[5].type = "a";
617 expected1->records[5].ttl = 900;
618
619 /*
620 * We expect multiple srv records
621 */
622 expected1->records[6].name = NULL;
623 expected1->records[6].type = "srv";
624 expected1->records[6].ttl = 900;
625
626 torture_assert_int_equal(tctx, dlz_allnodes(lpcfg_dnsdomain(tctx->lp_ctx),
627 dbdata, (dns_sdlzallnodes_t *)expected1),
628 ISC_R_SUCCESS,
629 "Failed to configure samba_dlz");
630 for (i = 0; i < expected1->num_records; i++) {
631 torture_assert(tctx, expected1->records[i].printed,
632 talloc_asprintf(tctx,
633 "Failed to have putrr callback run name[%s] for type %s",
634 expected1->records[i].name,
635 expected1->records[i].type));
636 }
637 torture_assert_int_equal(tctx, expected1->num_rr, 24,
638 "Got wrong record count");
639
640 dlz_destroy(dbdata);
641
642 return true;
643 }
644
645 /*
646 * Test some updates
647 */
test_dlz_bind9_update01(struct torture_context * tctx)648 static bool test_dlz_bind9_update01(struct torture_context *tctx)
649 {
650 NTSTATUS status;
651 struct gensec_security *gensec_client_context;
652 DATA_BLOB client_to_server, server_to_client;
653 void *dbdata;
654 void *version = NULL;
655 const char *argv[] = {
656 "samba_dlz",
657 "-H",
658 test_dlz_bind9_binddns_dir(tctx, "dns/sam.ldb"),
659 NULL
660 };
661 struct test_expected_rr *expected1 = NULL;
662 char *name = NULL;
663 char *data0 = NULL;
664 char *data1 = NULL;
665 char *data2 = NULL;
666 bool ret = false;
667
668 tctx_static = tctx;
669 torture_assert_int_equal(tctx, dlz_create("samba_dlz", 3, argv, &dbdata,
670 "log", dlz_bind9_log_wrapper,
671 "writeable_zone", dlz_bind9_writeable_zone_hook,
672 "putrr", dlz_bind9_putrr_hook,
673 "putnamedrr", dlz_bind9_putnamedrr_hook,
674 NULL),
675 ISC_R_SUCCESS,
676 "Failed to create samba_dlz");
677
678 torture_assert_int_equal(tctx, dlz_configure((void*)tctx, dbdata),
679 ISC_R_SUCCESS,
680 "Failed to configure samba_dlz");
681
682 expected1 = talloc_zero(tctx, struct test_expected_rr);
683 torture_assert(tctx, expected1 != NULL, "talloc failed");
684 expected1->tctx = tctx;
685
686 expected1->query_name = __func__;
687
688 name = talloc_asprintf(expected1, "%s.%s",
689 expected1->query_name,
690 lpcfg_dnsdomain(tctx->lp_ctx));
691 torture_assert(tctx, name != NULL, "talloc failed");
692
693 expected1->num_records = 2;
694 expected1->records = talloc_zero_array(expected1,
695 struct test_expected_record,
696 expected1->num_records);
697 torture_assert(tctx, expected1->records != NULL, "talloc failed");
698
699 expected1->records[0].name = expected1->query_name;
700 expected1->records[0].type = "a";
701 expected1->records[0].ttl = 3600;
702 expected1->records[0].data = "127.1.2.3";
703 expected1->records[0].printed = false;
704
705 data0 = talloc_asprintf(expected1,
706 "%s.\t" "%u\t" "%s\t" "%s\t" "%s",
707 name,
708 (unsigned)expected1->records[0].ttl,
709 "in",
710 expected1->records[0].type,
711 expected1->records[0].data);
712 torture_assert(tctx, data0 != NULL, "talloc failed");
713
714 expected1->records[1].name = expected1->query_name;
715 expected1->records[1].type = "a";
716 expected1->records[1].ttl = 3600;
717 expected1->records[1].data = "127.3.2.1";
718 expected1->records[1].printed = false;
719
720 data1 = talloc_asprintf(expected1,
721 "%s.\t" "%u\t" "%s\t" "%s\t" "%s",
722 name,
723 (unsigned)expected1->records[1].ttl,
724 "in",
725 expected1->records[1].type,
726 expected1->records[1].data);
727 torture_assert(tctx, data1 != NULL, "talloc failed");
728
729 data2 = talloc_asprintf(expected1,
730 "%s.\t" "0\t" "in\t" "a\t" "127.3.3.3",
731 name);
732 torture_assert(tctx, data2 != NULL, "talloc failed");
733
734 /*
735 * Prepare session info
736 */
737 status = gensec_client_start(tctx, &gensec_client_context,
738 lpcfg_gensec_settings(tctx, tctx->lp_ctx));
739 torture_assert_ntstatus_ok(tctx, status, "gensec_client_start (client) failed");
740
741 /*
742 * dlz_bind9 use the special dns/host.domain account
743 */
744 status = gensec_set_target_hostname(gensec_client_context,
745 talloc_asprintf(tctx,
746 "%s.%s",
747 torture_setting_string(tctx, "host", NULL),
748 lpcfg_dnsdomain(tctx->lp_ctx)));
749 torture_assert_ntstatus_ok(tctx, status, "gensec_set_target_hostname (client) failed");
750
751 status = gensec_set_target_service(gensec_client_context, "dns");
752 torture_assert_ntstatus_ok(tctx, status, "gensec_set_target_service failed");
753
754 status = gensec_set_credentials(gensec_client_context,
755 popt_get_cmdline_credentials());
756 torture_assert_ntstatus_ok(tctx, status, "gensec_set_credentials (client) failed");
757
758 status = gensec_start_mech_by_sasl_name(gensec_client_context, "GSS-SPNEGO");
759 torture_assert_ntstatus_ok(tctx, status, "gensec_start_mech_by_sasl_name (client) failed");
760
761 server_to_client = data_blob(NULL, 0);
762
763 /* Do one step of the client-server update dance */
764 status = gensec_update(gensec_client_context, tctx, server_to_client, &client_to_server);
765 if (!NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {;
766 torture_assert_ntstatus_ok(tctx, status, "gensec_update (client) failed");
767 }
768
769 torture_assert_int_equal(tctx, dlz_ssumatch(
770 cli_credentials_get_username(
771 popt_get_cmdline_credentials()),
772 name,
773 "127.0.0.1",
774 expected1->records[0].type,
775 "key",
776 client_to_server.length,
777 client_to_server.data,
778 dbdata),
779 ISC_TRUE,
780 "Failed to check key for update rights samba_dlz");
781
782 /*
783 * We test the following:
784 *
785 * 1. lookup the records => NOT_FOUND
786 * 2. delete all records => NOT_FOUND
787 * 3. delete 1st record => NOT_FOUND
788 * 4. create 1st record => SUCCESS
789 * 5. lookup the records => found 1st
790 * 6. create 2nd record => SUCCESS
791 * 7. lookup the records => found 1st and 2nd
792 * 8. delete unknown record => NOT_FOUND
793 * 9. lookup the records => found 1st and 2nd
794 * 10. delete 1st record => SUCCESS
795 * 11. lookup the records => found 2nd
796 * 12. delete 2nd record => SUCCESS
797 * 13. lookup the records => NOT_FOUND
798 * 14. create 1st record => SUCCESS
799 * 15. lookup the records => found 1st
800 * 16. create 2nd record => SUCCESS
801 * 17. lookup the records => found 1st and 2nd
802 * 18. update 1st record => SUCCESS
803 * 19. lookup the records => found 1st and 2nd
804 * 20. delete all unknown type records => NOT_FOUND
805 * 21. lookup the records => found 1st and 2nd
806 * 22. delete all records => SUCCESS
807 * 23. lookup the records => NOT_FOUND
808 */
809
810 /* Step 1. */
811 expected1->num_rr = 0;
812 expected1->records[0].printed = false;
813 expected1->records[1].printed = false;
814 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
815 expected1->query_name, dbdata,
816 (dns_sdlzlookup_t *)expected1),
817 ISC_R_NOTFOUND,
818 "Found hostname");
819 torture_assert_int_equal(tctx, expected1->num_rr, 0,
820 "Got wrong record count");
821
822 /* Step 2. */
823 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
824 dbdata, &version),
825 ISC_R_SUCCESS,
826 "Failed to start transaction");
827 torture_assert_int_equal_goto(tctx,
828 dlz_delrdataset(name,
829 expected1->records[0].type,
830 dbdata, version),
831 ISC_R_NOTFOUND, ret, cancel_version,
832 talloc_asprintf(tctx, "Deleted name[%s] type[%s]\n",
833 name, expected1->records[0].type));
834 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), false, dbdata, &version);
835
836 /* Step 3. */
837 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
838 dbdata, &version),
839 ISC_R_SUCCESS,
840 "Failed to start transaction");
841 torture_assert_int_equal_goto(tctx,
842 dlz_subrdataset(name, data0, dbdata, version),
843 ISC_R_NOTFOUND, ret, cancel_version,
844 talloc_asprintf(tctx, "Deleted name[%s] data[%s]\n",
845 name, data0));
846 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), false, dbdata, &version);
847
848 /* Step 4. */
849 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
850 dbdata, &version),
851 ISC_R_SUCCESS,
852 "Failed to start transaction");
853 torture_assert_int_equal_goto(tctx,
854 dlz_addrdataset(name, data0, dbdata, version),
855 ISC_R_SUCCESS, ret, cancel_version,
856 talloc_asprintf(tctx, "Failed to add name[%s] data[%s]\n",
857 name, data0));
858 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
859
860 /* Step 5. */
861 expected1->num_rr = 0;
862 expected1->records[0].printed = false;
863 expected1->records[1].printed = false;
864 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
865 expected1->query_name, dbdata,
866 (dns_sdlzlookup_t *)expected1),
867 ISC_R_SUCCESS,
868 "Not found hostname");
869 torture_assert(tctx, expected1->records[0].printed,
870 talloc_asprintf(tctx,
871 "Failed to have putrr callback run name[%s] for type %s",
872 expected1->records[0].name,
873 expected1->records[0].type));
874 torture_assert_int_equal(tctx, expected1->num_rr, 1,
875 "Got wrong record count");
876
877 /* Step 6. */
878 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
879 dbdata, &version),
880 ISC_R_SUCCESS,
881 "Failed to start transaction");
882 torture_assert_int_equal_goto(tctx,
883 dlz_addrdataset(name, data1, dbdata, version),
884 ISC_R_SUCCESS, ret, cancel_version,
885 talloc_asprintf(tctx, "Failed to add name[%s] data[%s]\n",
886 name, data1));
887 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
888
889 /* Step 7. */
890 expected1->num_rr = 0;
891 expected1->records[0].printed = false;
892 expected1->records[1].printed = false;
893 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
894 expected1->query_name, dbdata,
895 (dns_sdlzlookup_t *)expected1),
896 ISC_R_SUCCESS,
897 "Not found hostname");
898 torture_assert(tctx, expected1->records[0].printed,
899 talloc_asprintf(tctx,
900 "Failed to have putrr callback run name[%s] for type %s",
901 expected1->records[0].name,
902 expected1->records[0].type));
903 torture_assert(tctx, expected1->records[1].printed,
904 talloc_asprintf(tctx,
905 "Failed to have putrr callback run name[%s] for type %s",
906 expected1->records[1].name,
907 expected1->records[1].type));
908 torture_assert_int_equal(tctx, expected1->num_rr, 2,
909 "Got wrong record count");
910
911 /* Step 8. */
912 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
913 dbdata, &version),
914 ISC_R_SUCCESS,
915 "Failed to start transaction");
916 torture_assert_int_equal_goto(tctx,
917 dlz_subrdataset(name, data2, dbdata, version),
918 ISC_R_NOTFOUND, ret, cancel_version,
919 talloc_asprintf(tctx, "Deleted name[%s] data[%s]\n",
920 name, data2));
921 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
922
923 /* Step 9. */
924 expected1->num_rr = 0;
925 expected1->records[0].printed = false;
926 expected1->records[1].printed = false;
927 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
928 expected1->query_name, dbdata,
929 (dns_sdlzlookup_t *)expected1),
930 ISC_R_SUCCESS,
931 "Not found hostname");
932 torture_assert(tctx, expected1->records[0].printed,
933 talloc_asprintf(tctx,
934 "Failed to have putrr callback run name[%s] for type %s",
935 expected1->records[0].name,
936 expected1->records[0].type));
937 torture_assert(tctx, expected1->records[1].printed,
938 talloc_asprintf(tctx,
939 "Failed to have putrr callback run name[%s] for type %s",
940 expected1->records[1].name,
941 expected1->records[1].type));
942 torture_assert_int_equal(tctx, expected1->num_rr, 2,
943 "Got wrong record count");
944
945 /* Step 10. */
946 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
947 dbdata, &version),
948 ISC_R_SUCCESS,
949 "Failed to start transaction");
950 torture_assert_int_equal_goto(tctx,
951 dlz_subrdataset(name, data0, dbdata, version),
952 ISC_R_SUCCESS, ret, cancel_version,
953 talloc_asprintf(tctx, "Failed to delete name[%s] data[%s]\n",
954 name, data0));
955 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
956
957 /* Step 11. */
958 expected1->num_rr = 0;
959 expected1->records[0].printed = false;
960 expected1->records[1].printed = false;
961 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
962 expected1->query_name, dbdata,
963 (dns_sdlzlookup_t *)expected1),
964 ISC_R_SUCCESS,
965 "Not found hostname");
966 torture_assert(tctx, expected1->records[1].printed,
967 talloc_asprintf(tctx,
968 "Failed to have putrr callback run name[%s] for type %s",
969 expected1->records[1].name,
970 expected1->records[1].type));
971 torture_assert_int_equal(tctx, expected1->num_rr, 1,
972 "Got wrong record count");
973
974 /* Step 12. */
975 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
976 dbdata, &version),
977 ISC_R_SUCCESS,
978 "Failed to start transaction");
979 torture_assert_int_equal_goto(tctx,
980 dlz_subrdataset(name, data1, dbdata, version),
981 ISC_R_SUCCESS, ret, cancel_version,
982 talloc_asprintf(tctx, "Failed to delete name[%s] data[%s]\n",
983 name, data1));
984 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
985
986 /* Step 13. */
987 expected1->num_rr = 0;
988 expected1->records[0].printed = false;
989 expected1->records[1].printed = false;
990 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
991 expected1->query_name, dbdata,
992 (dns_sdlzlookup_t *)expected1),
993 ISC_R_NOTFOUND,
994 "Found hostname");
995 torture_assert_int_equal(tctx, expected1->num_rr, 0,
996 "Got wrong record count");
997
998 /* Step 14. */
999 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
1000 dbdata, &version),
1001 ISC_R_SUCCESS,
1002 "Failed to start transaction");
1003 torture_assert_int_equal_goto(tctx,
1004 dlz_addrdataset(name, data0, dbdata, version),
1005 ISC_R_SUCCESS, ret, cancel_version,
1006 talloc_asprintf(tctx, "Failed to add name[%s] data[%s]\n",
1007 name, data0));
1008 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
1009
1010 /* Step 15. */
1011 expected1->num_rr = 0;
1012 expected1->records[0].printed = false;
1013 expected1->records[1].printed = false;
1014 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
1015 expected1->query_name, dbdata,
1016 (dns_sdlzlookup_t *)expected1),
1017 ISC_R_SUCCESS,
1018 "Not found hostname");
1019 torture_assert(tctx, expected1->records[0].printed,
1020 talloc_asprintf(tctx,
1021 "Failed to have putrr callback run name[%s] for type %s",
1022 expected1->records[0].name,
1023 expected1->records[0].type));
1024 torture_assert_int_equal(tctx, expected1->num_rr, 1,
1025 "Got wrong record count");
1026
1027 /* Step 16. */
1028 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
1029 dbdata, &version),
1030 ISC_R_SUCCESS,
1031 "Failed to start transaction");
1032 torture_assert_int_equal_goto(tctx,
1033 dlz_addrdataset(name, data1, dbdata, version),
1034 ISC_R_SUCCESS, ret, cancel_version,
1035 talloc_asprintf(tctx, "Failed to add name[%s] data[%s]\n",
1036 name, data1));
1037 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
1038
1039 /* Step 17. */
1040 expected1->num_rr = 0;
1041 expected1->records[0].printed = false;
1042 expected1->records[1].printed = false;
1043 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
1044 expected1->query_name, dbdata,
1045 (dns_sdlzlookup_t *)expected1),
1046 ISC_R_SUCCESS,
1047 "Not found hostname");
1048 torture_assert(tctx, expected1->records[0].printed,
1049 talloc_asprintf(tctx,
1050 "Failed to have putrr callback run name[%s] for type %s",
1051 expected1->records[0].name,
1052 expected1->records[0].type));
1053 torture_assert(tctx, expected1->records[1].printed,
1054 talloc_asprintf(tctx,
1055 "Failed to have putrr callback run name[%s] for type %s",
1056 expected1->records[1].name,
1057 expected1->records[1].type));
1058 torture_assert_int_equal(tctx, expected1->num_rr, 2,
1059 "Got wrong record count");
1060
1061 /* Step 18. */
1062 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
1063 dbdata, &version),
1064 ISC_R_SUCCESS,
1065 "Failed to start transaction");
1066 torture_assert_int_equal_goto(tctx,
1067 dlz_addrdataset(name, data0, dbdata, version),
1068 ISC_R_SUCCESS, ret, cancel_version,
1069 talloc_asprintf(tctx, "Failed to update name[%s] data[%s]\n",
1070 name, data0));
1071 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
1072
1073 /* Step 19. */
1074 expected1->num_rr = 0;
1075 expected1->records[0].printed = false;
1076 expected1->records[1].printed = false;
1077 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
1078 expected1->query_name, dbdata,
1079 (dns_sdlzlookup_t *)expected1),
1080 ISC_R_SUCCESS,
1081 "Not found hostname");
1082 torture_assert(tctx, expected1->records[0].printed,
1083 talloc_asprintf(tctx,
1084 "Failed to have putrr callback run name[%s] for type %s",
1085 expected1->records[0].name,
1086 expected1->records[0].type));
1087 torture_assert(tctx, expected1->records[1].printed,
1088 talloc_asprintf(tctx,
1089 "Failed to have putrr callback run name[%s] for type %s",
1090 expected1->records[1].name,
1091 expected1->records[1].type));
1092 torture_assert_int_equal(tctx, expected1->num_rr, 2,
1093 "Got wrong record count");
1094
1095 /* Step 20. */
1096 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
1097 dbdata, &version),
1098 ISC_R_SUCCESS,
1099 "Failed to start transaction");
1100 torture_assert_int_equal_goto(tctx,
1101 dlz_delrdataset(name, "txt", dbdata, version),
1102 ISC_R_FAILURE, ret, cancel_version,
1103 talloc_asprintf(tctx, "Deleted name[%s] type[%s]\n",
1104 name, "txt"));
1105 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), false, dbdata, &version);
1106
1107 /* Step 21. */
1108 expected1->num_rr = 0;
1109 expected1->records[0].printed = false;
1110 expected1->records[1].printed = false;
1111 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
1112 expected1->query_name, dbdata,
1113 (dns_sdlzlookup_t *)expected1),
1114 ISC_R_SUCCESS,
1115 "Not found hostname");
1116 torture_assert(tctx, expected1->records[0].printed,
1117 talloc_asprintf(tctx,
1118 "Failed to have putrr callback run name[%s] for type %s",
1119 expected1->records[0].name,
1120 expected1->records[0].type));
1121 torture_assert(tctx, expected1->records[1].printed,
1122 talloc_asprintf(tctx,
1123 "Failed to have putrr callback run name[%s] for type %s",
1124 expected1->records[1].name,
1125 expected1->records[1].type));
1126 torture_assert_int_equal(tctx, expected1->num_rr, 2,
1127 "Got wrong record count");
1128
1129 /* Step 22. */
1130 torture_assert_int_equal(tctx, dlz_newversion(lpcfg_dnsdomain(tctx->lp_ctx),
1131 dbdata, &version),
1132 ISC_R_SUCCESS,
1133 "Failed to start transaction");
1134 torture_assert_int_equal_goto(tctx,
1135 dlz_delrdataset(name,
1136 expected1->records[0].type,
1137 dbdata, version),
1138 ISC_R_SUCCESS, ret, cancel_version,
1139 talloc_asprintf(tctx, "Failed to delete name[%s] type[%s]\n",
1140 name, expected1->records[0].type));
1141 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), true, dbdata, &version);
1142
1143 /* Step 23. */
1144 expected1->num_rr = 0;
1145 expected1->records[0].printed = false;
1146 expected1->records[1].printed = false;
1147 torture_assert_int_equal(tctx, dlz_lookup(lpcfg_dnsdomain(tctx->lp_ctx),
1148 expected1->query_name, dbdata,
1149 (dns_sdlzlookup_t *)expected1),
1150 ISC_R_NOTFOUND,
1151 "Found hostname");
1152 torture_assert_int_equal(tctx, expected1->num_rr, 0,
1153 "Got wrong record count");
1154
1155 dlz_destroy(dbdata);
1156
1157 return true;
1158
1159 cancel_version:
1160 dlz_closeversion(lpcfg_dnsdomain(tctx->lp_ctx), false, dbdata, &version);
1161 return ret;
1162 }
1163
dlz_bind9_suite(TALLOC_CTX * ctx)1164 static struct torture_suite *dlz_bind9_suite(TALLOC_CTX *ctx)
1165 {
1166 struct torture_suite *suite = torture_suite_create(ctx, "dlz_bind9");
1167
1168 suite->description = talloc_strdup(suite,
1169 "Tests for the BIND 9 DLZ module");
1170 torture_suite_add_simple_test(suite, "version", test_dlz_bind9_version);
1171 torture_suite_add_simple_test(suite, "create", test_dlz_bind9_create);
1172 torture_suite_add_simple_test(suite, "configure", test_dlz_bind9_configure);
1173 torture_suite_add_simple_test(suite, "destroyoldestfirst",
1174 test_dlz_bind9_destroy_oldest_first);
1175 torture_suite_add_simple_test(suite, "destroynewestfirst",
1176 test_dlz_bind9_destroy_newest_first);
1177 torture_suite_add_simple_test(suite, "multipleconfigure",
1178 test_dlz_bind9_multiple_configure);
1179
1180 torture_suite_add_simple_test(suite, "gssapi", test_dlz_bind9_gssapi);
1181 torture_suite_add_simple_test(suite, "spnego", test_dlz_bind9_spnego);
1182 torture_suite_add_simple_test(suite, "lookup", test_dlz_bind9_lookup);
1183 torture_suite_add_simple_test(suite, "zonedump", test_dlz_bind9_zonedump);
1184 torture_suite_add_simple_test(suite, "update01", test_dlz_bind9_update01);
1185 return suite;
1186 }
1187
1188 /**
1189 * DNS torture module initialization
1190 */
1191 NTSTATUS torture_bind_dns_init(TALLOC_CTX *);
torture_bind_dns_init(TALLOC_CTX * ctx)1192 NTSTATUS torture_bind_dns_init(TALLOC_CTX *ctx)
1193 {
1194 struct torture_suite *suite;
1195
1196 /* register DNS related test cases */
1197 suite = dlz_bind9_suite(ctx);
1198 if (!suite) return NT_STATUS_NO_MEMORY;
1199 torture_register_suite(ctx, suite);
1200
1201 return NT_STATUS_OK;
1202 }
1203