1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

selftest: Split out creation of complex (often invalid) links

This will allow us to test other run-time behaviour with broken
databases.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Andrew Bartlett 2017-10-31 08:23:39 +13:00 committed by Stefan Metzmacher
parent b99d2ee122
commit 25ae8d72d6
2 changed files with 200 additions and 199 deletions

View File

@ -0,0 +1,199 @@
release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
ldbadd="ldbadd"
if [ -x "$BINDIR/ldbadd" ]; then
ldbadd="$BINDIR/ldbadd"
fi
ldbmodify="ldbmodify"
if [ -x "$BINDIR/ldbmodify" ]; then
ldbmodify="$BINDIR/ldbmodify"
fi
ldbdel="ldbdel"
if [ -x "$BINDIR/ldbdel" ]; then
ldbdel="$BINDIR/ldbdel"
fi
ldbsearch="ldbsearch"
if [ -x "$BINDIR/ldbsearch" ]; then
ldbsearch="$BINDIR/ldbsearch"
fi
ldbrename="ldbrename"
if [ -x "$BINDIR/ldbrename" ]; then
ldbrename="$BINDIR/ldbrename"
fi
undump() {
if test -x $BINDIR/tdbrestore;
then
`dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
else
`dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
fi
}
add_dangling_link() {
ldif=$release_dir/add-dangling-forwardlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-initially-normal-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/delete-only-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_dangling_backlink() {
ldif=$release_dir/add-dangling-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-dangling-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_dangling_backlink() {
ldif=$release_dir/add-deleted-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-deleted-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_target_backlink() {
ldif=$release_dir/add-deleted-target-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-deleted-target-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_target_link() {
ldif=$release_dir/add-dangling-deleted-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_two_more_users() {
ldif=$release_dir/add-two-more-users.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_four_more_links() {
ldif=$release_dir/add-four-more-links.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
remove_one_link() {
ldif=$release_dir/remove-one-more-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
remove_one_user() {
ldif=$release_dir/remove-one-more-user.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
move_one_user() {
TZ=UTC $ldbrename -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'cn=user1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' 'cn=user1x,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
if [ "$?" != "0" ]; then
return 1
fi
}
dangling_one_way_dn() {
ldif=$release_dir/dangling-one-way-dn.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
deleted_one_way_dn() {
ldif=$release_dir/deleted-one-way-dn.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
dangling_one_way_link() {
ldif=$release_dir/dangling-one-way-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/CN%3DCONFIGURATION,DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_dangling_multi_valued() {
# multi1 - All 4 backlinks
# multi2 - Missing all 4 backlinks
# multi3 - Missing 2 backlinks
# Administrator - Has 2 too many backlinks
# multi5 - Has 2 backlinks but no forward links
ldif=$release_dir/add-dangling-multilink-users.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-initially-normal-multilink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/delete-only-multi-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-dangling-multi-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}

View File

@ -13,41 +13,7 @@ shift 2
. `dirname $0`/subunit.sh
release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
ldbadd="ldbadd"
if [ -x "$BINDIR/ldbadd" ]; then
ldbadd="$BINDIR/ldbadd"
fi
ldbmodify="ldbmodify"
if [ -x "$BINDIR/ldbmodify" ]; then
ldbmodify="$BINDIR/ldbmodify"
fi
ldbdel="ldbdel"
if [ -x "$BINDIR/ldbdel" ]; then
ldbdel="$BINDIR/ldbdel"
fi
ldbsearch="ldbsearch"
if [ -x "$BINDIR/ldbsearch" ]; then
ldbsearch="$BINDIR/ldbsearch"
fi
ldbrename="ldbrename"
if [ -x "$BINDIR/ldbrename" ]; then
ldbrename="$BINDIR/ldbrename"
fi
undump() {
if test -x $BINDIR/tdbrestore;
then
`dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
else
`dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
fi
}
. `dirname $0`/common-links.sh
dbcheck() {
tmpfile=$PREFIX_ABS/$RELEASE/expected-dbcheck-link-output${1}.txt.tmp
@ -103,115 +69,6 @@ dbcheck_clean() {
fi
}
add_dangling_link() {
ldif=$release_dir/add-dangling-forwardlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-initially-normal-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/delete-only-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_dangling_backlink() {
ldif=$release_dir/add-dangling-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-dangling-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_dangling_backlink() {
ldif=$release_dir/add-deleted-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-deleted-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_target_backlink() {
ldif=$release_dir/add-deleted-target-backlink-user.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-deleted-target-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_deleted_target_link() {
ldif=$release_dir/add-dangling-deleted-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_two_more_users() {
ldif=$release_dir/add-two-more-users.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_four_more_links() {
ldif=$release_dir/add-four-more-links.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
remove_one_link() {
ldif=$release_dir/remove-one-more-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
remove_one_user() {
ldif=$release_dir/remove-one-more-user.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
move_one_user() {
TZ=UTC $ldbrename -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb 'cn=user1,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp' 'cn=user1x,cn=users,DC=release-4-5-0-pre1,DC=samba,DC=corp'
if [ "$?" != "0" ]; then
return 1
fi
}
check_expected_after_links() {
tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-link-dbcheck.ldif.tmp
TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(cn=swimmers)(cn=leaders)(cn=helpers))' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --sorted member > $tmpldif
@ -239,61 +96,6 @@ check_expected_after_objects() {
fi
}
dangling_one_way_dn() {
ldif=$release_dir/dangling-one-way-dn.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
deleted_one_way_dn() {
ldif=$release_dir/deleted-one-way-dn.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
dangling_one_way_link() {
ldif=$release_dir/dangling-one-way-link.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/CN%3DCONFIGURATION,DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
add_dangling_multi_valued() {
# multi1 - All 4 backlinks
# multi2 - Missing all 4 backlinks
# multi3 - Missing 2 backlinks
# Administrator - Has 2 too many backlinks
# multi5 - Has 2 backlinks but no forward links
ldif=$release_dir/add-dangling-multilink-users.ldif
TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-initially-normal-multilink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/delete-only-multi-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
ldif=$release_dir/add-dangling-multi-backlink.ldif
TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
if [ "$?" != "0" ]; then
return 1
fi
}
dbcheck_dangling_multi_valued() {
$PYTHON $BINDIR/samba-tool dbcheck -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --fix --yes