source: mod_gnutls/test/Makefile.am @ e2200db

asyncioproxy-ticket
Last change on this file since e2200db was 9db4dcd, checked in by Fiona Klute <fiona.klute@…>, 20 months ago

Handle GNUTLS_E_GOT_APPLICATION_DATA on gnutls_reauth()

Pending application data is cached in the connection input buffer, so
repeated attempts won't cause more memory allocations. If the buffer
is too small HTTP_REQUEST_ENTITY_TOO_LARGE is sent to the client.

The reauthentication test now contains a POST request so this code
path may (!) be taken during the test suite run.

  • Property mode set to 100644
File size: 12.2 KB
RevLine 
[33af2b7]1SUBDIRS = tests
2
[478767a]3# Generate the test scripts
4test-%.bash: test-template.bash.in | tests/%/
5        testname="$(*)"; sed s/@NUMBER@/$${testname%%_*}/ < $< > $@
6        chmod a+x $@
7
[0da2c5d]8test_scripts = test-00_basic.bash \
[c51e33a]9        test-01_serverwide_priorities.bash \
10        test-02_cache_in_vhost.bash \
11        test-03_cachetimeout_in_vhost.bash \
12        test-04_basic_nosni.bash \
13        test-05_mismatched-priorities.bash \
14        test-06_verify_sni_a.bash \
15        test-07_verify_sni_b.bash \
16        test-08_verify_no_sni_fallback_to_first_vhost.bash \
17        test-09_verify_no_sni_fails_with_wrong_order.bash \
18        test-10_basic_client_verification.bash \
19        test-11_basic_client_verification_fail.bash \
20        test-12_cgi_variables.bash \
21        test-13_cgi_variables_no_client_cert.bash \
[6c5c2ec]22        test-14_resume_session.bash
[65c18ce]23if USE_MSVA
[0da2c5d]24test_scripts += test-15_basic_msva.bash
[65c18ce]25endif
[0da2c5d]26test_scripts += test-16_view-status.bash \
[eea8a16]27        test-17_cgi_vars_large_cert.bash \
[6e6a4e4]28        test-18_client_verification_wrong_cert.bash \
[ed82a6a]29        test-19_TLS_reverse_proxy.bash \
30        test-20_TLS_reverse_proxy_client_auth.bash \
[907ae8f]31        test-21_TLS_reverse_proxy_wrong_cert.bash \
[f030883]32        test-22_TLS_reverse_proxy_crl_revoke.bash \
[3f00958]33        test-23_TLS_reverse_proxy_mismatched_priorities.bash \
[29d3311]34        test-24_pkcs11_cert.bash \
[8ac7c0d]35        test-25_Disable_TLS_1.0.bash \
[c4d6e77]36        test-26_redirect_HTTP_to_HTTPS.bash \
[d50dac5]37        test-27_OCSP_server.bash \
[359f009]38        test-28_HTTP2_support.bash \
[0062ede]39        test-29_force_handshake_vhost.bash \
[5cf8e99]40        test-30_ip_based_vhosts.bash \
41        test-31_vhost_SNI_serveralias_match.bash \
[dcc053e]42        test-32_vhost_SNI_serveralias_mismatch.bash \
[f674424]43        test-33_vhost_SNI_serveralias_missinghost.bash \
[6fa6095]44        test-34_TLS_reverse_proxy_h2.bash \
45        test-35_client_reauth.bash
[5951102]46
[0da2c5d]47MOSTLYCLEANFILES = $(test_scripts)
[478767a]48dist_check_SCRIPTS = netns_py.bash test-template.bash.in
49
[459a982]50TEST_EXTENSIONS = .bash .py
51PY_LOG_COMPILER = $(PYTHON)
[0da2c5d]52TESTS = doctest-mgstest.py $(test_scripts)
[8f90bf4]53
[7921dc7]54check_PROGRAMS = pgpcrc
[42829ae]55pgpcrc_SOURCES = pgpcrc.c
56
[42bee37]57# build OCSP database tool
58if ENABLE_OCSP_TEST
[b674e95]59check_PROGRAMS += gen_ocsp_index
[42bee37]60gen_ocsp_index_SOURCES = gen_ocsp_index.c cert_helper.c
[439005a]61gen_ocsp_index_CFLAGS = $(LIBGNUTLS_CFLAGS)
[6c44ed2]62gen_ocsp_index_LDFLAGS = $(LIBGNUTLS_LIBS)
[42bee37]63noinst_HEADERS = cert_helper.h
64endif
65
[6d3dc34]66# Python tools for tests
67noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
[ff039b1]68        mgstest/hooks.py mgstest/services.py mgstest/softhsm.py \
69        mgstest/tests.py runtest.py softhsm-init.py doctest-mgstest.py
[6d3dc34]70
[9a4d250]71# Identities in the miniature CA, server, and client environment for
72# the test suite
[e5546be]73shared_identities = authority authority/client
[c0bb823]74pgp_identities = $(shared_identities)
[c3aebe5]75x509_only_identities = authority/server authority/imposter \
76        authority/subca authority/subca/server \
77        rogueca rogueca/rogueclient
[a03f94e]78if ENABLE_OCSP_TEST
[7cfc02b]79x509_only_identities += authority/ocsp-responder authority/subca/ocsp-responder
[a03f94e]80endif
[c0bb823]81x509_identities = $(shared_identities) $(x509_only_identities)
82identities = $(shared_identities) $(x509_only_identities)
[9a4d250]83# Append strings after ":=" to each identity to generate a list of
84# necessary files
[d70dd6e]85pgp_tokens = $(pgp_identities:=/cert.pgp) \
[c0bb823]86        $(pgp_identities:=/secret.pgp)
87x509_keys = $(x509_identities:=/secret.key)
88x509_certs = $(x509_identities:=/x509.pem)
[9a4d250]89x509_tokens = $(x509_certs) $(x509_keys)
[39a27cf]90tokens = $(x509_tokens)
91if USE_MSVA
92tokens += $(pgp_tokens)
93endif
[9a4d250]94
[5b6a5d9]95if !DISABLE_FLOCK
96# flock command for write access to the authority keyring
[5725dca]97GPG_FLOCK = @FLOCK@ authority/lock
[5b6a5d9]98endif
99
[fc8e463b]100include $(srcdir)/test_ca.mk
[9a4d250]101
[39bd695]102# Test cases trying to create keys and certificates in parallel causes
103# race conditions. Ensure that all keys and certificates are generated
104# before tests get to run.
105#
106# NOTE: Once the support files have been generated, test cases can be
107# run with multiple jobs, but real parallelization would require
108# dynamic port assignments. At the moment, lock files ensure that only
109# one Apache instance (possibly plus a proxy back end instance) is
110# running at any time, so test cases actually have to wait for each
111# other - just not in any particular order.
[c825c3a]112check_DATA = $(tokens) authority/server/crl.pem
[39bd695]113
[478767a]114MOSTLYCLEANFILES += cache/* logs/* outputs/* authority/server/crl.pem
[6ce02e2]115
[e5546be]116cert_templates = authority/template.in authority/client/template.in \
[e8498bf]117        authority/imposter/template.in authority/ocsp-responder/template \
[6dab61d]118        authority/server/template.in \
[c3aebe5]119        authority/subca/template.in authority/subca/server/template.in \
[7cfc02b]120        authority/subca/ocsp-responder/template \
[6dab61d]121        rogueca/template rogueca/rogueclient/template.in
[e5546be]122generated_templates = authority/template authority/client/template \
[6dab61d]123        authority/imposter/template rogueca/rogueclient/template \
[59afe51]124        authority/server/template
[90a31a4]125
[9a4d250]126# Delete X.509 private keys on full clean. Note that unless you need
127# to generate fresh keys, the "mostlyclean" target should be
128# sufficient (see below).
129CLEANFILES = $(x509_keys)
130
[90a31a4]131# Delete X.509 certificates and generated templates on "mostlyclean"
132# target. Certificates can be rebuilt without generating new key
133# pairs, and regenerating them makes it possible to change identities
[7aeabcb]134# (e.g. host names) without wasting time on new keys (which would
[90a31a4]135# happen after "clean").
[e5546be]136MOSTLYCLEANFILES += $(x509_certs) $(generated_templates) $(identities:=/uid)
[9a4d250]137
[90a31a4]138
[6ce02e2]139# Delete PGP keyrings on "mostlyclean" target. They are created from
140# the X.509 private keys and certificates with an expiration time of
141# one day, so regenerating them is both fast and frequently
142# necessary.
[e5546be]143pgp_patterns = /*.pgp /*.pgp.raw /*.gpg /*.gpg~ /gpg.conf \
144        /*.kbx /*.kbx~ /S.gpg-agent /private-keys-v1.d/*
145MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(pgp_identities:=$(pat))) \
146        authority/lock authority/tofu.db
[9a4d250]147# GnuPG random pool, no need to regenerate on every build
148CLEANFILES += authority/random_seed
[1708045]149
[ee94de5]150# GnuPG 2 starts gpg-agent processes per GNUPGHOME (one for every PGP
151# identity) while creating the PGP certificates. This target is called
152# by both "check-local" and "mostlyclean-local": The former because
153# agent processes are started while preparing for "check" and are no
154# longer needed afterwards, the latter to make sure they are gone
155# along with their certificates.
156stop-gnupg-agent:
157        for id in $(pgp_identities) $(msva_home); do \
158                GNUPGHOME=$$id/ gpgconf --kill gpg-agent || true; \
159        done
160
161check-local: stop-gnupg-agent
162
[9a4d250]163# Delete lock files for test servers on "mostlyclean" target.
164MOSTLYCLEANFILES += *.lock
165
166# rule to build MSVA trust database
167if USE_MSVA
168msva_home = msva.gnupghome
[e5546be]169check_DATA += $(msva_home)/trustdb.gpg authority/client/uid
170MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(msva_home)$(pat))
171$(msva_home)/trustdb.gpg: authority/minimal.pgp authority/client/cert.pgp
[9a4d250]172        mkdir -p -m 0700 $(dir $@)
173        GNUPGHOME=$(dir $@) gpg --import < $<
[ee94de5]174        printf "%s:6:\n" "$$(GNUPGHOME=authority/ gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" | GNUPGHOME=$(dir $@) gpg --import-ownertrust
[e5546be]175        GNUPGHOME=$(dir $@) gpg --import < authority/client/cert.pgp
[9a4d250]176        printf "keyserver does-not-exist.example\n" > $(msva_home)/gpg.conf
177endif
[3f00958]178
[ea99ffe]179if ENABLE_OCSP_TEST
[20f8e99]180# rules to build OCSP database
[7cfc02b]181ocsp_index_data = authority/ocsp_index.txt authority/ocsp_index.txt.attr \
182        authority/subca/ocsp_index.txt authority/subca/ocsp_index.txt.attr
183check_DATA += $(ocsp_index_data)
184MOSTLYCLEANFILES += $(ocsp_index_data)
185
186# The "find" command builds a list of all certificates directly below
187# the CA that aren't for the ocsp-responder.
188%/ocsp_index.txt: $(x509_tokens) gen_ocsp_index
189        ./gen_ocsp_index $$(find $(*) -mindepth 2 -maxdepth 2 ! -path '*/ocsp-responder/*' -name x509.pem) > $@
190
191%/ocsp_index.txt.attr:
192        @mkdir -m 0700 -p $(dir $@)
[ea99ffe]193        echo "unique_subject = no" > $@
[20f8e99]194
[f828974]195# Build certificate chain files. Note that intermediate tokens must be
196# listed explicitly, or the dependency chain will be broken because
197# the higher level pattern matches, too.
198chain_tokens = authority/server/x509-chain.pem \
199        authority/subca/x509-chain.pem \
200        authority/subca/server/x509-chain.pem
201check_DATA += $(chain_tokens)
[7cfc02b]202MOSTLYCLEANFILES += $(chain_tokens) authority/x509-chain.pem
[ea99ffe]203endif
[9a4d250]204
[278381d]205# SoftHSM token, note that the SoftHSM 2 token is a directory
[c825c3a]206SOFTHSM2_TOKEN = authority/server/softhsm2.db
[b0e5dae]207# included in mostlyclean-local below
208clean-softhsm2-db:
209        -rm -rf $(SOFTHSM2_TOKEN)
210
[278381d]211if HAVE_SOFTHSM
[b0e5dae]212check_DATA += $(SOFTHSM2_TOKEN)
[278381d]213endif HAVE_SOFTHSM
[9a4d250]214
215check_DATA += make-test-dirs
216extra_dirs = logs cache outputs
217make-test-dirs:
218        mkdir -p $(extra_dirs)
[b0e5dae]219
[ee94de5]220.PHONY: make-test-dirs clean-softhsm2-db stop-gnupg-agent
221
[b0e5dae]222
[ee94de5]223mostlyclean-local: clean-softhsm2-db stop-gnupg-agent
[42829ae]224        -rmdir $(pgp_identities:=/private-keys-v1.d) || true
225if USE_MSVA
226        -rmdir $(msva_home)/private-keys-v1.d || true
227endif
[3f00958]228
[acea635]229# Delete test data directories, and wait for test services to
230# exit. The reason for the wait is that Apache instances may take some
231# time to exit and delete their PID files. Occasionally some PID files
232# where still around during "distcheck" runs by the time the target
233# checked if the build directory was really empty after "distclean",
234# breaking the build. Delaying "clean-local" until PID files are gone
235# avoids this issue, and the timeout will expose actually unclean
236# stops.
[9a4d250]237clean-local:
238        -rmdir $(extra_dirs) || true
239if USE_MSVA
240        -rmdir $(msva_home) || true
241endif
[acea635]242        wait=0; \
243        while ls *.pid && test "$$wait" -lt "@TEST_LOCK_WAIT@"; do \
244                wait=$$(($$wait + 1)); \
245                echo "waiting for test services to exit ($$wait seconds)"; \
246                sleep 1; \
247        done
[33af2b7]248
[9a4d250]249# Apache configuration and data files
[b674e95]250apache_data = base_apache.conf cgi_module.conf data/dump.cgi data/ocsp.cgi \
[9db4dcd]251        data/test.txt data/secret/mirror.cgi data/secret/test.txt \
252        mime.types proxy_mods.conf
[33af2b7]253
[a1ce49d]254# Documentation for the test system
255test_doc = README.md sample_fail.yml sample_test.yml
256
[c91382d]257EXTRA_DIST = $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
[ff039b1]258        authority/server/crl.template $(test_doc)
[52c3f68]259
[34e5dc7]260# Lockfile for the main Apache process
261test_lockfile = ./test.lock
[412ee84]262# Lockfile for the proxy backend Apache process (if any)
263backend_lockfile = ./backend.lock
[94430e6]264# Lockfile for the OCSP server Apache process (if any)
265ocsp_lockfile = ./ocsp.lock
[50eab8e]266
[34e5dc7]267# port for the main Apache server
268TEST_PORT ?= 9932
269# port for MSVA in test cases that use it
270MSVA_PORT ?= 9933
[97d7c63]271# port for TLS proxy backend server
272BACKEND_PORT ?= 9934
[3871dbd]273# port for plain HTTP server
274TEST_HTTP_PORT ?= 9935
[97d7c63]275# port for the OCSP responder
[21181b2]276if ENABLE_OCSP_TEST
277OCSP_PORT ?= 9936
[b47dc70]278OCSP_URI_TEMPLATE = ocsp_uri = http://$(TEST_HOST):$(OCSP_PORT)/ocsp/
[21181b2]279endif
[a61edfd]280# maximum time to wait for MSVA startup (milliseconds)
[4fb510d]281TEST_SERVICE_MAX_WAIT ?= 10000
[a61edfd]282# wait loop time for MSVA startup (milliseconds)
[4fb510d]283TEST_SERVICE_WAIT ?= 400
[34e5dc7]284
[5725dca]285AM_TESTS_ENVIRONMENT = export APACHE2=@APACHE2@; \
286        export AP_LIBEXECDIR=@AP_LIBEXECDIR@; \
[8335f8c]287        export PYTHON="@PYTHON@"; \
[6c030c1]288        export TEST_LOCK_WAIT="@TEST_LOCK_WAIT@"; \
[849b87e]289        export TEST_IP="@TEST_IP@"; \
[5725dca]290        export TEST_HOST="@TEST_HOST@"; \
[34e5dc7]291        export TEST_PORT="$(TEST_PORT)"; \
292        export MSVA_PORT="$(MSVA_PORT)"; \
[4fb510d]293        export TEST_SERVICE_MAX_WAIT="$(TEST_SERVICE_MAX_WAIT)"; \
294        export TEST_SERVICE_WAIT="$(TEST_SERVICE_WAIT)"; \
[6c030c1]295        export TEST_QUERY_TIMEOUT="@TEST_QUERY_TIMEOUT@"; \
[5725dca]296        export BACKEND_HOST="@TEST_HOST@"; \
[97d7c63]297        export BACKEND_PORT="$(BACKEND_PORT)"; \
[3871dbd]298        export TEST_HTTP_PORT="$(TEST_HTTP_PORT)"; \
[67f2f58]299        export HTTP_CLI="@HTTP_CLI@";
[f9f184f]300
[5eb4544]301if HAVE_SOFTHSM
[74772b2]302AM_TESTS_ENVIRONMENT += export SOFTHSM="@SOFTHSM@"; \
[a592762]303        export SOFTHSM_LIB="@SOFTHSM_LIB@";
[5eb4544]304endif
305
[21181b2]306if ENABLE_OCSP_TEST
307AM_TESTS_ENVIRONMENT += export OPENSSL="@OPENSSL@"; \
308        export OCSP_PORT="$(OCSP_PORT)";
309endif
310
[cf4e708]311if ENABLE_NETNS
[5725dca]312AM_TESTS_ENVIRONMENT += export UNSHARE="@UNSHARE@"; \
[cf4e708]313        export USE_TEST_NAMESPACE=1;
314endif
[94430e6]315# Without flock tests must not run in parallel, and PID files are used
316# to prevent conflicts between server instances. Otherwise set lock
317# files for flock.
[412ee84]318if DISABLE_FLOCK
[94430e6]319AM_TESTS_ENVIRONMENT += export TEST_LOCK="apache2.pid"; \
320        export BACKEND_LOCK="backend.pid"; \
321        export OCSP_LOCK="ocsp.pid";
[412ee84]322.NOTPARALLEL:
323else
[5725dca]324AM_TESTS_ENVIRONMENT += export FLOCK="@FLOCK@"; \
[412ee84]325        export TEST_LOCK="$(test_lockfile)"; \
[94430e6]326        export BACKEND_LOCK="$(backend_lockfile)"; \
327        export OCSP_LOCK="$(ocsp_lockfile)";
[412ee84]328endif
329
[f9f184f]330# Echo AM_TESTS_ENVIRONMENT. This can be useful for debugging, e.g. if
331# you want to manually run an Apache instance with Valgrind using the
332# same configuration as a test case.
333show-test-env: export TEST_ENV=$(AM_TESTS_ENVIRONMENT)
334show-test-env:
335        @echo "$${TEST_ENV}"
[a274959]336
337# Build the test suite README as HTML if pandoc is available.
338if USE_PANDOC
339noinst_DATA = README.html
340MOSTLYCLEANFILES += $(noinst_DATA)
341%.html: %.md $(srcdir)/../doc/style.css
342        $(PANDOC) --css $(filter %.css,$^) --metadata pagetitle="$(<)" --self-contained -f markdown -o $@ $<
343endif
Note: See TracBrowser for help on using the repository browser.