source: mod_gnutls/t/runtests @ 9720026

debian/masterdebian/stretch-backportsjessie-backportsupstream
Last change on this file since 9720026 was e3cbda4, checked in by Daniel Kahn Gillmor <dkg@…>, 6 years ago

MSVA: include in test framework

  • Property mode set to 100755
File size: 2.7 KB
Line 
1#!/bin/bash
2
3# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
4
5set -e
6
7tests="${1##t-}"
8
9BADVARS=0
10for v in TEST_HOST TEST_IP TEST_PORT TEST_QUERY_DELAY TEST_GAP MSVA_PORT; do
11    if [ ! -v "$v" ]; then
12        printf "You need to set the %s environment variable\n" "$v" >&2
13        BADVARS=1
14    fi
15done
16
17if [ 0 != "$BADVARS" ]; then
18    exit 1
19fi
20
21if [ . != "$(dirname "$0")" ]; then
22    printf "You should only run this mod-gnutls test suite from the t/ directory of the mod_gnutls source.\n" >&2
23    exit 1
24fi
25
26function stop_msva() {
27    kill %1
28}
29
30function apache_down_err() {
31    printf "FAILURE: %s\n" "$TEST_NAME"
32    /usr/sbin/apache2 -f "$(pwd)/apache.conf" -k stop || true
33    if [ -e output ]; then
34        printf "\ngnutls-cli outputs:\n"
35        diff -u output <( tail -n "$(wc -l < output)" "$output" ) || true
36    fi
37    printf "\nApache error logs:\n"
38    tail "../../logs/${TEST_NAME}.error.log"
39    stop_msva
40}
41
42if [ -z "$tests" ] ; then
43    tests=./tests/*
44else
45    tests=./tests/"$(printf "%02d" "$tests")"_*
46fi
47
48GNUPGHOME=$(pwd)/msva.gnupghome MSVA_KEYSERVER_POLICY=never monkeysphere-validation-agent &
49
50trap stop_msva EXIT
51
52sleep "$TEST_GAP"
53
54printf "TESTING: initial MSVA verification\n"
55MONKEYSPHERE_VALIDATION_AGENT_SOCKET="http://127.0.0.1:$MSVA_PORT" msva-query-agent https "$(cat client.uid)" x509pem client < client/x509.pem 
56printf "\nSUCCESS: initial MSVA verification\n"
57
58for t in $tests; do 
59    sleep "$TEST_GAP"
60    export TEST_NAME="$(basename "$t")"
61    output="../../outputs/${TEST_NAME}.output"
62    rm -f "$output"
63    cd "$t"
64    if [ -e fail.* ]; then
65        EXPECTED_FAILURE="$(printf " (expected: %s)" fail.*)"
66    else
67        unset EXPECTED_FAILURE
68    fi
69    printf "TESTING: %s%s\n" "$TEST_NAME" "$EXPECTED_FAILURE"
70    trap apache_down_err EXIT
71    MONKEYSPHERE_VALIDATION_AGENT_SOCKET="http://127.0.0.1:$MSVA_PORT" /usr/sbin/apache2 -f "$(pwd)/apache.conf" -k start || [ -e fail.server ]
72
73    if (sed "s/__HOSTNAME__/${TEST_HOST}/" < ./input && sleep "$TEST_QUERY_DELAY") | \
74        gnutls-cli -p "${TEST_PORT}" $(cat ./gnutls-cli.args) "${TEST_HOST}" > \
75        "$output" ; then
76        if [ -e fail* ]; then
77            printf "%s should have failed but succeeded\n" "$(basename "$t")" >&2
78            exit 1
79        fi
80    else
81        if [ ! -e fail* ]; then
82            printf "%s should have succeeded but failed\n" "$(basename "$t")" >&2
83            exit 1
84        fi
85    fi
86    if [ -e output ] ; then
87        diff -q -u output <( tail -n "$(wc -l < output)" "$output" )
88    fi
89    /usr/sbin/apache2 -f "$(pwd)/apache.conf" -k stop || [ -e fail.server ]
90    trap stop_msva EXIT
91    printf "SUCCESS: %s\n" "$TEST_NAME"
92    cd ../..
93done
94
95stop_msva
Note: See TracBrowser for help on using the repository browser.