summaryrefslogtreecommitdiff
path: root/source4/torture/drs/unit
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-26 21:04:28 +0200
committerStefan Metzmacher <metze@samba.org>2009-11-06 14:05:44 +0100
commit20622de49f8a876ef91db329348d0827126f11c2 (patch)
treed9205cdbd53d41d81246562a56aed4368fd7ba4f /source4/torture/drs/unit
parentfc05386c0d9bf2cf39223e05d3a633a8559c5973 (diff)
downloadsamba-20622de49f8a876ef91db329348d0827126f11c2.tar.gz
samba-20622de49f8a876ef91db329348d0827126f11c2.tar.bz2
samba-20622de49f8a876ef91db329348d0827126f11c2.zip
s4/drs(tort): prefixMap to/from ldb_val serialization test case
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/torture/drs/unit')
-rw-r--r--source4/torture/drs/unit/prefixmap_tests.c63
1 files changed, 61 insertions, 2 deletions
diff --git a/source4/torture/drs/unit/prefixmap_tests.c b/source4/torture/drs/unit/prefixmap_tests.c
index f89d5d95d7..e0203bf783 100644
--- a/source4/torture/drs/unit/prefixmap_tests.c
+++ b/source4/torture/drs/unit/prefixmap_tests.c
@@ -21,8 +21,9 @@
#include "includes.h"
#include "torture/smbtorture.h"
-#include "torture/rpc/drsuapi.h"
#include "dsdb/samdb/samdb.h"
+#include "torture/rpc/drsuapi.h"
+#include "param/param.h"
/**
@@ -369,7 +370,7 @@ static bool torture_drs_unit_pfm_to_from_drsuapi(struct torture_context *tctx, s
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_new(tctx);
- torture_assert(tctx, mem_ctx, "Unexptected: Have no memory!");
+ torture_assert(tctx, mem_ctx, "Unexpected: Have no memory!");
/* convert Schema_prefixMap to drsuapi_prefixMap */
werr = dsdb_drsuapi_pfm_from_schema_pfm(priv->pfm_full, schema_info_default, mem_ctx, &ctr);
@@ -415,6 +416,62 @@ static bool torture_drs_unit_pfm_to_from_drsuapi(struct torture_context *tctx, s
}
+/**
+ * Test Schema prefixMap conversions to/from ldb_val
+ * blob representation.
+ */
+static bool torture_drs_unit_pfm_to_from_ldb_val(struct torture_context *tctx, struct drsut_prefixmap_data *priv)
+{
+ WERROR werr;
+ const char *schema_info;
+ const char *schema_info_default = "FF0000000000000000000000000000000123456789";
+ struct dsdb_schema *schema;
+ struct ldb_val pfm_ldb_val;
+ struct ldb_val schema_info_ldb_val;
+ TALLOC_CTX *mem_ctx;
+
+ mem_ctx = talloc_new(tctx);
+ torture_assert(tctx, mem_ctx, "Unexpected: Have no memory!");
+
+ schema = dsdb_new_schema(mem_ctx, lp_iconv_convenience(tctx->lp_ctx));
+ torture_assert(tctx, schema, "Unexpected: failed to allocate schema object");
+
+ /* set priv->pfm_full as prefixMap for new schema object */
+ schema->prefixmap = priv->pfm_full;
+ schema->schema_info = schema_info_default;
+
+ /* convert schema_prefixMap to ldb_val blob */
+ werr = dsdb_get_oid_mappings_ldb(schema, mem_ctx, &pfm_ldb_val, &schema_info_ldb_val);
+ torture_assert_werr_ok(tctx, werr, "dsdb_get_oid_mappings_ldb() failed");
+ torture_assert(tctx, pfm_ldb_val.data && pfm_ldb_val.length,
+ "pfm_ldb_val not constructed correctly");
+ torture_assert(tctx, schema_info_ldb_val.data && schema_info_ldb_val.length,
+ "schema_info_ldb_val not constructed correctly");
+ /* look for schema_info entry - it should be the last one */
+ schema_info = hex_encode_talloc(mem_ctx,
+ schema_info_ldb_val.data,
+ schema_info_ldb_val.length);
+ torture_assert_str_equal(tctx,
+ schema_info,
+ schema_info_default,
+ "schema_info not stored correctly or not last entry");
+
+ /* convert pfm_ldb_val back to schema_prefixMap */
+ schema->prefixmap = NULL;
+ schema->schema_info = NULL;
+ werr = dsdb_load_oid_mappings_ldb(schema, &pfm_ldb_val, &schema_info_ldb_val);
+ torture_assert_werr_ok(tctx, werr, "dsdb_load_oid_mappings_ldb() failed");
+ /* compare against the original */
+ if (!_torture_drs_pfm_compare_same(tctx, schema->prefixmap, priv->pfm_full)) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
+
/*
* Setup/Teardown for test case
*/
@@ -467,5 +524,7 @@ struct torture_tcase * torture_drs_unit_prefixmap(struct torture_suite *suite)
torture_tcase_add_simple_test(tc, "pfm_to_from_drsuapi", (pfn_run)torture_drs_unit_pfm_to_from_drsuapi);
+ torture_tcase_add_simple_test(tc, "pfm_to_from_ldb_val", (pfn_run)torture_drs_unit_pfm_to_from_ldb_val);
+
return tc;
}