Changeset b28158c in mod_gnutls


Ignore:
Timestamp:
Oct 11, 2017, 2:25:39 AM (5 years ago)
Author:
Thomas Klute <thomas2.klute@…>
Branches:
asyncio, debian/master, debian/stretch-backports, main, master, proxy-ticket, upstream
Children:
1872744
Parents:
c9e4709
Message:

Test suite: Start proxy backend server from runtests if config exists

Proxy tests started the backend server from the test script until now,
so this removes a lot of duplicate code.

Location:
test
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • test/runtests

    rc9e4709 rb28158c  
    77set -e
    88. ${srcdir}/common.bash
     9. ${srcdir}/proxy_backend.bash
    910netns_reexec ${@}
    1011
     
    1718    testid=${srcdir}/tests/"$(printf "%02d" "$testid")"_*
    1819fi
     20testdir="$(realpath ${testid})"
    1921
    2022BADVARS=0
     
    100102function apache_down_err() {
    101103    printf "FAILURE: %s\n" "$TEST_NAME"
    102     ${APACHE2} -f "${t}/apache.conf" -k stop || true
     104    ${APACHE2} -f "${testdir}/apache.conf" -k stop || true
    103105    if [ -e output ]; then
    104106        printf "\ngnutls-cli outputs:\n"
    105107        diff_output_filter_headers "output" "$output" || true
     108    fi
     109
     110    if [ -r "${testdir}/backend.conf" ]; then
     111        backend_apache "${testdir}" "backend.conf" stop || true
    106112    fi
    107113
     
    151157fi
    152158
    153 t="$(realpath ${testid})"
    154159export srcdir="$(realpath ${srcdir})"
    155 export TEST_NAME="$(basename "$t")"
     160export TEST_NAME="$(basename "${testdir}")"
    156161output="outputs/${TEST_NAME}.output"
    157162rm -f "$output"
    158163
    159 if [ -e ${t}/fail.* ]; then
     164if [ -e ${testdir}/fail.* ]; then
    160165    EXPECTED_FAILURE="$(printf " (expected: %s)" fail.*)"
    161166else
     
    173178fi
    174179
    175 if ! ${flock_cmd} ${APACHE2} -f "${t}/apache.conf" -k start; then
    176     if [ -e "${t}/fail.server" ]; then
     180echo "${testdir}/backend.conf"
     181if [ -r "${testdir}/backend.conf" ]; then
     182    backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
     183fi
     184
     185if ! ${flock_cmd} ${APACHE2} -f "${testdir}/apache.conf" -k start; then
     186    if [ -e "${testdir}/fail.server" ]; then
    177187        echo "Apache HTTPD failed to start as expected."
    178188        exit 0
     
    206216# end with CRLF as required by RFC 7230, Section 3.1.1 regardless of
    207217# the line ends in the input file.
    208 if (sed -r "s/__HOSTNAME__/${TEST_HOST}/;s/\r?$/\r/" <${t}/input && \
     218if (sed -r "s/__HOSTNAME__/${TEST_HOST}/;s/\r?$/\r/" <${testdir}/input && \
    209219           run_with_pidfile "${sleep_pidfile}" sleep "${TEST_QUERY_TIMEOUT}" &) | \
    210        gnutls-cli -p "${TEST_PORT}" $(cat ${t}/gnutls-cli.args) "${TEST_HOST}" \
     220       gnutls-cli -p "${TEST_PORT}" $(cat ${testdir}/gnutls-cli.args) "${TEST_HOST}" \
    211221       | tee "$output" && test "${PIPESTATUS[1]}" -eq 0;
    212222then
    213     if [ -e ${t}/fail* ]; then
    214         printf "%s should have failed but succeeded\n" "$(basename "$t")" >&2
     223    if [ -e ${testdir}/fail* ]; then
     224        printf "%s should have failed but succeeded\n" "$(basename "$testdir")" >&2
    215225        exit 1
    216226    fi
    217227else
    218     if [ ! -e ${t}/fail* ]; then
    219         printf "%s should have succeeded but failed\n" "$(basename "$t")" >&2
     228    if [ ! -e ${testdir}/fail* ]; then
     229        printf "%s should have succeeded but failed\n" "$(basename "$testdir")" >&2
    220230        exit 1
    221231    fi
     
    225235unset sleep_pidfile
    226236
    227 if [ -e ${t}/output ] ; then
    228     diff_output_filter_headers "${t}/output" "$output" >&2
     237if [ -e ${testdir}/output ] ; then
     238    diff_output_filter_headers "${testdir}/output" "$output" >&2
    229239fi
    230240if [ -n "${USE_MSVA}" ]; then
     
    233243    trap - EXIT
    234244fi
    235 ${APACHE2} -f "${t}/apache.conf" -k stop || [ -e ${t}/fail.server ]
     245${APACHE2} -f "${testdir}/apache.conf" -k stop || [ -e ${testdir}/fail.server ]
    236246printf "SUCCESS: %s\n" "$TEST_NAME"
     247
     248if [ -r "${testdir}/backend.conf" ]; then
     249    backend_apache "${testdir}" "backend.conf" stop || true
     250fi
    237251
    238252if [ -n "${USE_MSVA}" ]; then
  • test/test-19_TLS_reverse_proxy.bash

    rc9e4709 rb28158c  
    11#!/bin/bash
    2 
    3 set -e
    4 : ${srcdir:="."}
    5 . ${srcdir}/common.bash
    6 netns_reexec ${@}
    7 
    8 testdir="${srcdir}/tests/19_TLS_reverse_proxy"
    9 . $(dirname ${0})/proxy_backend.bash
    10 
    11 function stop_backend
    12 {
    13     backend_apache "${testdir}" "backend.conf" stop
    14 }
    15 backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
    16 trap stop_backend EXIT
    17 
    182${srcdir}/runtests t-19
    19 
    20 backend_apache "${testdir}" "backend.conf" stop
    21 trap - EXIT
  • test/test-20_TLS_reverse_proxy_client_auth.bash

    rc9e4709 rb28158c  
    11#!/bin/bash
    2 
    3 set -e
    4 : ${srcdir:="."}
    5 . ${srcdir}/common.bash
    6 netns_reexec ${@}
    7 
    8 testdir="${srcdir}/tests/20_TLS_reverse_proxy_client_auth"
    9 . $(dirname ${0})/proxy_backend.bash
    10 
    11 function stop_backend
    12 {
    13     backend_apache "${testdir}" "backend.conf" stop
    14 }
    15 backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
    16 trap stop_backend EXIT
    17 
    182${srcdir}/runtests t-20
    19 
    20 backend_apache "${testdir}" "backend.conf" stop
    21 trap - EXIT
  • test/test-21_TLS_reverse_proxy_wrong_cert.bash

    rc9e4709 rb28158c  
    11#!/bin/bash
    2 
    3 set -e
    4 : ${srcdir:="."}
    5 . ${srcdir}/common.bash
    6 netns_reexec ${@}
    7 
    8 testdir="${srcdir}/tests/21_TLS_reverse_proxy_wrong_cert"
    9 . $(dirname ${0})/proxy_backend.bash
    10 
    11 function stop_backend
    12 {
    13     backend_apache "${testdir}" "backend.conf" stop
    14 }
    15 backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
    16 trap stop_backend EXIT
    17 
    182${srcdir}/runtests t-21
    19 
    20 backend_apache "${testdir}" "backend.conf" stop
    21 trap - EXIT
  • test/test-22_TLS_reverse_proxy_crl_revoke.bash

    rc9e4709 rb28158c  
    11#!/bin/bash
    2 
    3 set -e
    4 : ${srcdir:="."}
    5 . ${srcdir}/common.bash
    6 netns_reexec ${@}
    7 
    8 testdir="${srcdir}/tests/22_TLS_reverse_proxy_crl_revoke"
    9 . $(dirname ${0})/proxy_backend.bash
    10 
    11 function stop_backend
    12 {
    13     backend_apache "${testdir}" "backend.conf" stop
    14 }
    15 backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
    16 trap stop_backend EXIT
    17 
    182${srcdir}/runtests t-22
    19 
    20 backend_apache "${testdir}" "backend.conf" stop
    21 trap - EXIT
  • test/test-23_TLS_reverse_proxy_mismatched_priorities.bash

    rc9e4709 rb28158c  
    11#!/bin/bash
    2 
    3 set -e
    4 : ${srcdir:="."}
    5 . ${srcdir}/common.bash
    6 netns_reexec ${@}
    7 
    8 testdir="${srcdir}/tests/23_TLS_reverse_proxy_mismatched_priorities"
    9 . $(dirname ${0})/proxy_backend.bash
    102
    113# This test checks if server and proxy priorities are applied
     
    135# back end server is configured not to use TLS 1.2. The proxy request
    146# must fail and the client must receive an error message to pass.
    15 
    16 function stop_backend
    17 {
    18     backend_apache "${testdir}" "backend.conf" stop
    19 }
    20 backend_apache "${testdir}" "backend.conf" start "${BACKEND_LOCK}"
    21 trap stop_backend EXIT
    22 
    237${srcdir}/runtests t-23
    24 
    25 backend_apache "${testdir}" "backend.conf" stop
    26 trap - EXIT
Note: See TracChangeset for help on using the changeset viewer.