testprogs: Consistantly use kinit -c $KRB5CCNAME
[samba.git] / testprogs / blackbox / functionalprep.sh
1 #!/bin/sh
2
3 if [ $# -lt 1 ]; then
4 cat <<EOF
5 Usage: $0 PREFIX
6 EOF
7 exit 1;
8 fi
9
10 PREFIX_ABS="$1"
11 shift 1
12
13 failed=0
14
15 . `dirname $0`/subunit.sh
16 . `dirname $0`/common_test_fns.inc
17
18 RELEASE="release-4-8-0-pre1"
19 release_dir="$SRCDIR_ABS/source4/selftest/provisions/$RELEASE"
20
21 OLD_RELEASE="release-4-1-0rc3"
22 old_release_dir="$SRCDIR_ABS/source4/selftest/provisions/$OLD_RELEASE"
23
24 samba_tdbrestore="tdbrestore"
25 if [ -x "$BINDIR/tdbrestore" ]; then
26     samba_tdbrestore="$BINDIR/tdbrestore"
27 fi
28
29 samba_undump="$SRCDIR_ABS/source4/selftest/provisions/undump.sh"
30
31 if [ ! -x $samba_undump ] || [ ! -d $release_dir ] || [ ! -d $old_release_dir ]; then
32     subunit_start_test $RELEASE
33     subunit_skip_test $RELEASE <<EOF
34 no test provision
35 EOF
36
37     subunit_start_test "functional_prep"
38     subunit_skip_test "functional_prep" <<EOF
39 no test provision
40 EOF
41
42     subunit_start_test "functional_prep_old"
43     subunit_skip_test "functional_prep_old" <<EOF
44 no test provision
45 EOF
46
47     exit 0
48 fi
49
50 cleanup_output_directories()
51 {
52     remove_directory $PREFIX_ABS/2012R2_schema
53     remove_directory $PREFIX_ABS/$RELEASE
54     remove_directory $PREFIX_ABS/$OLD_RELEASE
55 }
56
57 undump() {
58     $samba_undump $release_dir $PREFIX_ABS/$RELEASE $samba_tdbrestore
59 }
60
61 undump_old() {
62     $samba_undump $old_release_dir $PREFIX_ABS/$OLD_RELEASE $samba_tdbrestore
63 }
64
65
66 PROVISION_OPTS="--use-ntvfs --host-ip6=::1 --host-ip=127.0.0.1"
67
68 provision_2012r2() {
69     $PYTHON $BINDIR/samba-tool domain provision $PROVISION_OPTS --domain=REALM --realm=REALM.COM --targetdir=$PREFIX_ABS/2012R2_schema --base-schema=2012_R2 --host-name=FLPREP
70 }
71
72 ldapcmp_ignore() {
73     # At some point we will need to ignore, but right now, it should be perfect
74     IGNORE_ATTRS=$1
75     $PYTHON $BINDIR/samba-tool ldapcmp tdb://$PREFIX_ABS/$2/private/sam.ldb tdb://$PREFIX_ABS/$3/private/sam.ldb --two --skip-missing-dn --filter msDS-SupportedEncryptionTypes
76 }
77
78 ldapcmp() {
79     # Our functional prep doesn't set these values as they were not provided
80     # These are XML schema based enumerations which are used for claims
81     ldapcmp_ignore "msDS-ClaimPossibleValues" "$RELEASE"  "2012R2_schema"
82 }
83
84 functional_prep() {
85     $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/2012R2_schema/private/sam.ldb --function-level=2012_R2
86 }
87
88 functional_prep_old() {
89     $PYTHON $BINDIR/samba-tool domain functionalprep -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --function-level=2012_R2
90 }
91
92 steal_roles() {
93     # Must steal schema master and infrastructure roles first
94     $PYTHON $BINDIR/samba-tool fsmo seize --role=schema -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
95     $PYTHON $BINDIR/samba-tool fsmo seize --role=infrastructure -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --force
96 }
97
98 schema_upgrade() {
99     $PYTHON $BINDIR/samba-tool domain schemaupgrade -H tdb://$PREFIX_ABS/$OLD_RELEASE/private/sam.ldb --schema=2012_R2
100 }
101
102 # double-check we cleaned up from the last test run
103 cleanup_output_directories
104
105 testit $RELEASE undump || failed=`expr $failed + 1`
106
107 # Provision a DC based on 2012R2 schema
108 testit "provision_2012R2_schema" provision_2012r2 || failed=`expr $failed + 1`
109
110 # Perform functional prep up to 2012 R2 level
111 testit "functional_prep" functional_prep || failed=`expr $failed + 1`
112
113 # check that the databases are now the same
114 testit "check_databases_same" ldapcmp || failed=`expr $failed + 1`
115
116 testit $OLD_RELEASE undump_old || failed=`expr $failed + 1`
117
118 testit "steal_roles" steal_roles || failed=`expr $failed + 1`
119
120 testit "schema_upgrade" schema_upgrade || failed=`expr $failed + 1`
121
122 testit "functional_prep_old" functional_prep_old || failed=`expr $failed + 1`
123
124 cleanup_output_directories
125
126 exit $failed