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