source: mod_gnutls/test/Makefile.am @ 747a9c4

asyncio
Last change on this file since 747a9c4 was 747a9c4, checked in by Fiona Klute <fiona.klute@…>, 7 months ago

Create a new test for handling client-side handshake errors

Prior to f363569cf5563271019bfb439980c7ad08e5ac30 the test
09_verify_no_sni_fails_with_wrong_order expected the client to reject
the presented certificate. This is rather imprecise for vhost
selection testing, but did exercise an otherwise untested code path:
What happens if the client cancels the handshake?

This commit adds a new test explicitly covering that situation.

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