source: mod_gnutls/test/Makefile.am @ c33b0ea

asynciomainproxy-ticket
Last change on this file since c33b0ea was 9db4dcd, checked in by Fiona Klute <fiona.klute@…>, 3 years 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
Line 
1SUBDIRS = tests
2
3# Generate the test scripts
4test-%.bash: test-template.bash.in | tests/%/
5        testname="$(*)"; sed s/@NUMBER@/$${testname%%_*}/ < $< > $@
6        chmod a+x $@
7
8test_scripts = test-00_basic.bash \
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 \
22        test-14_resume_session.bash
23if USE_MSVA
24test_scripts += test-15_basic_msva.bash
25endif
26test_scripts += test-16_view-status.bash \
27        test-17_cgi_vars_large_cert.bash \
28        test-18_client_verification_wrong_cert.bash \
29        test-19_TLS_reverse_proxy.bash \
30        test-20_TLS_reverse_proxy_client_auth.bash \
31        test-21_TLS_reverse_proxy_wrong_cert.bash \
32        test-22_TLS_reverse_proxy_crl_revoke.bash \
33        test-23_TLS_reverse_proxy_mismatched_priorities.bash \
34        test-24_pkcs11_cert.bash \
35        test-25_Disable_TLS_1.0.bash \
36        test-26_redirect_HTTP_to_HTTPS.bash \
37        test-27_OCSP_server.bash \
38        test-28_HTTP2_support.bash \
39        test-29_force_handshake_vhost.bash \
40        test-30_ip_based_vhosts.bash \
41        test-31_vhost_SNI_serveralias_match.bash \
42        test-32_vhost_SNI_serveralias_mismatch.bash \
43        test-33_vhost_SNI_serveralias_missinghost.bash \
44        test-34_TLS_reverse_proxy_h2.bash \
45        test-35_client_reauth.bash
46
47MOSTLYCLEANFILES = $(test_scripts)
48dist_check_SCRIPTS = netns_py.bash test-template.bash.in
49
50TEST_EXTENSIONS = .bash .py
51PY_LOG_COMPILER = $(PYTHON)
52TESTS = doctest-mgstest.py $(test_scripts)
53
54check_PROGRAMS = pgpcrc
55pgpcrc_SOURCES = pgpcrc.c
56
57# build OCSP database tool
58if ENABLE_OCSP_TEST
59check_PROGRAMS += gen_ocsp_index
60gen_ocsp_index_SOURCES = gen_ocsp_index.c cert_helper.c
61gen_ocsp_index_CFLAGS = $(LIBGNUTLS_CFLAGS)
62gen_ocsp_index_LDFLAGS = $(LIBGNUTLS_LIBS)
63noinst_HEADERS = cert_helper.h
64endif
65
66# Python tools for tests
67noinst_PYTHON = https-test-client.py mgstest/http.py mgstest/__init__.py \
68        mgstest/hooks.py mgstest/services.py mgstest/softhsm.py \
69        mgstest/tests.py runtest.py softhsm-init.py doctest-mgstest.py
70
71# Identities in the miniature CA, server, and client environment for
72# the test suite
73shared_identities = authority authority/client
74pgp_identities = $(shared_identities)
75x509_only_identities = authority/server authority/imposter \
76        authority/subca authority/subca/server \
77        rogueca rogueca/rogueclient
78if ENABLE_OCSP_TEST
79x509_only_identities += authority/ocsp-responder authority/subca/ocsp-responder
80endif
81x509_identities = $(shared_identities) $(x509_only_identities)
82identities = $(shared_identities) $(x509_only_identities)
83# Append strings after ":=" to each identity to generate a list of
84# necessary files
85pgp_tokens = $(pgp_identities:=/cert.pgp) \
86        $(pgp_identities:=/secret.pgp)
87x509_keys = $(x509_identities:=/secret.key)
88x509_certs = $(x509_identities:=/x509.pem)
89x509_tokens = $(x509_certs) $(x509_keys)
90tokens = $(x509_tokens)
91if USE_MSVA
92tokens += $(pgp_tokens)
93endif
94
95if !DISABLE_FLOCK
96# flock command for write access to the authority keyring
97GPG_FLOCK = @FLOCK@ authority/lock
98endif
99
100include $(srcdir)/test_ca.mk
101
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.
112check_DATA = $(tokens) authority/server/crl.pem
113
114MOSTLYCLEANFILES += cache/* logs/* outputs/* authority/server/crl.pem
115
116cert_templates = authority/template.in authority/client/template.in \
117        authority/imposter/template.in authority/ocsp-responder/template \
118        authority/server/template.in \
119        authority/subca/template.in authority/subca/server/template.in \
120        authority/subca/ocsp-responder/template \
121        rogueca/template rogueca/rogueclient/template.in
122generated_templates = authority/template authority/client/template \
123        authority/imposter/template rogueca/rogueclient/template \
124        authority/server/template
125
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
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
134# (e.g. host names) without wasting time on new keys (which would
135# happen after "clean").
136MOSTLYCLEANFILES += $(x509_certs) $(generated_templates) $(identities:=/uid)
137
138
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.
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
147# GnuPG random pool, no need to regenerate on every build
148CLEANFILES += authority/random_seed
149
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
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
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
172        mkdir -p -m 0700 $(dir $@)
173        GNUPGHOME=$(dir $@) gpg --import < $<
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
175        GNUPGHOME=$(dir $@) gpg --import < authority/client/cert.pgp
176        printf "keyserver does-not-exist.example\n" > $(msva_home)/gpg.conf
177endif
178
179if ENABLE_OCSP_TEST
180# rules to build OCSP database
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 $@)
193        echo "unique_subject = no" > $@
194
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)
202MOSTLYCLEANFILES += $(chain_tokens) authority/x509-chain.pem
203endif
204
205# SoftHSM token, note that the SoftHSM 2 token is a directory
206SOFTHSM2_TOKEN = authority/server/softhsm2.db
207# included in mostlyclean-local below
208clean-softhsm2-db:
209        -rm -rf $(SOFTHSM2_TOKEN)
210
211if HAVE_SOFTHSM
212check_DATA += $(SOFTHSM2_TOKEN)
213endif HAVE_SOFTHSM
214
215check_DATA += make-test-dirs
216extra_dirs = logs cache outputs
217make-test-dirs:
218        mkdir -p $(extra_dirs)
219
220.PHONY: make-test-dirs clean-softhsm2-db stop-gnupg-agent
221
222
223mostlyclean-local: clean-softhsm2-db stop-gnupg-agent
224        -rmdir $(pgp_identities:=/private-keys-v1.d) || true
225if USE_MSVA
226        -rmdir $(msva_home)/private-keys-v1.d || true
227endif
228
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.
237clean-local:
238        -rmdir $(extra_dirs) || true
239if USE_MSVA
240        -rmdir $(msva_home) || true
241endif
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
248
249# Apache configuration and data files
250apache_data = base_apache.conf cgi_module.conf data/dump.cgi data/ocsp.cgi \
251        data/test.txt data/secret/mirror.cgi data/secret/test.txt \
252        mime.types proxy_mods.conf
253
254# Documentation for the test system
255test_doc = README.md sample_fail.yml sample_test.yml
256
257EXTRA_DIST = $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
258        authority/server/crl.template $(test_doc)
259
260# Lockfile for the main Apache process
261test_lockfile = ./test.lock
262# Lockfile for the proxy backend Apache process (if any)
263backend_lockfile = ./backend.lock
264# Lockfile for the OCSP server Apache process (if any)
265ocsp_lockfile = ./ocsp.lock
266
267# port for the main Apache server
268TEST_PORT ?= 9932
269# port for MSVA in test cases that use it
270MSVA_PORT ?= 9933
271# port for TLS proxy backend server
272BACKEND_PORT ?= 9934
273# port for plain HTTP server
274TEST_HTTP_PORT ?= 9935
275# port for the OCSP responder
276if ENABLE_OCSP_TEST
277OCSP_PORT ?= 9936
278OCSP_URI_TEMPLATE = ocsp_uri = http://$(TEST_HOST):$(OCSP_PORT)/ocsp/
279endif
280# maximum time to wait for MSVA startup (milliseconds)
281TEST_SERVICE_MAX_WAIT ?= 10000
282# wait loop time for MSVA startup (milliseconds)
283TEST_SERVICE_WAIT ?= 400
284
285AM_TESTS_ENVIRONMENT = export APACHE2=@APACHE2@; \
286        export AP_LIBEXECDIR=@AP_LIBEXECDIR@; \
287        export PYTHON="@PYTHON@"; \
288        export TEST_LOCK_WAIT="@TEST_LOCK_WAIT@"; \
289        export TEST_IP="@TEST_IP@"; \
290        export TEST_HOST="@TEST_HOST@"; \
291        export TEST_PORT="$(TEST_PORT)"; \
292        export MSVA_PORT="$(MSVA_PORT)"; \
293        export TEST_SERVICE_MAX_WAIT="$(TEST_SERVICE_MAX_WAIT)"; \
294        export TEST_SERVICE_WAIT="$(TEST_SERVICE_WAIT)"; \
295        export TEST_QUERY_TIMEOUT="@TEST_QUERY_TIMEOUT@"; \
296        export BACKEND_HOST="@TEST_HOST@"; \
297        export BACKEND_PORT="$(BACKEND_PORT)"; \
298        export TEST_HTTP_PORT="$(TEST_HTTP_PORT)"; \
299        export HTTP_CLI="@HTTP_CLI@";
300
301if HAVE_SOFTHSM
302AM_TESTS_ENVIRONMENT += export SOFTHSM="@SOFTHSM@"; \
303        export SOFTHSM_LIB="@SOFTHSM_LIB@";
304endif
305
306if ENABLE_OCSP_TEST
307AM_TESTS_ENVIRONMENT += export OPENSSL="@OPENSSL@"; \
308        export OCSP_PORT="$(OCSP_PORT)";
309endif
310
311if ENABLE_NETNS
312AM_TESTS_ENVIRONMENT += export UNSHARE="@UNSHARE@"; \
313        export USE_TEST_NAMESPACE=1;
314endif
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.
318if DISABLE_FLOCK
319AM_TESTS_ENVIRONMENT += export TEST_LOCK="apache2.pid"; \
320        export BACKEND_LOCK="backend.pid"; \
321        export OCSP_LOCK="ocsp.pid";
322.NOTPARALLEL:
323else
324AM_TESTS_ENVIRONMENT += export FLOCK="@FLOCK@"; \
325        export TEST_LOCK="$(test_lockfile)"; \
326        export BACKEND_LOCK="$(backend_lockfile)"; \
327        export OCSP_LOCK="$(ocsp_lockfile)";
328endif
329
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}"
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.