s3:smbd: s/event_add_fd/tevent_add_fd and s/EVENT_FD_/TEVENT_FD_
[Samba/gebeck_regimport.git] / source4 / torture / drs / unit / schemainfo_tests.c
blob2fb5308f741c1644cac3ecada90f3bcdefb4350c
1 /*
2 Unix SMB/CIFS implementation.
4 DRSUAPI schemaInfo unit tests
6 Copyright (C) Kamen Mazdrashki <kamenim@samba.org> 2010
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "system/filesys.h"
24 #include "torture/smbtorture.h"
25 #include "dsdb/samdb/samdb.h"
26 #include "dsdb/samdb/ldb_modules/util.h"
27 #include "ldb_wrap.h"
28 #include <ldb_module.h>
29 #include "torture/rpc/drsuapi.h"
30 #include "librpc/ndr/libndr.h"
31 #include "param/param.h"
32 #include "torture/drs/proto.h"
33 #include "torture/drs/proto.h"
36 /**
37 * schemaInfo to init ldb context with
38 * Rev: 0
39 * GUID: 00000000-0000-0000-0000-000000000000
41 #define SCHEMA_INFO_INIT_STR "FF0000000000000000000000000000000000000000"
43 /**
44 * Default schema_info string to be used for testing
45 * Rev: 01
46 * GUID: 071c82fd-45c7-4351-a3db-51f75a630a7f
48 #define SCHEMA_INFO_DEFAULT_STR "FF00000001FD821C07C7455143A3DB51F75A630A7F"
50 /**
51 * Schema info data to test with
53 struct schemainfo_data {
54 DATA_BLOB ndr_blob;
55 struct dsdb_schema_info schi;
56 WERROR werr_expected;
57 bool test_both_ways;
60 /**
61 * Schema info test data in human-readable format (... kind of)
63 static const struct {
64 const char *schema_info_str;
65 uint32_t revision;
66 const char *guid_str;
67 WERROR werr_expected;
68 bool test_both_ways;
69 } _schemainfo_test_data[] = {
71 .schema_info_str = "FF0000000000000000000000000000000000000000",
72 .revision = 0,
73 .guid_str = "00000000-0000-0000-0000-000000000000",
74 .werr_expected = WERR_OK,
75 .test_both_ways = true
78 .schema_info_str = "FF00000001FD821C07C7455143A3DB51F75A630A7F",
79 .revision = 1,
80 .guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
81 .werr_expected = WERR_OK,
82 .test_both_ways = true
85 .schema_info_str = "FFFFFFFFFFFD821C07C7455143A3DB51F75A630A7F",
86 .revision = 0xFFFFFFFF,
87 .guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
88 .werr_expected = WERR_OK,
89 .test_both_ways = true
91 { /* len == 21 */
92 .schema_info_str = "FF00000001FD821C07C7455143A3DB51F75A630A7F00",
93 .revision = 1,
94 .guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
95 .werr_expected = WERR_INVALID_PARAMETER,
96 .test_both_ways = false
98 { /* marker == FF */
99 .schema_info_str = "AA00000001FD821C07C7455143A3DB51F75A630A7F",
100 .revision = 1,
101 .guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
102 .werr_expected = WERR_INVALID_PARAMETER,
103 .test_both_ways = false
108 * Private data to be shared among all test in Test case
110 struct drsut_schemainfo_data {
111 struct ldb_context *ldb;
112 struct ldb_module *ldb_module;
113 struct dsdb_schema *schema;
115 /* Initial schemaInfo set in ldb to test with */
116 struct dsdb_schema_info *schema_info;
118 uint32_t test_data_count;
119 struct schemainfo_data *test_data;
123 * torture macro to assert for equal dsdb_schema_info's
125 #define torture_assert_schema_info_equal(torture_ctx,got,expected,cmt)\
126 do { const struct dsdb_schema_info *__got = (got), *__expected = (expected); \
127 if (__got->revision != __expected->revision) { \
128 torture_result(torture_ctx, TORTURE_FAIL, \
129 __location__": "#got".revision %d did not match "#expected".revision %d: %s", \
130 (int)__got->revision, (int)__expected->revision, cmt); \
131 return false; \
133 if (!GUID_equal(&__got->invocation_id, &__expected->invocation_id)) { \
134 torture_result(torture_ctx, TORTURE_FAIL, \
135 __location__": "#got".invocation_id did not match "#expected".invocation_id: %s", cmt); \
136 return false; \
138 } while(0)
141 * forward declaration for internal functions
143 static bool _drsut_ldb_schema_info_reset(struct torture_context *tctx,
144 struct ldb_context *ldb,
145 const char *schema_info_str,
146 bool in_setup);
150 * Creates dsdb_schema_info object based on NDR data
151 * passed as hex string
153 static bool _drsut_schemainfo_new(struct torture_context *tctx,
154 const char *schema_info_str, struct dsdb_schema_info **_si)
156 WERROR werr;
157 DATA_BLOB blob;
159 blob = strhex_to_data_blob(tctx, schema_info_str);
160 if (!blob.data) {
161 torture_comment(tctx, "Not enough memory!\n");
162 return false;
165 werr = dsdb_schema_info_from_blob(&blob, tctx, _si);
166 if (!W_ERROR_IS_OK(werr)) {
167 torture_comment(tctx,
168 "Failed to create dsdb_schema_info object for %s: %s",
169 schema_info_str,
170 win_errstr(werr));
171 return false;
174 data_blob_free(&blob);
176 return true;
180 * Creates dsdb_schema_info object based on predefined data
181 * Function is public as it is intended to be used by other
182 * tests (e.g. prefixMap tests)
184 bool drsut_schemainfo_new(struct torture_context *tctx, struct dsdb_schema_info **_si)
186 return _drsut_schemainfo_new(tctx, SCHEMA_INFO_DEFAULT_STR, _si);
191 * Tests dsdb_schema_info_new() and dsdb_schema_info_blob_new()
193 static bool test_dsdb_schema_info_new(struct torture_context *tctx,
194 struct drsut_schemainfo_data *priv)
196 WERROR werr;
197 DATA_BLOB ndr_blob;
198 DATA_BLOB ndr_blob_expected;
199 struct dsdb_schema_info *schi;
200 TALLOC_CTX *mem_ctx;
202 mem_ctx = talloc_new(priv);
203 torture_assert(tctx, mem_ctx, "Not enough memory!");
204 ndr_blob_expected = strhex_to_data_blob(mem_ctx, SCHEMA_INFO_INIT_STR);
205 torture_assert(tctx, ndr_blob_expected.data, "Not enough memory!");
207 werr = dsdb_schema_info_new(mem_ctx, &schi);
208 torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_new() failed");
209 torture_assert_int_equal(tctx, schi->revision, 0,
210 "dsdb_schema_info_new() creates schemaInfo with invalid revision");
211 torture_assert(tctx, GUID_all_zero(&schi->invocation_id),
212 "dsdb_schema_info_new() creates schemaInfo with not ZERO GUID");
214 werr = dsdb_schema_info_blob_new(mem_ctx, &ndr_blob);
215 torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_blob_new() failed");
216 torture_assert_data_blob_equal(tctx, ndr_blob, ndr_blob_expected,
217 "dsdb_schema_info_blob_new() returned invalid blob");
219 talloc_free(mem_ctx);
220 return true;
224 * Tests dsdb_schema_info_from_blob()
226 static bool test_dsdb_schema_info_from_blob(struct torture_context *tctx,
227 struct drsut_schemainfo_data *priv)
229 int i;
230 WERROR werr;
231 char *msg;
232 struct dsdb_schema_info *schema_info;
233 TALLOC_CTX *mem_ctx;
235 mem_ctx = talloc_new(priv);
236 torture_assert(tctx, mem_ctx, "Not enough memory!");
238 for (i = 0; i < priv->test_data_count; i++) {
239 struct schemainfo_data *data = &priv->test_data[i];
241 msg = talloc_asprintf(tctx, "dsdb_schema_info_from_blob() [%d]-[%s]",
242 i, _schemainfo_test_data[i].schema_info_str);
244 werr = dsdb_schema_info_from_blob(&data->ndr_blob, mem_ctx, &schema_info);
245 torture_assert_werr_equal(tctx, werr, data->werr_expected, msg);
247 /* test returned data */
248 if (W_ERROR_IS_OK(werr)) {
249 torture_assert_schema_info_equal(tctx,
250 schema_info, &data->schi,
251 "after dsdb_schema_info_from_blob() call");
255 talloc_free(mem_ctx);
257 return true;
261 * Tests dsdb_blob_from_schema_info()
263 static bool test_dsdb_blob_from_schema_info(struct torture_context *tctx,
264 struct drsut_schemainfo_data *priv)
266 int i;
267 WERROR werr;
268 char *msg;
269 DATA_BLOB ndr_blob;
270 TALLOC_CTX *mem_ctx;
272 mem_ctx = talloc_new(priv);
273 torture_assert(tctx, mem_ctx, "Not enough memory!");
275 for (i = 0; i < priv->test_data_count; i++) {
276 struct schemainfo_data *data = &priv->test_data[i];
278 /* not all test are valid reverse type of conversion */
279 if (!data->test_both_ways) {
280 continue;
283 msg = talloc_asprintf(tctx, "dsdb_blob_from_schema_info() [%d]-[%s]",
284 i, _schemainfo_test_data[i].schema_info_str);
286 werr = dsdb_blob_from_schema_info(&data->schi, mem_ctx, &ndr_blob);
287 torture_assert_werr_equal(tctx, werr, data->werr_expected, msg);
289 /* test returned data */
290 if (W_ERROR_IS_OK(werr)) {
291 torture_assert_data_blob_equal(tctx,
292 ndr_blob, data->ndr_blob,
293 "dsdb_blob_from_schema_info()");
297 talloc_free(mem_ctx);
299 return true;
302 static bool test_dsdb_schema_info_cmp(struct torture_context *tctx,
303 struct drsut_schemainfo_data *priv)
305 DATA_BLOB blob;
306 struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
308 ctr = talloc_zero(priv, struct drsuapi_DsReplicaOIDMapping_Ctr);
309 torture_assert(tctx, ctr, "Not enough memory!");
311 /* not enough elements */
312 torture_assert_werr_equal(tctx,
313 dsdb_schema_info_cmp(priv->schema, ctr),
314 WERR_INVALID_PARAMETER,
315 "dsdb_schema_info_cmp(): unexpected result");
317 /* an empty element for schemaInfo */
318 ctr->num_mappings = 1;
319 ctr->mappings = talloc_zero_array(ctr, struct drsuapi_DsReplicaOIDMapping, 1);
320 torture_assert(tctx, ctr->mappings, "Not enough memory!");
321 torture_assert_werr_equal(tctx,
322 dsdb_schema_info_cmp(priv->schema, ctr),
323 WERR_INVALID_PARAMETER,
324 "dsdb_schema_info_cmp(): unexpected result");
326 /* test with invalid schemaInfo - length != 21 */
327 blob = strhex_to_data_blob(ctr, "FF00000001FD821C07C7455143A3DB51F75A630A7F00");
328 torture_assert(tctx, blob.data, "Not enough memory!");
329 ctr->mappings[0].oid.length = blob.length;
330 ctr->mappings[0].oid.binary_oid = blob.data;
331 torture_assert_werr_equal(tctx,
332 dsdb_schema_info_cmp(priv->schema, ctr),
333 WERR_INVALID_PARAMETER,
334 "dsdb_schema_info_cmp(): unexpected result");
336 /* test with invalid schemaInfo - marker != 0xFF */
337 blob = strhex_to_data_blob(ctr, "AA00000001FD821C07C7455143A3DB51F75A630A7F");
338 torture_assert(tctx, blob.data, "Not enough memory!");
339 ctr->mappings[0].oid.length = blob.length;
340 ctr->mappings[0].oid.binary_oid = blob.data;
341 torture_assert_werr_equal(tctx,
342 dsdb_schema_info_cmp(priv->schema, ctr),
343 WERR_INVALID_PARAMETER,
344 "dsdb_schema_info_cmp(): unexpected result");
346 /* test with valid schemaInfo, but not correct one */
347 blob = strhex_to_data_blob(ctr, "FF0000000000000000000000000000000000000000");
348 torture_assert(tctx, blob.data, "Not enough memory!");
349 ctr->mappings[0].oid.length = blob.length;
350 ctr->mappings[0].oid.binary_oid = blob.data;
351 torture_assert_werr_equal(tctx,
352 dsdb_schema_info_cmp(priv->schema, ctr),
353 WERR_DS_DRA_SCHEMA_MISMATCH,
354 "dsdb_schema_info_cmp(): unexpected result");
356 /* test with correct schemaInfo, but invalid ATTID */
357 blob = strhex_to_data_blob(ctr, priv->schema->schema_info);
358 torture_assert(tctx, blob.data, "Not enough memory!");
359 ctr->mappings[0].id_prefix = 1;
360 ctr->mappings[0].oid.length = blob.length;
361 ctr->mappings[0].oid.binary_oid = blob.data;
362 torture_assert_werr_equal(tctx,
363 dsdb_schema_info_cmp(priv->schema, ctr),
364 WERR_INVALID_PARAMETER,
365 "dsdb_schema_info_cmp(): unexpected result");
367 /* test with valid schemaInfo */
368 blob = strhex_to_data_blob(ctr, priv->schema->schema_info);
369 ctr->mappings[0].id_prefix = 0;
370 torture_assert_werr_ok(tctx,
371 dsdb_schema_info_cmp(priv->schema, ctr),
372 "dsdb_schema_info_cmp(): unexpected result");
374 talloc_free(ctr);
375 return true;
379 * Tests dsdb_module_schema_info_blob_read()
380 * and dsdb_module_schema_info_blob_write()
382 static bool test_dsdb_module_schema_info_blob_rw(struct torture_context *tctx,
383 struct drsut_schemainfo_data *priv)
385 int ldb_err;
386 DATA_BLOB blob_write;
387 DATA_BLOB blob_read;
389 /* reset schmeInfo to know value */
390 torture_assert(tctx,
391 _drsut_ldb_schema_info_reset(tctx, priv->ldb, SCHEMA_INFO_INIT_STR, false),
392 "_drsut_ldb_schema_info_reset() failed");
394 /* write tests' default schemaInfo */
395 blob_write = strhex_to_data_blob(priv, SCHEMA_INFO_DEFAULT_STR);
396 torture_assert(tctx, blob_write.data, "Not enough memory!");
398 ldb_err = dsdb_module_schema_info_blob_write(priv->ldb_module,
399 DSDB_FLAG_TOP_MODULE,
400 &blob_write, NULL);
401 torture_assert_int_equal(tctx, ldb_err, LDB_SUCCESS, "dsdb_module_schema_info_blob_write() failed");
403 ldb_err = dsdb_module_schema_info_blob_read(priv->ldb_module, DSDB_FLAG_TOP_MODULE,
404 priv, &blob_read, NULL);
405 torture_assert_int_equal(tctx, ldb_err, LDB_SUCCESS, "dsdb_module_schema_info_blob_read() failed");
407 /* check if we get what we wrote */
408 torture_assert_data_blob_equal(tctx, blob_read, blob_write,
409 "Write/Read of schemeInfo blob failed");
411 return true;
415 * Tests dsdb_schema_update_schema_info()
417 static bool test_dsdb_module_schema_info_update(struct torture_context *tctx,
418 struct drsut_schemainfo_data *priv)
420 int ldb_err;
421 WERROR werr;
422 DATA_BLOB blob;
423 struct dsdb_schema_info *schema_info;
425 /* reset schmeInfo to know value */
426 torture_assert(tctx,
427 _drsut_ldb_schema_info_reset(tctx, priv->ldb, SCHEMA_INFO_INIT_STR, false),
428 "_drsut_ldb_schema_info_reset() failed");
430 ldb_err = dsdb_module_schema_info_update(priv->ldb_module,
431 priv->schema,
432 DSDB_FLAG_TOP_MODULE | DSDB_FLAG_AS_SYSTEM, NULL);
433 torture_assert_int_equal(tctx, ldb_err, LDB_SUCCESS, "dsdb_module_schema_info_update() failed");
435 /* get updated schemaInfo */
436 ldb_err = dsdb_module_schema_info_blob_read(priv->ldb_module, DSDB_FLAG_TOP_MODULE,
437 priv, &blob, NULL);
438 torture_assert_int_equal(tctx, ldb_err, LDB_SUCCESS, "dsdb_module_schema_info_blob_read() failed");
440 werr = dsdb_schema_info_from_blob(&blob, priv, &schema_info);
441 torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_from_blob() failed");
443 /* check against default schema_info */
444 torture_assert_schema_info_equal(tctx, schema_info, priv->schema_info,
445 "schemaInfo attribute no updated correctly");
447 return true;
452 * Reset schemaInfo record to know value
454 static bool _drsut_ldb_schema_info_reset(struct torture_context *tctx,
455 struct ldb_context *ldb,
456 const char *schema_info_str,
457 bool in_setup)
459 bool bret = true;
460 int ldb_err;
461 DATA_BLOB blob;
462 struct ldb_message *msg;
463 TALLOC_CTX *mem_ctx = talloc_new(tctx);
465 blob = strhex_to_data_blob(mem_ctx, schema_info_str);
466 torture_assert_goto(tctx, blob.data, bret, DONE, "Not enough memory!");
468 msg = ldb_msg_new(mem_ctx);
469 torture_assert_goto(tctx, msg, bret, DONE, "Not enough memory!");
471 msg->dn = ldb_get_schema_basedn(ldb);
472 ldb_err = ldb_msg_add_value(msg, "schemaInfo", &blob, NULL);
473 torture_assert_int_equal_goto(tctx, ldb_err, LDB_SUCCESS, bret, DONE,
474 "ldb_msg_add_value() failed");
476 if (in_setup) {
477 ldb_err = ldb_add(ldb, msg);
478 } else {
479 ldb_err = dsdb_replace(ldb, msg, DSDB_MODIFY_PERMISSIVE);
481 torture_assert_int_equal_goto(tctx, ldb_err, LDB_SUCCESS, bret, DONE,
482 "dsdb_replace() failed");
484 DONE:
485 talloc_free(mem_ctx);
486 return bret;
490 * Prepare temporary LDB and opens it
492 static bool _drsut_ldb_setup(struct torture_context *tctx, struct drsut_schemainfo_data *priv)
494 int ldb_err;
495 char *ldb_url;
496 bool bret = true;
497 char *tempdir = NULL;
498 NTSTATUS status;
499 TALLOC_CTX* mem_ctx;
501 mem_ctx = talloc_new(priv);
502 torture_assert(tctx, mem_ctx, "Not enough memory!");
504 status = torture_temp_dir(tctx, "drs_", &tempdir);
505 torture_assert_ntstatus_ok_goto(tctx, status, bret, DONE, "creating temp dir");
507 ldb_url = talloc_asprintf(priv, "%s/drs_schemainfo.ldb", tempdir);
508 torture_assert_goto(tctx, ldb_url, bret, DONE, "Not enough memory!");
510 /* create LDB */
511 priv->ldb = ldb_wrap_connect(priv, tctx->ev, tctx->lp_ctx,
512 ldb_url, NULL, NULL, 0);
513 torture_assert_goto(tctx, priv->ldb, bret, DONE, "ldb_wrap_connect() failed");
515 /* set some schemaNamingContext */
516 ldb_err = ldb_set_opaque(priv->ldb,
517 "schemaNamingContext",
518 ldb_dn_new(priv->ldb, priv->ldb, "CN=Schema,CN=Config"));
519 torture_assert_int_equal_goto(tctx, ldb_err, LDB_SUCCESS, bret, DONE,
520 "ldb_set_opaque() failed");
522 /* add schemaInfo attribute so tested layer could work properly */
523 torture_assert_goto(tctx,
524 _drsut_ldb_schema_info_reset(tctx, priv->ldb, SCHEMA_INFO_INIT_STR, true),
525 bret, DONE,
526 "_drsut_ldb_schema_info_reset() failed");
528 DONE:
529 talloc_free(tempdir);
530 talloc_free(mem_ctx);
531 return bret;
535 * Setup/Teardown for test case
537 static bool torture_drs_unit_schemainfo_setup(struct torture_context *tctx,
538 struct drsut_schemainfo_data **_priv)
540 int i;
541 int ldb_err;
542 NTSTATUS status;
543 DATA_BLOB ndr_blob;
544 struct GUID guid;
545 struct drsut_schemainfo_data *priv;
547 priv = talloc_zero(tctx, struct drsut_schemainfo_data);
548 torture_assert(tctx, priv, "Not enough memory!");
550 /* returned allocated pointer here
551 * teardown() will be called even in case of failure,
552 * so we'll get a changes to clean up */
553 *_priv = priv;
555 /* create initial schemaInfo */
556 torture_assert(tctx,
557 _drsut_schemainfo_new(tctx, SCHEMA_INFO_DEFAULT_STR, &priv->schema_info),
558 "Failed to create schema_info test object");
560 /* create data to test with */
561 priv->test_data_count = ARRAY_SIZE(_schemainfo_test_data);
562 priv->test_data = talloc_array(tctx, struct schemainfo_data, priv->test_data_count);
564 for (i = 0; i < ARRAY_SIZE(_schemainfo_test_data); i++) {
565 struct schemainfo_data *data = &priv->test_data[i];
567 ndr_blob = strhex_to_data_blob(priv,
568 _schemainfo_test_data[i].schema_info_str);
569 torture_assert(tctx, ndr_blob.data, "Not enough memory!");
571 status = GUID_from_string(_schemainfo_test_data[i].guid_str, &guid);
572 torture_assert_ntstatus_ok(tctx, status,
573 talloc_asprintf(tctx,
574 "GUID_from_string() failed for %s",
575 _schemainfo_test_data[i].guid_str));
577 data->ndr_blob = ndr_blob;
578 data->schi.invocation_id = guid;
579 data->schi.revision = _schemainfo_test_data[i].revision;
580 data->werr_expected = _schemainfo_test_data[i].werr_expected;
581 data->test_both_ways = _schemainfo_test_data[i].test_both_ways;
585 /* create temporary LDB and populate with data */
586 if (!_drsut_ldb_setup(tctx, priv)) {
587 return false;
590 /* create ldb_module mockup object */
591 priv->ldb_module = ldb_module_new(priv, priv->ldb, "schemaInfo_test_module", NULL);
592 torture_assert(tctx, priv->ldb_module, "Not enough memory!");
594 /* create schema mockup object */
595 priv->schema = dsdb_new_schema(priv);
597 /* set schema_info in dsdb_schema for testing */
598 priv->schema->schema_info = talloc_strdup(priv->schema, SCHEMA_INFO_DEFAULT_STR);
600 /* pre-cache invocationId for samdb_ntds_invocation_id()
601 * to work with our mock ldb */
602 ldb_err = ldb_set_opaque(priv->ldb, "cache.invocation_id",
603 &priv->schema_info->invocation_id);
604 torture_assert_int_equal(tctx, ldb_err, LDB_SUCCESS, "ldb_set_opaque() failed");
606 /* Perform all tests in transactions so that
607 * underlying modify calls not to fail */
608 ldb_err = ldb_transaction_start(priv->ldb);
609 torture_assert_int_equal(tctx,
610 ldb_err,
611 LDB_SUCCESS,
612 "ldb_transaction_start() failed");
614 return true;
617 static bool torture_drs_unit_schemainfo_teardown(struct torture_context *tctx,
618 struct drsut_schemainfo_data *priv)
620 int ldb_err;
622 /* commit pending transaction so we will
623 * be able to check what LDB state is */
624 ldb_err = ldb_transaction_commit(priv->ldb);
625 if (ldb_err != LDB_SUCCESS) {
626 torture_comment(tctx, "ldb_transaction_commit() - %s (%s)",
627 ldb_strerror(ldb_err),
628 ldb_errstring(priv->ldb));
631 talloc_free(priv);
633 return true;
637 * Test case initialization for
638 * drs.unit.schemaInfo
640 struct torture_tcase * torture_drs_unit_schemainfo(struct torture_suite *suite)
642 typedef bool (*pfn_setup)(struct torture_context *, void **);
643 typedef bool (*pfn_teardown)(struct torture_context *, void *);
644 typedef bool (*pfn_run)(struct torture_context *, void *);
646 struct torture_tcase * tc = torture_suite_add_tcase(suite, "schemaInfo");
648 torture_tcase_set_fixture(tc,
649 (pfn_setup)torture_drs_unit_schemainfo_setup,
650 (pfn_teardown)torture_drs_unit_schemainfo_teardown);
652 tc->description = talloc_strdup(tc, "Unit tests for DRSUAPI::schemaInfo implementation");
654 torture_tcase_add_simple_test(tc, "dsdb_schema_info_new",
655 (pfn_run)test_dsdb_schema_info_new);
656 torture_tcase_add_simple_test(tc, "dsdb_schema_info_from_blob",
657 (pfn_run)test_dsdb_schema_info_from_blob);
658 torture_tcase_add_simple_test(tc, "dsdb_blob_from_schema_info",
659 (pfn_run)test_dsdb_blob_from_schema_info);
660 torture_tcase_add_simple_test(tc, "dsdb_schema_info_cmp",
661 (pfn_run)test_dsdb_schema_info_cmp);
662 torture_tcase_add_simple_test(tc, "dsdb_module_schema_info_blob read|write",
663 (pfn_run)test_dsdb_module_schema_info_blob_rw);
664 torture_tcase_add_simple_test(tc, "dsdb_module_schema_info_update",
665 (pfn_run)test_dsdb_module_schema_info_update);
668 return tc;