s3:libsmb: let get_ipc_connect() use CLI_FULL_CONNECTION_FORCE_SMB1
[Samba.git] / testprogs / blackbox / tombstones-expunge.sh
blob3f7d708c8ad3dd8676b3dcd5c71c0536f971c8d2
1 #!/bin/sh
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: tombstones-expunge.sh PREFIX RELEASE
6 EOF
7 exit 1;
8 fi
10 PREFIX_ABS="$1"
11 RELEASE="$2"
12 shift 2
14 . `dirname $0`/subunit.sh
16 release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
18 ldbadd="ldbadd"
19 if [ -x "$BINDIR/ldbadd" ]; then
20 ldbadd="$BINDIR/ldbadd"
23 ldbmodify="ldbmodify"
24 if [ -x "$BINDIR/ldbmodify" ]; then
25 ldbmodify="$BINDIR/ldbmodify"
28 ldbdel="ldbdel"
29 if [ -x "$BINDIR/ldbdel" ]; then
30 ldbdel="$BINDIR/ldbdel"
33 ldbsearch="ldbsearch"
34 if [ -x "$BINDIR/ldbsearch" ]; then
35 ldbsearch="$BINDIR/ldbsearch"
38 undump() {
39 if test -x $BINDIR/tdbrestore;
40 then
41 `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
42 else
43 `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
47 tombstones_expunge() {
48 tmpfile=$PREFIX_ABS/$RELEASE/expected-expunge-output.txt.tmp
49 tmpldif1=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp1
51 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif1
53 $PYTHON $BINDIR/samba-tool domain tombstones expunge -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb --current-time=2016-07-30 --tombstone-lifetime=4 > $tmpfile
54 if [ "$?" != "0" ]; then
55 return 1
57 diff $tmpfile $release_dir/expected-expunge-output.txt
58 if [ "$?" != "0" ]; then
59 return 1
62 tmpldif2=$PREFIX_ABS/$RELEASE/expected-expunge-output2.txt.tmp2
63 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb -s base -b '' | grep highestCommittedUSN > $tmpldif2
65 diff $tmpldif1 $tmpldif2
66 if [ "$?" != "0" ]; then
67 return 1
71 add_dangling_link() {
72 ldif=$release_dir/add-dangling-link.ldif
73 TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
74 if [ "$?" != "0" ]; then
75 return 1
79 add_two_more_users() {
80 ldif=$release_dir/add-two-more-users.ldif
81 TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
82 if [ "$?" != "0" ]; then
83 return 1
87 add_four_more_links() {
88 ldif=$release_dir/add-four-more-links.ldif
89 TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
90 if [ "$?" != "0" ]; then
91 return 1
95 remove_one_link() {
96 ldif=$release_dir/remove-one-more-link.ldif
97 TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
98 if [ "$?" != "0" ]; then
99 return 1
103 remove_one_user() {
104 ldif=$release_dir/remove-one-more-user.ldif
105 TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
106 if [ "$?" != "0" ]; then
107 return 1
111 check_match_rule_links() {
112 tmpldif=$PREFIX_ABS/$RELEASE/expected-match-rule-links.ldif.tmp
113 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted no_attrs > $tmpldif
114 diff $tmpldif $release_dir/expected-match-rule-links.ldif
115 if [ "$?" != "0" ]; then
116 return 1
120 check_match_rule_links_negative() {
121 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=-131139216000000000)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
124 check_match_rule_links_overflow() {
125 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=18446744073709551617)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
128 check_match_rule_links_null() {
129 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=18446744\073709551617)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
132 check_match_rule_links_hex() {
133 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=abcd)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
136 check_match_rule_links_hex2() {
137 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=0xabcd)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
140 check_match_rule_links_decimal() {
141 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(member:1.3.6.1.4.1.7165.4.5.2:=131139216000000000.00)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted member
144 check_match_rule_links_backlink() {
145 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(memberOf:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted memberOf
148 check_match_rule_links_notlink() {
149 $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(samAccountName:1.3.6.1.4.1.7165.4.5.2:=131139216000000000)' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName
152 check_expected_after_links() {
153 tmpldif=$PREFIX_ABS/$RELEASE/expected-links-after-expunge.ldif.tmp
154 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
155 diff $tmpldif $release_dir/expected-links-after-expunge.ldif
156 if [ "$?" != "0" ]; then
157 return 1
161 check_expected_after_deleted_links() {
162 tmpldif=$PREFIX_ABS/$RELEASE/expected-deleted-links-after-expunge.ldif.tmp
163 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 --reveal --sorted member > $tmpldif
164 diff $tmpldif $release_dir/expected-deleted-links-after-expunge.ldif
165 if [ "$?" != "0" ]; then
166 return 1
170 check_expected_after_objects() {
171 tmpldif=$PREFIX_ABS/$RELEASE/expected-objects-after-expunge.ldif.tmp
172 TZ=UTC $ldbsearch -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb '(|(samaccountname=fred)(samaccountname=ddg)(samaccountname=usg)(samaccountname=user1)(samaccountname=user2))' -s sub -b DC=release-4-5-0-pre1,DC=samba,DC=corp --show-deleted --reveal --sorted samAccountName | grep sAMAccountName > $tmpldif
173 diff $tmpldif $release_dir/expected-objects-after-expunge.ldif
174 if [ "$?" != "0" ]; then
175 return 1
179 if [ -d $release_dir ]; then
180 testit $RELEASE undump
181 testit "add_two_more_users" add_two_more_users
182 testit "add_four_more_links" add_four_more_links
183 testit "add_dangling_link" add_dangling_link
184 testit "remove_one_link" remove_one_link
185 testit "remove_one_user" remove_one_user
186 testit "check_match_rule_links" check_match_rule_links
187 testit_expect_failure "check_match_rule_links_negative" check_match_rule_links_negative
188 testit_expect_failure "check_match_rule_links_overflow" check_match_rule_links_overflow
189 testit_expect_failure "check_match_rule_links_null" check_match_rule_links_null
190 testit_expect_failure "check_match_rule_links_hex" check_match_rule_links_hex
191 testit_expect_failure "check_match_rule_links_hex2" check_match_rule_links_hex2
192 testit_expect_failure "check_match_rule_links_decimal" check_match_rule_links_decimal
193 testit_expect_failure "check_match_rule_links_backlink" check_match_rule_links_backlink
194 testit_expect_failure "check_match_rule_links_notlink" check_match_rule_links_notlink
195 testit "tombstones_expunge" tombstones_expunge
196 testit "check_expected_after_deleted_links" check_expected_after_deleted_links
197 testit "check_expected_after_links" check_expected_after_links
198 testit "check_expected_after_objects" check_expected_after_objects
199 else
200 subunit_start_test $RELEASE
201 subunit_skip_test $RELEASE <<EOF
202 no test provision
205 subunit_start_test "tombstones_expunge"
206 subunit_skip_test "tombstones_expunge" <<EOF
207 no test provision
211 if [ -d $PREFIX_ABS/${RELEASE} ]; then
212 rm -fr $PREFIX_ABS/${RELEASE}
215 exit $failed