ce2e6f2efb38b9c573a0375eb4647826b5091e31
[tripe] / server / tests.at
1 ### -*-autotest-*-
2 ###
3 ### Test script for the main server
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
26 m4_define([nl], [
27 ])
28
29 ## Configure a directory ready for use by tripe.
30 m4_define([SETUPDIR], [
31 cp $abs_top_srcdir/t/keyring-$1 ./keyring
32 key extract -f-secret keyring.pub
33 ])
34
35 ## Running standard programs with useful options.
36 m4_define([TRIPE],
37 [env TRIPE_PRIVHELPER=$abs_top_builddir/priv/tripe-privhelper \
38 $abs_top_builddir/server/tripe -F -d. -aadmin -p0 -b127.0.0.1 -talice])
39 m4_define([TRIPECTL], [$abs_top_builddir/client/tripectl -d. -aadmin])
40 m4_define([USLIP], [$abs_top_builddir/uslip/tripe-uslip])
41 m4_define([PKSTREAM],
42 [$abs_top_builddir/pkstream/pkstream -b127.0.0.1 -p127.0.0.1])
43 m4_define([MITM], [$abs_top_builddir/proxy/tripe-mitm])
44
45 ## WITH_STRACE(tag, cmd)
46 ##
47 ## There's an awful hack here. If a process running under strace exits with
48 ## a signal, then strace will kill itself with the same signal -- and
49 ## therefore clobber the original process's core file. So we arrange to run
50 ## strace in one directory and have the child process run in another.
51 m4_define([WITH_STRACE],
52 [case "${TRIPE_TEST_STRACE-nil}" in
53 nil)
54 $2
55 ;;
56 *)
57 mkdir -p strace-hack.$1/
58 (ulimit -c hard >/dev/null 2>&1
59 sh -c 'cd strace-hack.$1; exec "$[]@"' - \
60 strace -f -o../$1.trace \
61 sh -c 'cd ..; exec "$[]@"' - \
62 $2)
63 ;;
64 esac])
65
66 ## Sequences. (These are used for testing the replay protection machinery.)
67 m4_define([R32], [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 dnl
68 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31])
69 m4_define([P32], [21 26 14 12 25 18 2 27 10 31 24 29 0 20 17 11 dnl
70 8 3 7 23 19 1 13 30 6 9 5 22 15 28 16 4])
71
72 ###--------------------------------------------------------------------------
73 ### Scaffolding for running a TrIPE server.
74
75 ## WITH_TRIPEX(dir, args, body)
76 m4_define([WITH_TRIPEX], [
77
78 ## If this directory doesn't exist then Bad Things will happen.
79 if test ! -d $1; then
80 echo >&2 "server directory \`$1' doesn't exist"
81 exit 99
82 fi
83
84 ## Remove the status file. This is how we notice that the server's died.
85 rm -f $1/server-status
86 > $1/expected-server-output
87 > $1/expected-server-errors
88
89 ## Autotest writes crap to standard output, which we don't want going to the
90 ## server. So keep a copy of the standard output, do the pipe, and recover
91 ## the old stdout inside the group.
92 exec 3>&1
93 { (
94 exec 1>&3 3>&-
95
96 ## Wait for the socket to appear. Watch for the server crashing during
97 ## initialization. Busy waiting is evil, but it's the best I can do and
98 ## not sleep for ages. (Yes, a second on each test group is a long time.)
99 while test ! -r $1/server-status && test ! -S $1/admin; do :; done
100
101 ## Make the port number availale.
102 AT_CHECK([TRIPECTL -d$1 PORT],, [stdout])
103 mv stdout $1/port
104
105 ## Test body...
106 $3
107
108 ## End of the test, now run the server.
109 ) && :; } | {
110 cd $1
111 echo TRIPE $2 >&2
112 WITH_STRACE([tripe], [TRIPE $2 >server-output.full 2>server-errors.full])
113 stat=$?
114 echo $stat >server-status
115 if test $stat -ne 0; then
116 echo "exit status: $stat" >>server-errors.full
117 fi
118 grep -v '^+ tripe: ' server-errors.full >server-errors
119
120 ## We interrupt this relatively sensible macro for an especially awful
121 ## hack. The tripe server emits warnings which are often caused by lack of
122 ## synchronization between two peers. These are harmless and shouldn't
123 ## cause test failures. But we shouldn't just trim out all messages that
124 ## look like the spurious ones: if they appear when we're not expecting
125 ## them, that's bad and they should properly cause a test failure.
126 ##
127 ## So we use the WARN command to insert magic directives into the server's
128 ## message stream. The directives begin with `WARN USER test'; remaining
129 ## tokens may be as follows.
130 ##
131 ## PUSH Introduce a new layer of nesting. Settings between
132 ## this PUSH and the matching POP will be forgotten
133 ## following the POP.
134 ##
135 ## POP End a layer of nesting. See PUSH above.
136 ##
137 ## IGNORE tokens Ignore lines which begin with the tokens.
138 ##
139 ## Token comparison isn't done very well, but it's good enough for these
140 ## purposes.
141 ##
142 ## We also trim out trace lines here, since it's useful to produce them for
143 ## debugging purposes and changing or introducing more of them shouldn't
144 ## cause failures.
145 awk '
146 BEGIN {
147 sp = 0;
148 npat = 0;
149 }
150 $[]1 == "TRACE" { next; }
151 $[]1 == "WARN" && $[]2 == "USER" && $[]3 == "test" {
152 if ($[]4 == "PUSH")
153 npatstk[[sp++]] = npat;
154 else if ($[]4 == "IGNORE") {
155 s = "";
156 p = "";
157 for (i = 5; i <= NF; i++) {
158 p = p s $[]i;
159 s = " ";
160 }
161 pat[[npat++]] = p;
162 } else if ($[]4 == "POP")
163 npat = npatstk[[--sp]];
164 next;
165 }
166 {
167 for (i = 0; i < npat; i++) {
168 n = length(pat[[i]]);
169 if (substr($[]0, 1, n) == pat[[i]])
170 next;
171 }
172 print $[]0;
173 }
174 ' server-output.full >server-output
175 }
176 exec 3>&-
177
178 ## Now check that the server's output matches our expectations.
179 mv $1/expected-server-output expout
180 mv $1/expected-server-errors experr
181 AT_CHECK([cat $1/server-output; cat >&2 $1/server-errors],,
182 [expout], [experr])
183 ])
184
185 ## WITH_TRIPE(args, body)
186 m4_define([WITH_TRIPE], [WITH_TRIPEX([.], [$1], [$2])])
187
188 ## WITH_2TRIPES(adir, bdir, bothargs, aargs, bargs, body)
189 m4_define([WITH_2TRIPES],
190 [WITH_TRIPEX([$1], [$3 $4], [WITH_TRIPEX([$2], [$3 $5], [$6])])])
191
192 ## WITH_3TRIPES(adir, bdir, cdir, allargs, aargs, bargs, cargs, body)
193 m4_define([WITH_3TRIPES],
194 [WITH_TRIPEX([$1], [$4 $5],
195 [WITH_TRIPEX([$2], [$4 $6],
196 [WITH_TRIPEX([$3], [$4 $7],
197 [$8])])])])
198
199 ## RETRY(n, body)
200 m4_define([RETRY], [
201 n=0 rc=1
202 while test $n -lt $1; do
203 if $2
204 then rc=0; break
205 fi
206 n=$(( $n + 1 ))
207 done
208 exit $rc
209 ])
210
211 ## COMMS_EPING(adir, aname, bdir, bname, [n])
212 m4_define([COMMS_EPING], [
213 AT_CHECK([RETRY([m4_default([$5], [1])],
214 [TRIPECTL -d$1 EPING $4])],, [ignore])
215 AT_CHECK([RETRY([m4_default([$5], [1])],
216 [TRIPECTL -d$3 EPING $2])],, [ignore])
217 ])
218
219 ## COMMS_SLIP(adir, aname, bdir, bname)
220 m4_define([COMMS_SLIP], [
221 AT_CHECK([echo "from $1" | USLIP -p $1/$4])
222 AT_CHECK([USLIP -g $3/$2],, [from $1[]nl])
223 AT_CHECK([echo "from $3" | USLIP -p $3/$2])
224 AT_CHECK([USLIP -g $1/$4],, [from $3[]nl])
225 ])
226
227 ## AWAIT_KXDONE(adir, aname, bdir, bname, body)
228 m4_define([AWAIT_KXDONE], [
229
230 ## Ignore some reports caused by races.
231 for d in $1 $3; do
232 TRIPECTL -d$d WARN test PUSH
233 TRIPECTL -d$d WARN test IGNORE WARN KX $2 incorrect cookie
234 TRIPECTL -d$d WARN test IGNORE WARN KX $2 unexpected pre-challenge
235 TRIPECTL -d$d WARN test IGNORE WARN KX $2 unexpected challenge
236 done
237
238 ## Watch for the key-exchange completion announcement in the background.
239 COPROCESSES([wait-$1], [
240 echo WATCH +n
241 while read line; do
242 set x $line; shift
243 echo >&2 ">>> $line"
244 case "$[]1:$[]2:$[]3" in
245 OK::) ;;
246 NOTE:KXDONE:$4) break ;;
247 NOTE:*) ;;
248 *) exit 63 ;;
249 esac
250 done
251 ], [
252 TRIPECTL -d$1
253 ]) & waiter_$1=$!
254
255 $5
256
257 ## Collect the completion announcement.
258 wait $waiter_$1; waitrc=$?
259 AT_CHECK([echo $waitrc],, [0[]nl])
260
261 ## Be interested in key-exchange warnings again.
262 for d in $1 $3; do TRIPECTL -d$d WARN test POP; done
263 ])
264
265 ## ESTABLISH(adir, aname, aopts, bdir, bname, bopts, [aport], [bport])
266 m4_define([ESTABLISH], [
267
268 ## Set up the establishment.
269 AWAIT_KXDONE([$1], [$2], [$4], [$5], [
270 AT_CHECK([TRIPECTL -d$1 ADD -cork $6 $5 INET 127.0.0.1 \
271 m4_if([$8], [], [$(cat $4/port)], [$8])])
272 AT_CHECK([TRIPECTL -d$4 ADD $3 $2 INET 127.0.0.1 \
273 m4_if([$7], [], [$(cat $1/port)], [$7])])
274 ])
275
276 ## Check transport pinging.
277 AT_CHECK([TRIPECTL -d$1 PING $5],, [ignore])
278 AT_CHECK([TRIPECTL -d$4 PING $2],, [ignore])
279
280 ## Check communication works.
281 COMMS_EPING([$1], [$2], [$4], [$5])
282 COMMS_SLIP([$1], [$2], [$4], [$5])
283 ])
284
285 ###--------------------------------------------------------------------------
286 ### Very unpleasant coprocess handling.
287
288 ## COPROCESSES(TAG, PROC-A, PROC-B)
289 m4_define([COPROCESSES], [dnl
290 rm -f pipe-$1; mknod pipe-$1 p
291 { { $2 nl } <pipe-$1 | { $3 nl } >pipe-$1; } dnl
292 ])
293
294 ## TRIPECTL_INTERACT(ARGS, SHELLSTUFF)
295 m4_define([TRIPECTL_INTERACT], [
296 exec 3>&1
297 COPROCESSES([client], [exec 4>&1 1>&3 $1], [TRIPECTL $2])
298 ])
299
300 ## TRIPECTL_COMMAND(CMD, EXPECT)
301 m4_define([TRIPECTL_COMMAND], [
302 AT_CHECK([
303 m4_if([$1], [!], [:], [echo "$1" >&4])
304 read line
305 case "$line" in
306 "$2") ;;
307 *) echo 2>&1 "submitted $1: expected $2, found $line"; exit 1 ;;
308 esac
309 ])
310 exec 3>&-
311 ])
312
313 ###--------------------------------------------------------------------------
314 ### Make sure the thing basically works.
315
316 AT_SETUP([server basics])
317 SETUPDIR([alpha])
318 AT_CHECK([echo port | TRIPE -p54321],, [INFO 54321[]nl[]OK[]nl])
319 AT_CLEANUP
320
321 ###--------------------------------------------------------------------------
322 ### Challenges.
323
324 AT_SETUP([server challenges])
325 AT_KEYWORDS([chal])
326 SETUPDIR([alpha])
327
328 WITH_TRIPE(, [
329 ## A simple test.
330 AT_CHECK([chal=$(TRIPECTL GETCHAL); TRIPECTL checkchal $chal])
331
332 ## A wrong challenge. (This was valid once, but the probablity that the
333 ## server chose the same key is negligible.)
334 AT_CHECK([TRIPECTL checkchal AAAAAHyoOL+HMaE0Y9B3ivuszt0], [1],,
335 [tripectl: invalid-challenge[]nl])
336 echo WARN CHAL incorrect-tag >>expected-server-output
337
338 ## A duplicated challenge.
339 AT_CHECK([
340 chal=$(TRIPECTL GETCHAL)
341 TRIPECTL CHECKCHAL $chal
342 TRIPECTL CHECKCHAL $chal
343 ], [1],, [tripectl: invalid-challenge[]nl])
344 echo WARN CHAL replay duplicated-sequence >>expected-server-output
345
346 ## Out-of-order reception. There should be a window of 32 challenges; we
347 ## make 33 and check them in a strange order.
348 rm -f experr
349 echo "tripectl: invalid-challenge" >>experr
350 echo "WARN CHAL replay old-sequence" >>expected-server-output
351 for i in P32; do
352 echo "tripectl: invalid-challenge" >>experr
353 echo "WARN CHAL replay duplicated-sequence" >>expected-server-output
354 done
355 AT_CHECK([
356
357 ## Make the challenges.
358 for i in old R32; do TRIPECTL GETCHAL >chal-$i || exit 2; done
359
360 ## Now check them back.
361 for i in P32; do TRIPECTL CHECKCHAL $(cat chal-$i) || exit 3; done
362
363 ## Check the one which should have fallen off the front.
364 TRIPECTL CHECKCHAL $(cat chal-old) && exit 4
365
366 ## And make sure that the others are now considered duplicates.
367 for i in R32; do TRIPECTL CHECKCHAL $(cat chal-$i) && exit 5; done
368
369 ## All done: tidy cruft away.
370 rm -f chal-*
371 exit 0
372 ], [0],, [experr])
373 ])
374
375 AT_CLEANUP
376
377 ###--------------------------------------------------------------------------
378 ### Communication.
379
380 AT_SETUP([server communication])
381 AT_KEYWORDS([comm])
382 export TRIPE_SLIPIF=USLIP
383
384 for k in alpha beta-new; do
385 for p in alice bob; do (
386 rm -rf $p; mkdir $p; cd $p; SETUPDIR([$k])
387 ); done
388 WITH_2TRIPES([alice], [bob], [-nslip], [-talice], [-tbob], [
389 ESTABLISH([alice], [not-alice], [-key alice],
390 [bob], [bob], [])
391 ])
392 done
393
394 AT_CLEANUP
395
396 ###--------------------------------------------------------------------------
397 ### Mobile peer tracking.
398
399 AT_SETUP([peer tracking])
400 AT_KEYWORDS([mobile])
401 export TRIPE_SLIPIF=USLIP
402
403 for p in alice bob carol; do (mkdir $p; cd $p; SETUPDIR([alpha])); done
404
405 ## WITH_PKSTREAM(adir, aport, bdir, bport, body)
406 m4_define([WITH_PKSTREAM], [
407 echo >&2 "pkstream: $1 <--> :$2 <-pkstream-> :$4 <--> $3"
408 PKSTREAM -l$4 127.0.0.1:$4 127.0.0.1:$(cat $3/port)& pkstream_$3_$1=$!
409 sleep 1
410 PKSTREAM -c127.0.0.1:$4 127.0.0.1:$2 127.0.0.1:$(cat $1/port)&
411 pkstream_$1_$3=$!
412 set +x
413 $5
414 kill $pkstream_$3_$1 $pkstream_$1_$3
415 ])
416
417 WITH_3TRIPES([alice], [bob], [carol], [-nslip],
418 [-talice], [-tbob], [-tcarol], [
419
420 ## We need an indirection layer between the two peers so that we can
421 ## simulate the effects of NAT remapping. The nearest thing we have to
422 ## this is pkstream, so we may as well use that.
423 ##
424 ## alice <--> :5311 <-pkstream-> :5312 <--> bob
425 ## alice <--> :5321 <-pkstream-> :5322 <--> carol
426
427 WITH_PKSTREAM([alice], [5311], [bob], [5312], [
428 ESTABLISH([alice], [alice], [], [bob], [bob], [-mobile], [5312], [5311])
429 ])
430
431 WITH_PKSTREAM([alice], [5319], [bob], [5312], [
432 COMMS_EPING([bob], [bob], [alice], [alice])
433 COMMS_SLIP([bob], [bob], [alice], [alice])
434 ])
435
436 WITH_PKSTREAM([alice], [5321], [carol], [5322], [
437 ESTABLISH([alice], [alice], [], [carol], [carol], [-mobile],
438 [5322], [5321])
439 ])
440
441 WITH_PKSTREAM([alice], [5311], [bob], [5312], [
442 WITH_PKSTREAM([alice], [5321], [carol], [5322], [
443 COMMS_EPING([bob], [bob], [alice], [alice])
444 COMMS_EPING([carol], [carol], [alice], [alice])
445 COMMS_SLIP([bob], [bob], [alice], [alice])
446 COMMS_SLIP([carol], [carol], [alice], [alice])
447 ])])
448
449 WITH_PKSTREAM([alice], [5321], [bob], [5312], [
450 WITH_PKSTREAM([alice], [5311], [carol], [5322], [
451 COMMS_EPING([bob], [bob], [alice], [alice])
452 COMMS_EPING([carol], [carol], [alice], [alice])
453 COMMS_SLIP([bob], [bob], [alice], [alice])
454 COMMS_SLIP([carol], [carol], [alice], [alice])
455 ])])
456 wait
457 ])
458
459 AT_CLEANUP
460
461 ###--------------------------------------------------------------------------
462 ### Adverse communication.
463
464 AT_SETUP([server retry])
465 AT_KEYWORDS([backoff])
466 export TRIPE_SLIPIF=USLIP
467
468 for i in alice bob; do (mkdir $i; cd $i; SETUPDIR([beta])); done
469
470 WITH_2TRIPES([alice], [bob], [-nslip], [-talice], [-tbob], [
471
472 ## Set up the evil proxy.
473 alicemitm=24516 bobmitm=14016
474 MITM -kalice/keyring.pub >mitm.out 2>mitm.err \
475 peer:alice:$alicemitm:127.0.0.1:$(cat alice/port) \
476 peer:bob:$bobmitm:127.0.0.1:$(cat bob/port) \
477 filt:drop:5 filt:send& mitmpid=$!
478 strace -omitm.trace -p$mitmpid& mitmtrace=$!
479 trap 'kill $mitmpid $mitmtrace; exit 127' EXIT INT QUIT TERM HUP
480
481 ## Try to establish keys anyway.
482 AWAIT_KXDONE([alice], [alice], [bob], [bob], [
483 AT_CHECK([TRIPECTL -dalice ADD -cork bob INET 127.0.0.1 $alicemitm])
484 AT_CHECK([TRIPECTL -dbob ADD alice INET 127.0.0.1 $bobmitm])
485 ])
486
487 ## Check pinging.
488 COMMS_EPING([alice], [alice], [bob], [bob], [10])
489 COMMS_EPING([bob], [bob], [alice], [alice], [10])
490
491 ## Tear down the MITM proxy.
492 kill $mitmpid
493 wait $mitmpid
494 wait $mitmtrace
495 ])
496
497 AT_CLEANUP
498
499 ###--------------------------------------------------------------------------
500 ### Key management.
501
502 AT_SETUP([server key-management])
503 AT_KEYWORDS([keymgmt])
504 export TRIPE_SLIPIF=USLIP
505
506 ## Determine all of the nets and the principals.
507 princs=""
508 nets=" "
509 while read princ pnets; do
510 princs="$princs $princ"
511 for n in $pnets; do
512 case " $nets " in *" $n "*) ;; *) nets="$nets$n " ;; esac
513 done
514 done <<PRINC
515 alice alpha beta
516 bob alpha beta
517 carol beta
518 PRINC
519
520 ## Build the master keyring. All key tags here are of the form PRINC/NET.
521 for n in $nets; do
522 key -k$abs_top_srcdir/t/keyring-$n extract keyring-$n $princs
523 for p in $princs; do key -kkeyring-$n tag $p $p/$n; done
524 key merge keyring-$n
525 rm keyring-$n
526 done
527 key extract -f-secret keyring.pub
528
529 ## Set up the principals' directories.
530 for p in $princs; do
531 mkdir $p
532 cp keyring keyring.pub $p/
533 done
534
535 WITH_3TRIPES([alice], [bob], [carol], [-nslip -Tmx],
536 [-talice/alpha], [-tbob/alpha], [-tcarol/beta], [
537
538 ## Establish this little merry-go-round.
539 ESTABLISH([alice], [alice], [-key alice/alpha],
540 [bob], [bob], [-key bob/alpha])
541 ESTABLISH([alice], [alice], [-key alice/beta],
542 [carol], [carol], [-priv alice/beta -key carol/beta])
543 ESTABLISH([bob], [bob], [-key bob/beta],
544 [carol], [carol], [-priv bob/beta -key carol/beta])
545
546 ## Tweak Bob's alpha key.
547 for p in $princs; do
548 TRIPECTL -d$p WARN test COMMENT tweak bob/alpha
549 done
550
551 key -k$abs_top_srcdir/t/keyring-alpha extract keyring-bob-new bob-new
552 key merge keyring-bob-new
553 key tag -r bob-new bob/alpha
554 key extract -f-secret keyring.pub
555 for p in alice bob; do cp keyring keyring.pub $p/; done
556
557 ## Kick the peers to see whether they update.
558 AWAIT_KXDONE([alice], [alice], [bob], [bob], [
559 TRIPECTL -dalice RELOAD
560 TRIPECTL -dbob RELOAD
561 TRIPECTL -dalice FORCEKX bob
562 TRIPECTL -dbob FORCEKX alice
563 ])
564
565 COMMS_EPING([alice], [alice], [bob], [bob])
566 COMMS_EPING([bob], [bob], [alice], [alice])
567
568 ## Update the beta ring.
569 key merge $abs_top_srcdir/t/keyring-beta-new
570 for p in $princs; do key tag -r $p $p/beta; done
571 key extract -f-secret keyring.pub
572
573 ## Update alice's and carol's private keys, bob's public. This should be
574 ## insufficient for them to switch, but the results could be interesting.
575 for p in $princs; do
576 TRIPECTL -d$p WARN test COMMENT tweak beta step 1
577 done
578
579 for p in alice carol; do cp keyring $p/; done
580 cp keyring.pub bob/
581 for p in $princs; do TRIPECTL -d$p RELOAD; done
582
583 AT_DATA([algs-alpha], [dnl
584 kx-group=ec kx-group-order-bits=256 kx-group-elt-bits=512
585 hash=rmd160 mgf=rmd160-mgf hash-sz=20
586 bulk-transform=v0 bulk-overhead=22
587 cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
588 cipher-data-limit=67108864
589 mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
590 ])
591
592 AT_DATA([algs-beta-old], [dnl
593 kx-group=prime kx-group-order-bits=160 kx-group-elt-bits=1023
594 hash=rmd160 mgf=rmd160-mgf hash-sz=20
595 bulk-transform=v0 bulk-overhead=22
596 cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
597 cipher-data-limit=67108864
598 mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
599 ])
600
601 AT_DATA([algs-beta-new], [dnl
602 kx-group=ec kx-group-order-bits=161 kx-group-elt-bits=320
603 hash=rmd160 mgf=rmd160-mgf hash-sz=20
604 bulk-transform=iiv bulk-overhead=14
605 cipher=blowfish-cbc cipher-keysz=20 cipher-blksz=8
606 cipher-data-limit=67108864
607 mac=rmd160-hmac mac-keysz=20 mac-tagsz=10
608 blkc=blowfish blkc-keysz=20 blkc-blksz=8
609 ])
610
611 cp algs-alpha expout; AT_CHECK([TRIPECTL -dalice ALGS],, [expout])
612 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
613 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dbob ALGS carol],, [expout])
614 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],, [expout])
615 cp algs-beta-old expout; AT_CHECK([TRIPECTL -dcarol ALGS alice],, [expout])
616
617 ## Now copy the full keys. We expect this to provoke key exchange.
618 for p in $princs; do
619 TRIPECTL -d$p WARN test COMMENT tweak beta step 2
620 done
621
622 for p in $princs; do cp keyring keyring.pub $p/; done
623
624 AWAIT_KXDONE([alice], [alice], [carol], [carol], [
625 TRIPECTL -dalice RELOAD
626 AWAIT_KXDONE([bob], [bob], [carol], [carol], [
627 TRIPECTL -dbob RELOAD
628 TRIPECTL -dcarol RELOAD
629 ])
630 ])
631
632 cp algs-alpha expout; AT_CHECK([TRIPECTL -dalice ALGS],, [expout])
633 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dalice ALGS carol],, [expout])
634 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dbob ALGS carol],, [expout])
635 cp algs-beta-new expout; AT_CHECK([TRIPECTL -dcarol ALGS],, [expout])
636 ])
637
638 AT_CLEANUP
639
640 ###--------------------------------------------------------------------------
641 ### Services.
642
643 AT_SETUP([server services])
644 AT_KEYWORDS([svc])
645 SETUPDIR([alpha])
646
647 WITH_TRIPE(, [
648
649 ## Make sure it's not running yet.
650 AT_CHECK([TRIPECTL SVCENSURE test], [1],,
651 [tripectl: unknown-service test[]nl])
652
653 ## Run a simple service.
654 rm -f svc-test-running tripectl-status
655 COPROCESSES([svc], [
656 echo SVCCLAIM test 1.0.0
657 read line
658 case "$line" in
659 OK)
660 ;;
661 *)
662 echo >&2 "SVCCLAIM failed: $line"
663 exit 1
664 ;;
665 esac
666 echo ok >svc-test-running
667 while read line; do
668 set -- $line
669 case "$[]1,$[]3,$[]4" in
670 SVCJOB,test,HELP)
671 echo SVCINFO try not to use this service for anything useful
672 echo SVCOK $[]2
673 ;;
674 SVCJOB,test,GOOD)
675 echo SVCOK $[]2
676 ;;
677 SVCJOB,test,BAD)
678 echo SVCFAIL $[]2 this-command-always-fails
679 ;;
680 SVCJOB,test,UGLY)
681 tag=$2
682 while read line; do
683 set -- $line
684 case "$[]1,$[]2,$[]3,$[]4" in
685 SVCCANCEL,$tag,,) break ;;
686 SVCJOB,*,test,ESCAPE)
687 echo >&2 "attempt to escape from alkatraz"
688 exit 1
689 ;;
690 esac
691 done
692 ;;
693 SVCJOB,test,FIRST)
694 firsttag=$[]2
695 ;;
696 SVCJOB,test,SECOND)
697 echo SVCOK $firsttag
698 echo SVCOK $[]2
699 ;;
700 SVCJOB,*)
701 echo SVCFAIL $[]2 unknown-svc-command $[]4
702 ;;
703 SVCCLAIM,*)
704 break
705 ;;
706 OK,* | INFO,*)
707 ;;
708 FAIL,*)
709 echo "failure in service: $line" >&2
710 ;;
711 esac
712 done
713 ], [
714 TRIPECTL; echo $? >tripectl-status
715 ]) 2>tripectl-errors &
716
717 ## Wait until it starts up.
718 while test ! -r svc-test-running && test ! -r tripectl-status; do :; done
719
720 ## Make sure it's running.
721 AT_CHECK([TRIPECTL SVCQUERY test],, [name=test version=1.0.0[]nl])
722
723 ## Try some simple commands.
724 AT_CHECK([TRIPECTL SVCSUBMIT test GOOD])
725 AT_CHECK([TRIPECTL SVCSUBMIT test BAD], [1],,
726 [tripectl: this-command-always-fails[]nl])
727
728 ## And now with commands in the background.
729 TRIPECTL_INTERACT([
730 TRIPECTL_COMMAND([SVCSUBMIT test GOOD], [OK])
731 TRIPECTL_COMMAND([SVCSUBMIT -background foo test UGLY], [BGDETACH foo])
732 TRIPECTL_COMMAND([BGCANCEL foo], [OK])
733 TRIPECTL_COMMAND([SVCSUBMIT test ESCAPE],
734 [FAIL unknown-svc-command ESCAPE])
735 ])
736
737 ## Out-of-order completion.
738 TRIPECTL_INTERACT([
739 TRIPECTL_COMMAND([SVCSUBMIT -background one test FIRST], [BGDETACH one])
740 TRIPECTL_COMMAND([SVCSUBMIT -background two test SECOND], [BGDETACH two])
741 TRIPECTL_COMMAND([!], [BGOK one])
742 TRIPECTL_COMMAND([!], [BGOK two])
743 ])
744
745 ## All done.
746 exit 0
747 ])
748
749 AT_CLEANUP
750
751 ###----- That's all, folks --------------------------------------------------