source: mod_gnutls/test/Makefile.am @ a21794d

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

Integrate 31_vhost_SNI_serveralias_match into 04_name_based_vhosts

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