summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-25 20:31:39 +0200
committerStefan Metzmacher <metze@samba.org>2009-11-06 14:05:39 +0100
commit5446123190a6db8a563289e902ed375771e29942 (patch)
tree7e7df833ac304bc8466a6dc8f2ba3f95bd872768 /source4/torture
parent3d91c8ef5a115171f96d33606879ab7d871f3e3d (diff)
downloadsamba-5446123190a6db8a563289e902ed375771e29942.tar.gz
samba-5446123190a6db8a563289e902ed375771e29942.tar.bz2
samba-5446123190a6db8a563289e902ed375771e29942.zip
s4/drs(tort): test for schema_prefixMap to/from drsuapi_prefixMap conversion
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/drs/unit/prefixmap_tests.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/source4/torture/drs/unit/prefixmap_tests.c b/source4/torture/drs/unit/prefixmap_tests.c
index 16d8298ef2..ea5802fcca 100644
--- a/source4/torture/drs/unit/prefixmap_tests.c
+++ b/source4/torture/drs/unit/prefixmap_tests.c
@@ -355,6 +355,55 @@ static bool torture_drs_unit_pfm_oid_from_attid(struct torture_context *tctx, st
return true;
}
+/**
+ * Test Schema prefixMap conversions to/from drsuapi prefixMap
+ * representation.
+ */
+static bool torture_drs_unit_pfm_to_from_drsuapi(struct torture_context *tctx, struct drsut_prefixmap_data *priv)
+{
+ WERROR werr;
+ const char *schema_info;
+ const char *schema_info_default = "FF0000000000000000000000000000000123456789";
+ struct dsdb_schema_prefixmap *pfm;
+ struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
+ TALLOC_CTX *mem_ctx;
+
+ mem_ctx = talloc_new(tctx);
+ torture_assert(tctx, mem_ctx, "Unexptected: 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);
+ torture_assert_werr_ok(tctx, werr, "dsdb_drsuapi_pfm_from_schema_pfm() failed");
+ torture_assert(tctx, ctr && ctr->mappings, "drsuapi_prefixMap not constructed correctly");
+ torture_assert_int_equal(tctx, ctr->num_mappings, priv->pfm_full->length + 1,
+ "drs_mappings count does not match");
+ /* look for schema_info entry - it should be the last one */
+ schema_info = hex_encode_talloc(mem_ctx,
+ ctr->mappings[ctr->num_mappings - 1].oid.binary_oid,
+ ctr->mappings[ctr->num_mappings - 1].oid.length);
+ torture_assert_str_equal(tctx,
+ schema_info,
+ schema_info_default,
+ "schema_info not stored correctly or not last entry");
+
+ /* compare schema_prefixMap and drsuapi_prefixMap */
+ werr = dsdb_schema_pfm_contains_drsuapi_pfm(priv->pfm_full, ctr);
+ torture_assert_werr_ok(tctx, werr, "dsdb_schema_pfm_contains_drsuapi_pfm() failed");
+
+ /* convert back drsuapi_prefixMap to schema_prefixMap */
+ werr = dsdb_schema_pfm_from_drsuapi_pfm(ctr, mem_ctx, &pfm, &schema_info);
+ torture_assert_werr_ok(tctx, werr, "dsdb_schema_pfm_from_drsuapi_pfm() failed");
+
+ /* compare against the original */
+ if (!_torture_drs_pfm_compare_same(tctx, priv->pfm_full, pfm)) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+
+ talloc_free(mem_ctx);
+ return true;
+}
+
/*
* Setup/Teardown for test case
@@ -406,5 +455,7 @@ struct torture_tcase * torture_drs_unit_prefixmap(struct torture_suite *suite)
torture_tcase_add_simple_test(tc, "make_attid_small_map", (pfn_run)torture_drs_unit_pfm_make_attid_small_map);
torture_tcase_add_simple_test(tc, "oid_from_attid_full_map", (pfn_run)torture_drs_unit_pfm_oid_from_attid);
+ torture_tcase_add_simple_test(tc, "pfm_to_from_drsuapi", (pfn_run)torture_drs_unit_pfm_to_from_drsuapi);
+
return tc;
}