chiark / gitweb /
keys: Add test script.
[tripe] / keys / tests.at
CommitLineData
8cae2567
MW
1### -*-autotest-*-
2###
3### Test script for key-management
4###
5### (c) 2008 Straylight/Edgeware
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of Trivial IP Encryption (TrIPE).
11###
12### TrIPE is free software; you can redistribute it and/or modify
13### it under the terms of the GNU General Public License as published by
14### the Free Software Foundation; either version 2 of the License, or
15### (at your option) any later version.
16###
17### TrIPE is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU General Public License for more details.
21###
22### You should have received a copy of the GNU General Public License
23### along with TrIPE; if not, write to the Free Software Foundation,
24### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26AT_SETUP([key management])
27AT_KEYWORDS([keys python])
28
29###--------------------------------------------------------------------------
30### Make sure that this has a chance of working.
31
32AT_CHECK([
33 case "$HAVE_PYTHON_TRUE$HAVE_PYCATACOMB_TRUE" in
34 "") ;;
35 *) exit 77 ;;
36 esac
37])
38
39AT_TESTED([curl key catsign rsync])
40
41###--------------------------------------------------------------------------
42### Create the initial environment.
43
44work=$(pwd)
45mkdir alice bob stage dist
46
47cd "$work"/alice
48
49cat <<EOF >tripe-keys.master
50## Distribution parameters.
51base-url = file://$work/dist/
52base-dir = $work/stage/
53upload-hook = rsync -aI --delete $work/stage/ $work/dist/
54
55## Cryptographic parameters.
56kx = ec
57kx-expire = now + 1 year
58sig-fresh = 1 month ago
59sig-expire now + 1 year
60master-keygen-flags =
61
62## Master key integrity.
63master-sequence = @MASTER-SEQUENCE@
64hk-master = @HK-MASTER@
65EOF
66
67###--------------------------------------------------------------------------
68### Simple key establishment.
69
70## Alice sets up her repository and generates a key.
71AT_CHECK([BUILDDIR/tripe-keys setup && test -d repos],, [ignore])
72AT_CHECK([BUILDDIR/tripe-keys generate alice],, [ignore])
73AT_CHECK([test -r peer-alice.pub])
74cp peer-alice.pub repos/
75AT_CHECK([BUILDDIR/tripe-keys rebuild],, [ignore])
76AT_CHECK([BUILDDIR/tripe-keys upload],, [ignore])
77
78## Bob fetches a copy and generates his own key.
79cd "$work"/bob
80AT_CHECK([test -r "$work"/dist/tripe-keys.conf])
81cp "$work"/dist/tripe-keys.conf .
82AT_CHECK([BUILDDIR/tripe-keys update],, [ignore])
83AT_CHECK([BUILDDIR/tripe-keys generate bob],, [ignore])
84AT_CHECK([test -r peer-bob.pub])
85
86## Alice collects Bob's key and installs it.
87cd "$work/alice"
88cp "$work"/bob/peer-bob.pub repos/
89AT_CHECK([BUILDDIR/tripe-keys rebuild],, [ignore])
90AT_CHECK([BUILDDIR/tripe-keys upload],, [ignore])
91
92## Bob fetches the new update and checks that his key's there.
93cd "$work"/bob
94AT_CHECK([BUILDDIR/tripe-keys update],, [ignore])
95AT_CHECK([cmp peer-bob.pub repos/peer-bob.pub])
96
97###--------------------------------------------------------------------------
98### Alice rolls over her master key.
99
100## Alice generates a new master key and publishes it.
101cd "$work"/alice
102AT_CHECK([BUILDDIR/tripe-keys newmaster],, [ignore])
103AT_CHECK([BUILDDIR/tripe-keys upload],, [ignore])
104
105cd "$work"/dist
106AT_CHECK([test -r tripe-keys.sig-0 && test -r tripe-keys.sig-1])
107
108## Bob fetches a new copy. He gets warned that something unusual has
109## happened.
110cd "$work"/bob
111AT_CHECK([BUILDDIR/tripe-keys update],, [ignore],
112[tripe-keys: configuration file changed: recommend running another update
113])
114
115## Alice can now destroy her old master key.
116cd "$work"/alice
117AT_CHECK([key -kmaster delete master-0])
118AT_CHECK([BUILDDIR/tripe-keys upload],, [ignore])
119
120## This is OK because Bob has rolled over to the new key.
121cd "$work"/bob
122AT_CHECK([BUILDDIR/tripe-keys update],, [ignore])
123
124###--------------------------------------------------------------------------
125### Check good behaviour on signature verification failures.
126
127## Corrupt the distribution tarball.
128cd "$work"/dist
129mkdir tmp
130cd tmp
131tar xfz ../tripe-keys.tar.gz
132touch repos/bogus-file
133tar cfz ../tripe-keys.tar.gz *
134
135## Bob tries fetching again. The update will notice the problem; none of his
136## files will change.
137cd "$work"/bob
138md5sum repos/* keyring keyring.pub tripe-keys.conf >old-state.md5
139AT_CHECK([BUILDDIR/tripe-keys update], [1], [ignore], [ignore])
140AT_CHECK([md5sum -c old-state.md5],, [ignore])
141
142###----- That's all, folks --------------------------------------------------
143
144AT_CLEANUP