add-modify-delete.in revision 1.1.1.2.12.1 1 1.1 elric #!/bin/sh
2 1.1 elric #
3 1.1 elric # Copyright (c) 2006 Kungliga Tekniska Hgskolan
4 1.1 elric # (Royal Institute of Technology, Stockholm, Sweden).
5 1.1 elric # All rights reserved.
6 1.1 elric #
7 1.1 elric # Redistribution and use in source and binary forms, with or without
8 1.1 elric # modification, are permitted provided that the following conditions
9 1.1 elric # are met:
10 1.1 elric #
11 1.1 elric # 1. Redistributions of source code must retain the above copyright
12 1.1 elric # notice, this list of conditions and the following disclaimer.
13 1.1 elric #
14 1.1 elric # 2. Redistributions in binary form must reproduce the above copyright
15 1.1 elric # notice, this list of conditions and the following disclaimer in the
16 1.1 elric # documentation and/or other materials provided with the distribution.
17 1.1 elric #
18 1.1 elric # 3. Neither the name of the Institute nor the names of its contributors
19 1.1 elric # may be used to endorse or promote products derived from this software
20 1.1 elric # without specific prior written permission.
21 1.1 elric #
22 1.1 elric # THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 1.1 elric # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 1.1 elric # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 1.1 elric # ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 1.1 elric # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 1.1 elric # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 1.1 elric # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 1.1 elric # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 1.1 elric # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 1.1 elric # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 1.1 elric # SUCH DAMAGE.
33 1.1 elric #
34 1.1.1.2 elric # Id
35 1.1 elric #
36 1.1 elric
37 1.1 elric srcdir="@srcdir@"
38 1.1 elric objdir="@objdir@"
39 1.1 elric EGREP="@EGREP@"
40 1.1 elric
41 1.1.1.2.12.1 snj default_db_type=@default_db_type@
42 1.1.1.2.12.1 snj db_type=${1:-${default_db_type}}
43 1.1.1.2.12.1 snj
44 1.1 elric # If there is no useful db support compile in, disable test
45 1.1 elric ./have-db || exit 77
46 1.1 elric
47 1.1 elric R=EXAMPLE.ORG
48 1.1 elric
49 1.1 elric kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
50 1.1 elric iproplog="${TESTS_ENVIRONMENT} ../../lib/kadm5/iprop-log"
51 1.1 elric
52 1.1.1.2.12.1 snj KRB5_CONFIG="${objdir}/krb5.conf-${db_type}"
53 1.1 elric export KRB5_CONFIG
54 1.1 elric
55 1.1 elric rm -f current-db*
56 1.1 elric rm -f log.current-db*
57 1.1 elric rm -f out-*
58 1.1 elric rm -f mkey.file*
59 1.1 elric
60 1.1 elric echo init database
61 1.1 elric ${kadmin} \
62 1.1 elric init \
63 1.1 elric --realm-max-ticket-life=1day \
64 1.1 elric --realm-max-renewable-life=1month \
65 1.1 elric EXAMPLE.ORG || exit 1
66 1.1 elric
67 1.1 elric echo test add
68 1.1 elric ${kadmin} add -r --use-defaults foo || exit 1
69 1.1 elric ${kadmin} list '*' > /dev/null || exit 1
70 1.1 elric ${kadmin} list '*' | ${EGREP} '^foo$' > /dev/null || exit 1
71 1.1 elric
72 1.1 elric echo "test add (double)"
73 1.1 elric ${kadmin} add -r --use-defaults foo 2>/dev/null && exit 1
74 1.1 elric
75 1.1 elric echo test rename
76 1.1 elric ${kadmin} rename foo bar
77 1.1 elric ${kadmin} list '*' | ${EGREP} '^foo$' > /dev/null && exit 1
78 1.1 elric ${kadmin} list '*' | ${EGREP} '^bar$' > /dev/null || exit 1
79 1.1 elric
80 1.1 elric echo test delete
81 1.1 elric ${kadmin} delete bar || exit 1
82 1.1 elric ${kadmin} list '*' | ${EGREP} '^bar$' > /dev/null && exit 1
83 1.1 elric
84 1.1 elric echo "test delete (double)"
85 1.1 elric ${kadmin} delete bar 2> /dev/null && exit 1
86 1.1 elric
87 1.1 elric echo "creating sample user"
88 1.1 elric ${kadmin} add -r --use-defaults foo || exit 1
89 1.1 elric ${kadmin} get foo > tempfile || exit 1
90 1.1 elric echo checking principal
91 1.1 elric ${EGREP} " *Principal: foo (at] EXAMPLE.ORG$" tempfile > /dev/null || exit 1
92 1.1 elric echo checking kvno
93 1.1 elric ${EGREP} " *Kvno: 1$" tempfile > /dev/null || exit 1
94 1.1 elric echo checking failed login count
95 1.1 elric ${EGREP} " *Failed login count: 0$" tempfile > /dev/null || exit 1
96 1.1 elric echo checking modifier
97 1.1 elric ${EGREP} " *Modifier: kadmin/admin@EXAMPLE.ORG$" tempfile > /dev/null || exit 1
98 1.1 elric echo checking attributes
99 1.1 elric ${EGREP} " *Attributes: $" tempfile > /dev/null || exit 1
100 1.1 elric echo checking renew time
101 1.1 elric ${EGREP} " *Max renewable life: 1 week$" tempfile > /dev/null || exit 1
102 1.1 elric
103 1.1 elric echo modifing renewable-life
104 1.1 elric ${kadmin} modify --max-renewable-life=2months foo
105 1.1 elric echo checking renew time
106 1.1 elric ${kadmin} get foo > tempfile || exit 1
107 1.1 elric ${EGREP} " *Max renewable life: 2 months$" tempfile > /dev/null || exit 1
108 1.1 elric
109 1.1 elric echo "creating sample server"
110 1.1 elric ${kadmin} add -r --use-defaults host/datan.example.org || exit 1
111 1.1 elric ${kadmin} get host/datan.example.org > tempfile || exit 1
112 1.1 elric echo checking principal
113 1.1 elric ${EGREP} " *Principal: host/datan.example.org@EXAMPLE.ORG$" tempfile > /dev/null || exit 1
114 1.1 elric echo checking kvno
115 1.1 elric ${EGREP} " *Kvno: 1$" tempfile > /dev/null || exit 1
116 1.1 elric
117 1.1 elric echo "iprop-log dump"
118 1.1 elric ${iproplog} dump > /dev/null || exit 1
119 1.1 elric echo "iprop-log last-version"
120 1.1 elric ${iproplog} last-version > /dev/null || exit 1
121 1.1 elric
122 1.1 elric echo "check iprop replay"
123 1.1 elric
124 1.1 elric ${kadmin} dump out-current-db || exit 1
125 1.1 elric sort out-current-db > out-current-db-sort
126 1.1 elric
127 1.1 elric rm -f current-db*
128 1.1 elric
129 1.1 elric echo "replaying"
130 1.1 elric ${iproplog} replay > /dev/null || exit 1
131 1.1 elric
132 1.1 elric ${kadmin} dump out-current-db2 || exit 1
133 1.1 elric sort out-current-db2 > out-current-db2-sort
134 1.1 elric
135 1.1 elric # XXX database should really be the same afterward... :(
136 1.1 elric # cmp out-current-db-sort out-current-db2-sort || exit 1
137 1.1 elric
138 1.1 elric
139 1.1 elric
140 1.1 elric exit 0
141