1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-22 02:50:28 +03:00

r17302: Testing!

This confirms that records are replicated into the correct databases,
and that the case insensitive flags really work.

Andrew Bartlett
(This used to be commit ad463c1a5243019548bdbeea3070ec2e6cbcfcdf)
This commit is contained in:
Andrew Bartlett 2006-07-29 01:52:15 +00:00 committed by Gerald (Jerry) Carter
parent 09b861f45b
commit cfa762ff87
3 changed files with 62 additions and 7 deletions

View File

@ -128,7 +128,7 @@ static int partition_search_callback(struct ldb_context *ldb, void *context, str
struct partition_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
ldb_set_errstring(ldb, talloc_asprintf(ldb, "partition_search_callback: NULL Context or Result in 'search' callback"));
goto error;
}
@ -157,14 +157,16 @@ static int partition_other_callback(struct ldb_context *ldb, void *context, stru
{
struct partition_context *ac;
if (!context || !ares) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
if (!context) {
ldb_set_errstring(ldb, talloc_asprintf(ldb, "partition_other_callback: NULL Context in 'other' callback"));
goto error;
}
ac = talloc_get_type(context, struct partition_context);
if (ares->type == LDB_REPLY_EXTENDED && strcmp(ares->response->oid, LDB_EXTENDED_START_TLS_OID)) {
if (!ares
|| (ares->type == LDB_REPLY_EXTENDED
&& strcmp(ares->response->oid, LDB_EXTENDED_START_TLS_OID))) {
ac->finished_requests++;
if (ac->finished_requests == ac->num_requests) {
return ac->orig_req->callback(ldb, ac->orig_req->context, ares);
@ -621,7 +623,7 @@ static int partition_init(struct ldb_module *module)
}
for (i=0; i < replicate_attributes->num_values; i++) {
data->replicate[i] = ldb_dn_explode(data->replicate[i], replicate_attributes->values[i].data);
data->replicate[i] = ldb_dn_explode(data->replicate, replicate_attributes->values[i].data);
if (!data->replicate[i]) {
ldb_set_errstring(module->ldb,
talloc_asprintf(module, "partition_init: "

View File

@ -92,18 +92,22 @@ partition: cn=SideTest:" + prefix + "testside.ldb
partition: cn=Sub,cn=PartTest:" + prefix + "testsub.ldb
partition: cn=PartTest:" + prefix + "testpartition.ldb
partition: cn=Sub,cn=Sub,cn=PartTest:" + prefix + "testsubsub.ldb
replicateEntries: @SUBCLASSES
replicateEntries: @ATTRIBUTES
replicateEntries: @INDEXLIST
");
}
/* Test the basic operation of the timestamps,objectguid and name_rdn
modules */
function modules_test(ldb)
function modules_test(ldb, parttestldb)
{
println("Running modules tests");
ok = ldb.add("
dn: @ATTRIBUTES
cn: CASE_INSENSITIVE
caseattr: CASE_INSENSITIVE
");
if (!ok) {
@ -111,6 +115,10 @@ caseattr: CASE_INSENSITIVE
assert(ok);
}
/* Confirm that the attributes were replicated */
var res_attrs = parttestldb.search("cn=*", "@ATTRIBUTES", parttestldb.SCOPE_BASE);
assert(res_attrs[0].cn == "CASE_INSENSITIVE");
ok = ldb.add("
dn: cn=x8,cn=PartTest
objectClass: foo
@ -132,6 +140,17 @@ cn: X9
assert(ok);
}
ok = ldb.add("
dn: cn=X9,cn=PartTest
objectClass: foo
x: 9
cn: X9
");
if (ok) {
println("Should have failed to add cn=X9,cn=PartTest");
assert(!ok);
}
var res = ldb.search("x=8", "cn=PartTest", ldb.SCOPE_DEFAULT);
assert(res[0].objectGUID != undefined);
assert(res[0].createTimestamp == undefined);
@ -139,6 +158,14 @@ cn: X9
assert(res[0].name == "x8");
assert(res[0].cn == "x8");
/* Confirm that this ended up in the correct LDB */
var res_otherldb = parttestldb.search("x=8", "cn=PartTest", parttestldb.SCOPE_DEFAULT);
assert(res_otherldb[0].objectGUID != undefined);
assert(res_otherldb[0].createTimestamp == undefined);
assert(res_otherldb[0].whenCreated != undefined);
assert(res_otherldb[0].name == "x8");
assert(res_otherldb[0].cn == "x8");
var attrs = new Array("*", "createTimestamp");
var res2 = ldb.search("x=9", "cn=PartTest", ldb.SCOPE_DEFAULT, attrs);
assert(res2[0].objectGUID != undefined);
@ -238,6 +265,17 @@ caseattr: XZ
assert(ok);
}
ok = ldb.add("
dn: caseattr=xz,cn=PartTest
objectClass: foo
x: Z
caseattr: xz
");
if (ok) {
println("Should have failed to add caseattr=xz,cn=PartTest");
assert(!ok);
}
ok = ldb.add("
dn: caseattr2=XZ,cn=PartTest
objectClass: foo
@ -249,6 +287,17 @@ caseattr2: XZ
assert(ok);
}
ok = ldb.add("
dn: caseattr2=Xz,cn=PartTest
objectClass: foo
x: Z
caseattr2: Xz
");
if (!ok) {
println("Failed to add: " + ldb.errstring());
assert(ok);
}
var resX = ldb.search("caseattr=xz", "cn=parttest", ldb.SCOPE_DEFAULT, attrs);
assert(resX.length == 1);
assert(resX[0].objectGUID != undefined);
@ -315,7 +364,11 @@ ldb = ldb_init();
var ok = ldb.connect("tdb://" + prefix + dbfile);
assert(ok);
modules_test(ldb);
parttestldb = ldb_init();
var ok = parttestldb.connect("tdb://" + prefix + "testpartition.ldb");
assert(ok);
modules_test(ldb, parttestldb);
sys.unlink(prefix + dbfile);
sys.unlink(prefix + "testpartition.ldb");