[SCM] Samba Shared Repository - branch master updated

Kamen Mazdrashki kamenim at samba.org
Wed Apr 28 19:55:27 MDT 2010


The branch, master has been updated
       via  5a4ee75... s4/tort: Add simple unit test for dsdb_schema_info object creation
       via  59830d0... s4/dsdb: schemaInfo revision may be 0
       via  a843801... s4/dsdb: remove unused dsdb_schema_info_create() function
       via  2264d91... s4/dsdb: Update Schema cache with updated schemaInfo value
       via  e41eac9... s4/samldb: Create initial schemaInfo value if it doesn't exists yet
       via  546a727... s4/dsdb: Use default schemaInfo value when no such value is given
       via  da127d4... s4/test: schemaInfo may not to be set yet
       via  5bf12e1... Revert "s4/dsdb: Set schemaInfo attribute value during provisioning"
      from  2bf2373... idl: we only need ndr_rap.[ch] and rap.h

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5a4ee75289e8394ea2f2de0b0415ed7f7ee54575
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Sat Apr 24 01:21:15 2010 +0300

    s4/tort: Add simple unit test for dsdb_schema_info object creation

commit 59830d0a6effa6509eae384f08cf3df32cd53359
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Apr 23 16:35:21 2010 +0300

    s4/dsdb: schemaInfo revision may be 0
    
    In case schemaInfo value is still not set, WinAD supplies
    schemaInfo blob with revision = 0 and GUID_ZERO

commit a8438015cae6d426bf140feffec46e129688ec8e
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Fri Apr 23 15:37:10 2010 +0300

    s4/dsdb: remove unused dsdb_schema_info_create() function

commit 2264d917ae626d6f2d8f5d2c128a4a95a4066665
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Apr 22 18:11:39 2010 +0300

    s4/dsdb: Update Schema cache with updated schemaInfo value
    
    Error checking is simplified and my leave leeks.
    I did it this way to make code more readable, and if we
    get error in those lines, it will be WERR_NOMEM in which
    case we are in a much deeper troubles than delayed freeing
    of few bytes.

commit e41eac96afb1d6d465faeb1e4e9a669cff1b8bc1
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Apr 22 17:59:22 2010 +0300

    s4/samldb: Create initial schemaInfo value if it doesn't exists yet

commit 546a727bd326464c6fac3c6454e4e98314e0e75a
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Apr 22 17:24:15 2010 +0300

    s4/dsdb: Use default schemaInfo value when no such value is given
    
    Having no value for schemaInfo is totally OK as it turns out.
    In such cases, we should use a default value with
    all fields set to 0.

commit da127d44e31306b4865e682be362fd9672d8201f
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Apr 22 04:39:04 2010 +0300

    s4/test: schemaInfo may not to be set yet
    
    On newly provisioned Forest schemaInfo is not initially set.
    It should be created after firs Schema modification

commit 5bf12e101aa729619758c38af5c682b2cd06ea70
Author: Kamen Mazdrashki <kamenim at samba.org>
Date:   Thu Apr 22 02:55:03 2010 +0300

    Revert "s4/dsdb: Set schemaInfo attribute value during provisioning"
    
    This reverts commit 8149094eddebd9a0e8b7c123c2ed54d00164bb26.
    
    Windows implementation does not set schemaInfo attribute value
    until first Schema update request.
    This way, newly provisioned forest returns no schemaInfo value.
    
    I think it won't be bad for us to have this value preset, but
    I want to mimic Win AD behavior as close as possible.

-----------------------------------------------------------------------

Summary of changes:
 source4/dsdb/schema/schema_info_attr.c           |  162 ++++++++-------------
 source4/dsdb/schema/schema_init.c                |   14 +--
 source4/dsdb/schema/schema_set.c                 |    5 +-
 source4/lib/ldb/tests/python/dsdb_schema_info.py |   22 ++-
 source4/scripting/python/pyglue.c                |   26 ----
 source4/scripting/python/samba/__init__.py       |    3 -
 source4/scripting/python/samba/provision.py      |    2 -
 source4/torture/drs/unit/schemainfo_tests.c      |   89 ++++++------
 8 files changed, 125 insertions(+), 198 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/dsdb/schema/schema_info_attr.c b/source4/dsdb/schema/schema_info_attr.c
index 132c72a..ac22eb9 100644
--- a/source4/dsdb/schema/schema_info_attr.c
+++ b/source4/dsdb/schema/schema_info_attr.c
@@ -30,6 +30,46 @@
 
 
 /**
+ * Creates and initializes new dsdb_schema_info value.
+ * Initial schemaInfo values is with:
+ *   revision = 0
+ *   invocationId = GUID_ZERO
+ */
+WERROR dsdb_schema_info_new(TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info)
+{
+	struct dsdb_schema_info *schema_info;
+
+	schema_info = talloc_zero(mem_ctx, struct dsdb_schema_info);
+	W_ERROR_HAVE_NO_MEMORY(schema_info);
+
+	*_schema_info = schema_info;
+
+	return WERR_OK;
+}
+
+/**
+ * Creates and initializes new dsdb_schema_info blob value.
+ * Initial schemaInfo values is with:
+ *   revision = 0
+ *   invocationId = GUID_ZERO
+ */
+WERROR dsdb_schema_info_blob_new(TALLOC_CTX *mem_ctx, DATA_BLOB *_schema_info_blob)
+{
+	DATA_BLOB blob;
+
+	blob = data_blob_talloc_zero(mem_ctx, 21);
+	W_ERROR_HAVE_NO_MEMORY(blob.data);
+
+	/* Set the schemaInfo marker to 0xFF */
+	blob.data[0] = 0xFF;
+
+	*_schema_info_blob = blob;
+
+	return WERR_OK;
+}
+
+
+/**
  * Parse schemaInfo structure from a data_blob
  * (DATA_BLOB or ldb_val).
  * Suitable for parsing blobs that comes from
@@ -95,10 +135,6 @@ WERROR dsdb_blob_from_schema_info(const struct dsdb_schema_info *schema_info,
 	enum ndr_err_code ndr_err;
 	struct schemaInfoBlob schema_info_blob;
 
-	if (schema_info->revision < 1) {
-		return WERR_INVALID_PARAMETER;
-	}
-
 	schema_info_blob.marker		= 0xFF;
 	schema_info_blob.revision	= schema_info->revision;
 	schema_info_blob.invocation_id  = schema_info->invocation_id;
@@ -169,7 +205,7 @@ WERROR dsdb_module_schema_info_blob_read(struct ldb_module *ldb_module,
 }
 
 /**
- * Pepares ldb_msg to be used for updating schemaInfo value in DB
+ * Prepares ldb_msg to be used for updating schemaInfo value in DB
  */
 static WERROR _dsdb_schema_info_write_prepare(struct ldb_context *ldb,
 					      DATA_BLOB *schema_info_blob,
@@ -317,90 +353,6 @@ static WERROR dsdb_module_schema_info_write(struct ldb_module *ldb_module,
 
 
 /**
- * Creates new dsdb_schema_info object using
- * invocationId from supplied ldb
- * @param check_invocation_id Error out if invocationId is not yet set
- */
-WERROR dsdb_schema_info_create(struct ldb_context *ldb, bool check_invocation_id,
-			       TALLOC_CTX *mem_ctx, struct dsdb_schema_info **_schema_info)
-{
-	const struct GUID *invocation_id;
-	struct dsdb_schema_info *schema_info;
-
-	/* try to determine invocationId from ldb */
-	invocation_id = samdb_ntds_invocation_id(ldb);
-	if (check_invocation_id && !invocation_id) {
-		return WERR_INTERNAL_DB_CORRUPTION;
-	}
-
-	schema_info = talloc(mem_ctx, struct dsdb_schema_info);
-	if (!schema_info) {
-		return WERR_NOMEM;
-	}
-
-	schema_info->revision = 1;
-	if (invocation_id) {
-		schema_info->invocation_id = *invocation_id;
-	} else {
-		schema_info->invocation_id = GUID_zero();
-	}
-
-	*_schema_info = schema_info;
-
-	return WERR_OK;
-}
-
-
-/**
- *
- * @param ldb
- * @param schema
- * @return
- */
-WERROR dsdb_schema_info_reset(struct ldb_context *ldb, struct dsdb_schema *schema)
-{
-	int ldb_err;
-	WERROR werr;
-	DATA_BLOB blob;
-	struct dsdb_schema_info *schema_info;
-	struct ldb_message *msg;
-	TALLOC_CTX *temp_ctx;
-
-	temp_ctx = talloc_new(ldb);
-	W_ERROR_HAVE_NO_MEMORY(temp_ctx);
-
-	/* create default schemaInfo value */
-	werr = dsdb_schema_info_create(ldb, true, temp_ctx, &schema_info);
-	W_ERROR_NOT_OK_GOTO(werr, DONE);
-
-	/* serialize schemaInfo to be stored in LDB and schema cache */
-	werr = dsdb_blob_from_schema_info(schema_info, temp_ctx, &blob);
-	W_ERROR_NOT_OK_GOTO(werr, DONE);
-
-	/* store initial schemaInfo in DB */
-	werr = _dsdb_schema_info_write_prepare(ldb, &blob, temp_ctx, &msg);
-	W_ERROR_NOT_OK_GOTO(werr, DONE);
-
-	ldb_err = dsdb_modify(ldb, msg, 0);
-	if (ldb_err != 0) {
-		DEBUG(0,("dsdb_module_schema_info_blob_write: dsdb_replace failed: %s (%s)\n",
-			 ldb_strerror(ldb_err),
-			 ldb_errstring(ldb)));
-		werr = WERR_INTERNAL_DB_ERROR;
-		goto DONE;
-	}
-
-	/* update dsdb_schema cache */
-	talloc_free(discard_const(schema->schema_info));
-	schema->schema_info = data_blob_hex_string_upper(schema, &blob);
-
-DONE:
-	talloc_free(temp_ctx);
-	return werr;
-}
-
-
-/**
  * Increments schemaInfo revision and save it to DB
  * setting our invocationID in the process
  * NOTE: this function should be called in a transaction
@@ -416,22 +368,29 @@ WERROR dsdb_module_schema_info_update(struct ldb_module *ldb_module,
 {
 	WERROR werr;
 	const struct GUID *invocation_id;
+	DATA_BLOB ndr_blob;
 	struct dsdb_schema_info *schema_info;
+	const char *schema_info_str;
 
-	TALLOC_CTX *mem_ctx = talloc_new(schema);
-	W_ERROR_HAVE_NO_MEMORY(mem_ctx);
+	TALLOC_CTX *temp_ctx = talloc_new(schema);
+	W_ERROR_HAVE_NO_MEMORY(temp_ctx);
 
 	invocation_id = samdb_ntds_invocation_id(ldb_module_get_ctx(ldb_module));
 	if (!invocation_id) {
 		return WERR_INTERNAL_DB_CORRUPTION;
 	}
 
-	werr = dsdb_module_schema_info_read(ldb_module, dsdb_flags,
-	                                    mem_ctx, &schema_info);
+	/* read serialized schemaInfo from LDB  */
+	werr = dsdb_module_schema_info_read(ldb_module, dsdb_flags, temp_ctx, &schema_info);
+	if (W_ERROR_EQUAL(werr, WERR_DS_NO_ATTRIBUTE_OR_VALUE)) {
+		/* make default value in case
+		 * we have no schemaInfo value yet */
+		werr = dsdb_schema_info_new(temp_ctx, &schema_info);
+	}
 	if (!W_ERROR_IS_OK(werr)) {
 		DEBUG(0,("dsdb_module_schema_info_update: failed to reload schemaInfo - %s\n",
 			 win_errstr(werr)));
-		talloc_free(mem_ctx);
+		talloc_free(temp_ctx);
 		return werr;
 	}
 
@@ -443,17 +402,20 @@ WERROR dsdb_module_schema_info_update(struct ldb_module *ldb_module,
 	if (!W_ERROR_IS_OK(werr)) {
 		DEBUG(0,("dsdb_module_schema_info_update: failed to save schemaInfo - %s\n",
 			 win_errstr(werr)));
-		talloc_free(mem_ctx);
+		talloc_free(temp_ctx);
 		return werr;
 	}
 
 	/* finally, update schema_info in the cache */
-	/* TODO: update schema_info in dsdb_schema cache */
-/*
+	werr = dsdb_blob_from_schema_info(schema_info, temp_ctx, &ndr_blob);
+	W_ERROR_NOT_OK_RETURN(werr);
+
+	schema_info_str = hex_encode_talloc(schema, ndr_blob.data, ndr_blob.length);
+	W_ERROR_HAVE_NO_MEMORY(schema_info_str);
+
 	talloc_unlink(schema, discard_const(schema->schema_info));
-	schema->schema_info = talloc_steal(schema, schema_info);
-*/
+	schema->schema_info = schema_info_str;
 
-	talloc_free(mem_ctx);
+	talloc_free(temp_ctx);
 	return WERR_OK;
 }
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 3405e15..cdd37f0 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -734,20 +734,10 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
 	}
 	info_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "schemaInfo");
 	if (!info_val) {
-		struct dsdb_schema_info *schema_info;
-
-		status = dsdb_schema_info_create(ldb, false, mem_ctx, &schema_info);
-		if (!W_ERROR_IS_OK(status)) {
-			*error_string = talloc_asprintf(mem_ctx,
-			                                "schema_fsmo_init: dsdb_schema_info_create() failed - %s",
-			                                win_errstr(status));
-			DEBUG(0,(__location__ ": %s\n", *error_string));
-			return LDB_ERR_OPERATIONS_ERROR;
-		}
-		status = dsdb_blob_from_schema_info(schema_info, mem_ctx, &info_val_default);
+		status = dsdb_schema_info_blob_new(mem_ctx, &info_val_default);
 		if (!W_ERROR_IS_OK(status)) {
 			*error_string = talloc_asprintf(mem_ctx,
-			                                "schema_fsmo_init: dsdb_blob_from_schema_info() failed - %s",
+			                                "schema_fsmo_init: dsdb_schema_info_blob_new() failed - %s",
 			                                win_errstr(status));
 			DEBUG(0,(__location__ ": %s\n", *error_string));
 			return LDB_ERR_OPERATIONS_ERROR;
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index f0c3c06..fe6ef42 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -582,7 +582,6 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
 	const struct ldb_val *prefix_val;
 	const struct ldb_val *info_val;
 	struct ldb_val info_val_default;
-	struct dsdb_schema_info *schema_info;
 
 
 	mem_ctx = talloc_new(ldb);
@@ -623,9 +622,7 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
 
 	info_val = ldb_msg_find_ldb_val(msg, "schemaInfo");
 	if (!info_val) {
-		status = dsdb_schema_info_create(ldb, false, mem_ctx, &schema_info);
-		W_ERROR_NOT_OK_GOTO(status, failed);
-		status = dsdb_blob_from_schema_info(schema_info, mem_ctx, &info_val_default);
+		status = dsdb_schema_info_blob_new(mem_ctx, &info_val_default);
 		W_ERROR_NOT_OK_GOTO(status, failed);
 		info_val = &info_val_default;
 	}
diff --git a/source4/lib/ldb/tests/python/dsdb_schema_info.py b/source4/lib/ldb/tests/python/dsdb_schema_info.py
index 5fd0ccb..f0c8c14 100755
--- a/source4/lib/ldb/tests/python/dsdb_schema_info.py
+++ b/source4/lib/ldb/tests/python/dsdb_schema_info.py
@@ -62,18 +62,26 @@ class SchemaInfoTestCase(samba.tests.RpcInterfaceTestCase):
         # get DC invocation_id
         self.invocation_id = GUID(ldb.get_invocation_id())
 
+
     def tearDown(self):
         super(SchemaInfoTestCase, self).tearDown()
 
 
     def _getSchemaInfo(self):
-        schema_info_data = ldb.searchone(attribute="schemaInfo",
-                                         basedn=self.schema_dn,
-                                         expression="(objectClass=*)",
-                                         scope=SCOPE_BASE)
-        self.assertEqual(len(schema_info_data), 21)
-        schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
-        self.assertEqual(schema_info.marker, 0xFF)
+        try:
+            schema_info_data = ldb.searchone(attribute="schemaInfo",
+                                             basedn=self.schema_dn,
+                                             expression="(objectClass=*)",
+                                             scope=SCOPE_BASE)
+            self.assertEqual(len(schema_info_data), 21)
+            schema_info = ndr_unpack(schemaInfoBlob, schema_info_data)
+            self.assertEqual(schema_info.marker, 0xFF)
+        except KeyError:
+            # create default schemaInfo if
+            # attribute value is not created yet
+            schema_info = schemaInfoBlob()
+            schema_info.revision = 0
+            schema_info.invocation_id = self.invocation_id
         return schema_info
 
     def _checkSchemaInfo(self, schi_before, schi_after):
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index a80dedc..f085714 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -159,30 +159,6 @@ static PyObject *py_dsdb_write_prefixes_from_schema_to_ldb(PyObject *self, PyObj
 	Py_RETURN_NONE;
 }
 
-static PyObject *py_dsdb_schema_info_reset(PyObject *self, PyObject *args)
-{
-	PyObject *py_ldb;
-	struct ldb_context *ldb;
-	WERROR result;
-	struct dsdb_schema *schema;
-
-	if (!PyArg_ParseTuple(args, "O", &py_ldb))
-		return NULL;
-
-	PyErr_LDB_OR_RAISE(py_ldb, ldb);
-
-	schema = dsdb_get_schema(ldb, NULL);
-	if (!schema) {
-		PyErr_SetString(PyExc_RuntimeError, "Failed to set find a schema on ldb!\n");
-		return NULL;
-	}
-
-	result = dsdb_schema_info_reset(ldb, schema);
-	PyErr_WERROR_IS_ERR_RAISE(result);
-
-	Py_RETURN_NONE;
-}
-
 static PyObject *py_dsdb_set_schema_from_ldb(PyObject *self, PyObject *args)
 {
 	PyObject *py_ldb;
@@ -277,8 +253,6 @@ static PyMethodDef py_misc_methods[] = {
 		NULL },
 	{ "dsdb_write_prefixes_from_schema_to_ldb", (PyCFunction)py_dsdb_write_prefixes_from_schema_to_ldb, METH_VARARGS,
 		NULL },
-	{ "dsdb_schema_info_reset", (PyCFunction)py_dsdb_schema_info_reset, METH_VARARGS,
-		"Reset schemaInfo value to default for a new Forest" },
 	{ "dsdb_set_schema_from_ldb", (PyCFunction)py_dsdb_set_schema_from_ldb, METH_VARARGS,
 		NULL },
 	{ "set_debug_level", (PyCFunction)py_set_debug_level, METH_VARARGS,
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index 67aac86..dcb80a7 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -286,9 +286,6 @@ class Ldb(_Ldb):
     def write_prefixes_from_schema(self):
         _glue.dsdb_write_prefixes_from_schema_to_ldb(self)
 
-    def set_schema_info(self):
-        _glue.dsdb_schema_info_reset(self)
-
     def convert_schema_to_openldap(self, target, mapping):
         return dsdb.dsdb_convert_schema_to_openldap(self, target, mapping)
 
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 8e79a8c..fa2dabe 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -946,8 +946,6 @@ def setup_samdb(path, setup_path, session_info, provision_backend, lp,
         message("Setting up sam.ldb schema")
         samdb.add_ldif(schema.schema_dn_add, controls=["relax:0"])
         samdb.modify_ldif(schema.schema_dn_modify)
-        # set schemaInfo to defalt value for a new Forest
-        samdb.set_schema_info()
         samdb.write_prefixes_from_schema()
         samdb.add_ldif(schema.schema_data, controls=["relax:0"])
         setup_add_ldif(samdb, setup_path("aggregate_schema.ldif"), 
diff --git a/source4/torture/drs/unit/schemainfo_tests.c b/source4/torture/drs/unit/schemainfo_tests.c
index 26e92d5..f197b47 100644
--- a/source4/torture/drs/unit/schemainfo_tests.c
+++ b/source4/torture/drs/unit/schemainfo_tests.c
@@ -33,10 +33,10 @@
 
 /**
  * schemaInfo to init ldb context with
- *   Rev:  01
- *   GUID: 071c82fd-45c7-4351-a3db-51f75a630a7f
+ *   Rev:  0
+ *   GUID: 00000000-0000-0000-0000-000000000000
  */
-#define SCHEMA_INFO_INIT_STR		"FF0000000100000000000000000000000000000000"
+#define SCHEMA_INFO_INIT_STR		"FF0000000000000000000000000000000000000000"
 
 /**
  * Default schema_info string to be used for testing
@@ -66,6 +66,13 @@ static const struct {
 	bool 		test_both_ways;
 } _schemainfo_test_data[] = {
 	{
+		.schema_info_str = "FF0000000000000000000000000000000000000000",
+		.revision = 0,
+		.guid_str = "00000000-0000-0000-0000-000000000000",
+		.werr_expected = WERR_OK,
+		.test_both_ways = true
+	},
+	{
 		.schema_info_str = "FF00000001FD821C07C7455143A3DB51F75A630A7F",
 		.revision = 1,
 		.guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
@@ -79,18 +86,6 @@ static const struct {
 		.werr_expected = WERR_OK,
 		.test_both_ways = true
 	},
-#if 0
-	/* removed until kamen can take a look - revision 0 is sent by
-	 * w2k8r2, and we need to accept it, possibly only when the
-	 * other fields are zero */
-	{ /* revision > 0 */
-		.schema_info_str = "FF00000000FD821C07C7455143A3DB51F75A630A7F",
-		.revision = 0,
-		.guid_str = "071c82fd-45c7-4351-a3db-51f75a630a7f",
-		.werr_expected = WERR_INVALID_PARAMETER,
-		.test_both_ways = true
-	},
-#endif
 	{ /* len == 21 */
 		.schema_info_str = "FF00000001FD821C07C7455143A3DB51F75A630A7F00",
 		.revision = 1,
@@ -191,6 +186,39 @@ bool drsut_schemainfo_new(struct torture_context *tctx, struct dsdb_schema_info
 
 
 /*
+ * Tests dsdb_schema_info_new() and dsdb_schema_info_blob_new()
+ */
+static bool test_dsdb_schema_info_new(struct torture_context *tctx,
+				      struct drsut_schemainfo_data *priv)
+{
+	WERROR werr;
+	DATA_BLOB ndr_blob;
+	DATA_BLOB ndr_blob_expected;
+	struct dsdb_schema_info *schi;
+	TALLOC_CTX *mem_ctx;
+
+	mem_ctx = talloc_new(priv);
+	torture_assert(tctx, mem_ctx, "Not enough memory!");
+	ndr_blob_expected = strhex_to_data_blob(mem_ctx, SCHEMA_INFO_INIT_STR);
+	torture_assert(tctx, ndr_blob_expected.data, "Not enough memory!");
+
+	werr = dsdb_schema_info_new(mem_ctx, &schi);
+	torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_new() failed");
+	torture_assert_int_equal(tctx, schi->revision, 0,
+				 "dsdb_schema_info_new() creates schemaInfo with invalid revision");
+	torture_assert(tctx, GUID_all_zero(&schi->invocation_id),
+			"dsdb_schema_info_new() creates schemaInfo with not ZERO GUID");
+
+	werr = dsdb_schema_info_blob_new(mem_ctx, &ndr_blob);
+	torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_blob_new() failed");
+	torture_assert_data_blob_equal(tctx, ndr_blob, ndr_blob_expected,
+				       "dsdb_schema_info_blob_new() returned invalid blob");
+
+	talloc_free(mem_ctx);
+	return true;
+}
+
+/*
  * Tests dsdb_schema_info_from_blob()
  */
 static bool test_dsdb_schema_info_from_blob(struct torture_context *tctx,
@@ -333,10 +361,6 @@ static bool test_dsdb_module_schema_info_update(struct torture_context *tctx,
 	werr = dsdb_schema_info_from_blob(&blob, priv, &schema_info);
 	torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_from_blob() failed");
 
-	/* decrement revision to be able to compare
-	 * against default schemaInfo later */
-	schema_info->revision--;
-
 	/* check against default schema_info */
 	torture_assert_schema_info_equal(tctx, schema_info, priv->schema_info,
 					  "schemaInfo attribute no updated correctly");
@@ -344,29 +368,6 @@ static bool test_dsdb_module_schema_info_update(struct torture_context *tctx,
 	return true;
 }
 
-/*
- * Tests dsdb_schema_info_create()
- */
-static bool test_dsdb_schema_info_create(struct torture_context *tctx,
-					 struct drsut_schemainfo_data *priv)
-{
-	WERROR werr;
-	struct dsdb_schema_info *schema_info = NULL;
-
-	werr = dsdb_schema_info_create(priv->ldb, true, priv, &schema_info);
-	torture_assert_werr_ok(tctx, werr, "dsdb_schema_info_create() failed");


-- 
Samba Shared Repository


More information about the samba-cvs mailing list