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