ctdb-daemon: Consolidate basic CTDB context initialisation
[samba.git] / testprogs / blackbox / common-links.sh
1 release_dir=`dirname $0`/../../source4/selftest/provisions/$RELEASE
2
3 ldbadd="ldbadd"
4 if [ -x "$BINDIR/ldbadd" ]; then
5     ldbadd="$BINDIR/ldbadd"
6 fi
7
8 ldbmodify="ldbmodify"
9 if [ -x "$BINDIR/ldbmodify" ]; then
10     ldbmodify="$BINDIR/ldbmodify"
11 fi
12
13 ldbdel="ldbdel"
14 if [ -x "$BINDIR/ldbdel" ]; then
15     ldbdel="$BINDIR/ldbdel"
16 fi
17
18 ldbsearch="ldbsearch"
19 if [ -x "$BINDIR/ldbsearch" ]; then
20     ldbsearch="$BINDIR/ldbsearch"
21 fi
22
23 ldbrename="ldbrename"
24 if [ -x "$BINDIR/ldbrename" ]; then
25     ldbrename="$BINDIR/ldbrename"
26 fi
27
28 undump() {
29        if test -x $BINDIR/tdbrestore;
30        then
31         `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE $BINDIR/tdbrestore
32        else
33         `dirname $0`/../../source4/selftest/provisions/undump.sh $release_dir $PREFIX_ABS/$RELEASE
34        fi
35 }
36
37 add_dangling_link() {
38     ldif=$release_dir/add-dangling-forwardlink-user.ldif
39     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
40     if [ "$?" != "0" ]; then
41         return 1
42     fi
43
44     ldif=$release_dir/add-initially-normal-link.ldif
45     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
46     if [ "$?" != "0" ]; then
47         return 1
48     fi
49
50     ldif=$release_dir/delete-only-backlink.ldif
51     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
52     if [ "$?" != "0" ]; then
53         return 1
54     fi
55 }
56
57 add_dangling_backlink() {
58     ldif=$release_dir/add-dangling-backlink-user.ldif
59     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
60     if [ "$?" != "0" ]; then
61         return 1
62     fi
63
64     ldif=$release_dir/add-dangling-backlink.ldif
65     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
66     if [ "$?" != "0" ]; then
67         return 1
68     fi
69 }
70
71 add_deleted_dangling_backlink() {
72     ldif=$release_dir/add-deleted-backlink-user.ldif
73     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
74     if [ "$?" != "0" ]; then
75         return 1
76     fi
77
78     ldif=$release_dir/add-deleted-backlink.ldif
79     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
80     if [ "$?" != "0" ]; then
81         return 1
82     fi
83 }
84
85 add_deleted_target_backlink() {
86     ldif=$release_dir/add-deleted-target-backlink-user.ldif
87     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
88     if [ "$?" != "0" ]; then
89         return 1
90     fi
91
92     ldif=$release_dir/add-deleted-target-backlink.ldif
93     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
94     if [ "$?" != "0" ]; then
95         return 1
96     fi
97 }
98
99 revive_links_on_deleted_group() {
100     ldif=$release_dir/revive-links-on-deleted-group.ldif
101     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
102     if [ "$?" != "0" ]; then
103         return 1
104     fi
105 }
106
107 revive_backlink_on_deleted_group() {
108     ldif=$release_dir/revive-backlink-on-deleted-group.ldif
109     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
110     if [ "$?" != "0" ]; then
111         return 1
112     fi
113 }
114
115 add_deleted_target_link() {
116     ldif=$release_dir/add-dangling-deleted-link.ldif
117     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
118     if [ "$?" != "0" ]; then
119         return 1
120     fi
121 }
122
123 add_two_more_users() {
124     ldif=$release_dir/add-two-more-users.ldif
125     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
126     if [ "$?" != "0" ]; then
127         return 1
128     fi
129 }
130
131 add_four_more_links() {
132     ldif=$release_dir/add-four-more-links.ldif
133     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
134     if [ "$?" != "0" ]; then
135         return 1
136     fi
137 }
138
139 remove_one_link() {
140     ldif=$release_dir/remove-one-more-link.ldif
141     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
142     if [ "$?" != "0" ]; then
143         return 1
144     fi
145 }
146
147 remove_one_user() {
148     ldif=$release_dir/remove-one-more-user.ldif
149     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
150     if [ "$?" != "0" ]; then
151         return 1
152     fi
153 }
154
155 move_one_user() {
156     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'
157     if [ "$?" != "0" ]; then
158         return 1
159     fi
160 }
161
162 dangling_one_way_dn() {
163     ldif=$release_dir/dangling-one-way-dn.ldif
164     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
165     if [ "$?" != "0" ]; then
166         return 1
167     fi
168 }
169
170 deleted_one_way_dn() {
171     ldif=$release_dir/deleted-one-way-dn.ldif
172     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
173     if [ "$?" != "0" ]; then
174         return 1
175     fi
176 }
177
178 dangling_one_way_link() {
179     ldif=$release_dir/dangling-one-way-link.ldif
180     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
181     if [ "$?" != "0" ]; then
182         return 1
183     fi
184 }
185
186 add_dangling_multi_valued() {
187     # multi1 - All 4 backlinks
188     # multi2 - Missing all 4 backlinks
189     # multi3 - Missing 2 backlinks
190     # Administrator - Has 2 too many backlinks
191     # multi5 - Has 2 backlinks but no forward links
192     ldif=$release_dir/add-dangling-multilink-users.ldif
193     TZ=UTC $ldbadd -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
194     if [ "$?" != "0" ]; then
195         return 1
196     fi
197
198     ldif=$release_dir/add-initially-normal-multilink.ldif
199     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb $ldif
200     if [ "$?" != "0" ]; then
201         return 1
202     fi
203
204     ldif=$release_dir/delete-only-multi-backlink.ldif
205     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
206     if [ "$?" != "0" ]; then
207         return 1
208     fi
209
210     ldif=$release_dir/add-dangling-multi-backlink.ldif
211     TZ=UTC $ldbmodify -H tdb://$PREFIX_ABS/${RELEASE}/private/sam.ldb.d/DC%3DRELEASE-4-5-0-PRE1,DC%3DSAMBA,DC%3DCORP.ldb $ldif
212     if [ "$?" != "0" ]; then
213         return 1
214     fi
215 }