source: mod_gnutls/test/Makefile.am @ f828974

proxy-ticket
Last change on this file since f828974 was f828974, checked in by Fiona Klute <fiona.klute@…>, 15 months ago

Test suite: Build & use certificate chain for the authority/subca/server ID

  • Property mode set to 100644
File size: 11.3 KB
Line 
1SUBDIRS = tests
2
3dist_check_SCRIPTS = test-00_basic.bash \
4        test-01_serverwide_priorities.bash \
5        test-02_cache_in_vhost.bash \
6        test-03_cachetimeout_in_vhost.bash \
7        test-04_basic_nosni.bash \
8        test-05_mismatched-priorities.bash \
9        test-06_verify_sni_a.bash \
10        test-07_verify_sni_b.bash \
11        test-08_verify_no_sni_fallback_to_first_vhost.bash \
12        test-09_verify_no_sni_fails_with_wrong_order.bash \
13        test-10_basic_client_verification.bash \
14        test-11_basic_client_verification_fail.bash \
15        test-12_cgi_variables.bash \
16        test-13_cgi_variables_no_client_cert.bash \
17        test-14_resume_session.bash
18if USE_MSVA
19dist_check_SCRIPTS += test-15_basic_msva.bash
20endif
21dist_check_SCRIPTS += test-16_view-status.bash \
22        test-17_cgi_vars_large_cert.bash \
23        test-18_client_verification_wrong_cert.bash \
24        test-19_TLS_reverse_proxy.bash \
25        test-20_TLS_reverse_proxy_client_auth.bash \
26        test-21_TLS_reverse_proxy_wrong_cert.bash \
27        test-22_TLS_reverse_proxy_crl_revoke.bash \
28        test-23_TLS_reverse_proxy_mismatched_priorities.bash \
29        test-24_pkcs11_cert.bash \
30        test-25_Disable_TLS_1.0.bash \
31        test-26_redirect_HTTP_to_HTTPS.bash \
32        test-27_OCSP_server.bash \
33        test-28_HTTP2_support.bash \
34        test-29_force_handshake_vhost.bash \
35        test-30_ip_based_vhosts.bash \
36        test-31_vhost_SNI_serveralias_match.bash \
37        test-32_vhost_SNI_serveralias_mismatch.bash \
38        test-33_vhost_SNI_serveralias_missinghost.bash \
39        test-34_TLS_reverse_proxy_h2.bash
40
41TEST_EXTENSIONS = .bash
42TESTS = $(dist_check_SCRIPTS)
43
44check_PROGRAMS = pgpcrc
45pgpcrc_SOURCES = pgpcrc.c
46
47# build OCSP database tool
48if ENABLE_OCSP_TEST
49check_PROGRAMS += gen_ocsp_index
50gen_ocsp_index_SOURCES = gen_ocsp_index.c cert_helper.c
51gen_ocsp_index_CFLAGS = $(LIBGNUTLS_CFLAGS)
52gen_ocsp_index_LDFLAGS = $(LIBGNUTLS_LIBS)
53noinst_HEADERS = cert_helper.h
54endif
55
56# Identities in the miniature CA, server, and client environment for
57# the test suite
58shared_identities = authority authority/client
59pgp_identities = $(shared_identities)
60x509_only_identities = authority/server authority/imposter \
61        authority/subca authority/subca/server \
62        rogueca rogueca/rogueclient
63if ENABLE_OCSP_TEST
64x509_only_identities += authority/ocsp-responder
65endif
66x509_identities = $(shared_identities) $(x509_only_identities)
67identities = $(shared_identities) $(x509_only_identities)
68# Append strings after ":=" to each identity to generate a list of
69# necessary files
70pgp_tokens = $(pgp_identities:=/cert.pgp) \
71        $(pgp_identities:=/secret.pgp)
72x509_keys = $(x509_identities:=/secret.key)
73x509_certs = $(x509_identities:=/x509.pem)
74x509_tokens = $(x509_certs) $(x509_keys)
75tokens = $(x509_tokens)
76if USE_MSVA
77tokens += $(pgp_tokens)
78endif
79
80if !DISABLE_FLOCK
81# flock command for write access to the authority keyring
82GPG_FLOCK = @FLOCK@ authority/lock
83endif
84
85include $(srcdir)/test_ca.mk
86
87# Test cases trying to create keys and certificates in parallel causes
88# race conditions. Ensure that all keys and certificates are generated
89# before tests get to run.
90#
91# NOTE: Once the support files have been generated, test cases can be
92# run with multiple jobs, but real parallelization would require
93# dynamic port assignments. At the moment, lock files ensure that only
94# one Apache instance (possibly plus a proxy back end instance) is
95# running at any time, so test cases actually have to wait for each
96# other - just not in any particular order.
97check_DATA = $(tokens) authority/server/crl.pem
98
99MOSTLYCLEANFILES = cache/* logs/* outputs/* authority/server/crl.pem
100
101cert_templates = authority/template.in authority/client/template.in \
102        authority/imposter/template.in authority/ocsp-responder/template \
103        authority/server/template.in \
104        authority/subca/template.in authority/subca/server/template.in \
105        rogueca/template rogueca/rogueclient/template.in
106generated_templates = authority/template authority/client/template \
107        authority/imposter/template rogueca/rogueclient/template \
108        authority/server/template
109
110# Delete X.509 private keys on full clean. Note that unless you need
111# to generate fresh keys, the "mostlyclean" target should be
112# sufficient (see below).
113CLEANFILES = $(x509_keys)
114
115# Delete X.509 certificates and generated templates on "mostlyclean"
116# target. Certificates can be rebuilt without generating new key
117# pairs, and regenerating them makes it possible to change identities
118# (e.g. host names) without wasting time on new keys (which would
119# happen after "clean").
120MOSTLYCLEANFILES += $(x509_certs) $(generated_templates) $(identities:=/uid)
121
122
123# Delete PGP keyrings on "mostlyclean" target. They are created from
124# the X.509 private keys and certificates with an expiration time of
125# one day, so regenerating them is both fast and frequently
126# necessary.
127pgp_patterns = /*.pgp /*.pgp.raw /*.gpg /*.gpg~ /gpg.conf \
128        /*.kbx /*.kbx~ /S.gpg-agent /private-keys-v1.d/*
129MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(pgp_identities:=$(pat))) \
130        authority/lock authority/tofu.db
131# GnuPG random pool, no need to regenerate on every build
132CLEANFILES += authority/random_seed
133
134# GnuPG 2 starts gpg-agent processes per GNUPGHOME (one for every PGP
135# identity) while creating the PGP certificates. This target is called
136# by both "check-local" and "mostlyclean-local": The former because
137# agent processes are started while preparing for "check" and are no
138# longer needed afterwards, the latter to make sure they are gone
139# along with their certificates.
140stop-gnupg-agent:
141        for id in $(pgp_identities) $(msva_home); do \
142                GNUPGHOME=$$id/ gpgconf --kill gpg-agent || true; \
143        done
144
145check-local: stop-gnupg-agent
146
147# Delete lock files for test servers on "mostlyclean" target.
148MOSTLYCLEANFILES += *.lock
149
150# rule to build MSVA trust database
151if USE_MSVA
152msva_home = msva.gnupghome
153check_DATA += $(msva_home)/trustdb.gpg authority/client/uid
154MOSTLYCLEANFILES += $(foreach pat,$(pgp_patterns),$(msva_home)$(pat))
155$(msva_home)/trustdb.gpg: authority/minimal.pgp authority/client/cert.pgp
156        mkdir -p -m 0700 $(dir $@)
157        GNUPGHOME=$(dir $@) gpg --import < $<
158        printf "%s:6:\n" "$$(GNUPGHOME=authority/ gpg --with-colons --list-secret-keys --fingerprint | grep ^fpr: | cut -f 10 -d :)" | GNUPGHOME=$(dir $@) gpg --import-ownertrust
159        GNUPGHOME=$(dir $@) gpg --import < authority/client/cert.pgp
160        printf "keyserver does-not-exist.example\n" > $(msva_home)/gpg.conf
161endif
162
163if ENABLE_OCSP_TEST
164# rules to build OCSP database
165check_DATA += authority/ocsp_index.txt
166MOSTLYCLEANFILES += authority/ocsp_index.txt authority/ocsp_index.txt.attr
167authority/ocsp_index.txt: $(x509_tokens) gen_ocsp_index authority/ocsp_index.txt.attr
168        ./gen_ocsp_index authority/server/x509.pem authority/client/x509.pem > $@
169
170authority/ocsp_index.txt.attr: authority/secret.key
171        echo "unique_subject = no" > $@
172
173# Build certificate chain files. Note that intermediate tokens must be
174# listed explicitly, or the dependency chain will be broken because
175# the higher level pattern matches, too.
176chain_tokens = authority/server/x509-chain.pem \
177        authority/subca/x509-chain.pem \
178        authority/subca/server/x509-chain.pem
179check_DATA += $(chain_tokens)
180MOSTLYCLEANFILES += $(chain_tokens)
181endif
182
183# SoftHSM tokens. Note that the SoftHSM 2 token is a directory and
184# hence has to be treated slightly differently.
185SOFTHSM_TOKEN = authority/server/softhsm.db
186SOFTHSM2_TOKEN = authority/server/softhsm2.db
187
188# Tokens should be cleaned whether or not the matching SoftHSM version
189# was detected on the last ./configure run.
190MOSTLYCLEANFILES += $(SOFTHSM_TOKEN)
191# included in mostlyclean-local below
192clean-softhsm2-db:
193        -rm -rf $(SOFTHSM2_TOKEN)
194
195if HAVE_SOFTHSM1
196check_DATA += $(SOFTHSM_TOKEN)
197endif HAVE_SOFTHSM1
198
199if HAVE_SOFTHSM2
200check_DATA += $(SOFTHSM2_TOKEN)
201endif HAVE_SOFTHSM2
202
203check_DATA += make-test-dirs
204extra_dirs = logs cache outputs
205make-test-dirs:
206        mkdir -p $(extra_dirs)
207
208.PHONY: make-test-dirs clean-softhsm2-db stop-gnupg-agent
209
210
211mostlyclean-local: clean-softhsm2-db stop-gnupg-agent
212        -rmdir $(pgp_identities:=/private-keys-v1.d) || true
213if USE_MSVA
214        -rmdir $(msva_home)/private-keys-v1.d || true
215endif
216
217# Delete test data directories, and wait for test services to
218# exit. The reason for the wait is that Apache instances may take some
219# time to exit and delete their PID files. Occasionally some PID files
220# where still around during "distcheck" runs by the time the target
221# checked if the build directory was really empty after "distclean",
222# breaking the build. Delaying "clean-local" until PID files are gone
223# avoids this issue, and the timeout will expose actually unclean
224# stops.
225clean-local:
226        -rmdir $(extra_dirs) || true
227if USE_MSVA
228        -rmdir $(msva_home) || true
229endif
230        wait=0; \
231        while ls *.pid && test "$$wait" -lt "@TEST_LOCK_WAIT@"; do \
232                wait=$$(($$wait + 1)); \
233                echo "waiting for test services to exit ($$wait seconds)"; \
234                sleep 1; \
235        done
236
237# Apache configuration and data files
238apache_data = base_apache.conf cgi_module.conf data/dump.cgi data/ocsp.cgi \
239        data/secret.txt data/test.txt ffdhe3072.pem mime.types \
240        proxy_mods.conf
241
242EXTRA_DIST = $(apache_data) $(cert_templates) $(shared_identities:=/uid.in) \
243        apache_service.bash common.bash runtests authority/server/crl.template \
244        softhsm.bash
245
246# Lockfile for the main Apache process
247test_lockfile = ./test.lock
248# Lockfile for the proxy backend Apache process (if any)
249backend_lockfile = ./backend.lock
250# Lockfile for the OCSP server Apache process (if any)
251ocsp_lockfile = ./ocsp.lock
252
253# port for the main Apache server
254TEST_PORT ?= 9932
255# port for MSVA in test cases that use it
256MSVA_PORT ?= 9933
257# port for TLS proxy backend server
258BACKEND_PORT ?= 9934
259# port for the OCSP responder
260if ENABLE_OCSP_TEST
261OCSP_PORT ?= 9936
262OCSP_URI_TEMPLATE = ocsp_uri = http://$(TEST_HOST):$(OCSP_PORT)/ocsp/
263endif
264# maximum time to wait for MSVA startup (milliseconds)
265TEST_SERVICE_MAX_WAIT ?= 10000
266# wait loop time for MSVA startup (milliseconds)
267TEST_SERVICE_WAIT ?= 400
268
269AM_TESTS_ENVIRONMENT = export APACHE2=@APACHE2@; \
270        export AP_LIBEXECDIR=@AP_LIBEXECDIR@; \
271        export TEST_LOCK_WAIT="@TEST_LOCK_WAIT@"; \
272        export TEST_IP="@TEST_IP@"; \
273        export TEST_HOST="@TEST_HOST@"; \
274        export TEST_PORT="$(TEST_PORT)"; \
275        export MSVA_PORT="$(MSVA_PORT)"; \
276        export TEST_SERVICE_MAX_WAIT="$(TEST_SERVICE_MAX_WAIT)"; \
277        export TEST_SERVICE_WAIT="$(TEST_SERVICE_WAIT)"; \
278        export TEST_QUERY_TIMEOUT="@TEST_QUERY_TIMEOUT@"; \
279        export BACKEND_HOST="@TEST_HOST@"; \
280        export BACKEND_PORT="$(BACKEND_PORT)"; \
281        export HTTP_CLI="@HTTP_CLI@";
282
283if HAVE_SOFTHSM
284AM_TESTS_ENVIRONMENT += export SOFTHSM="@SOFTHSM@"; \
285        export SOFTHSM_MAJOR_VERSION="@SOFTHSM_MAJOR_VERSION@"; \
286        export SOFTHSM_LIB="@SOFTHSM_LIB@"
287endif
288
289if ENABLE_OCSP_TEST
290AM_TESTS_ENVIRONMENT += export OPENSSL="@OPENSSL@"; \
291        export OCSP_PORT="$(OCSP_PORT)";
292endif
293
294if ENABLE_NETNS
295AM_TESTS_ENVIRONMENT += export UNSHARE="@UNSHARE@"; \
296        export USE_TEST_NAMESPACE=1;
297endif
298# Without flock tests must not run in parallel, and PID files are used
299# to prevent conflicts between server instances. Otherwise set lock
300# files for flock.
301if DISABLE_FLOCK
302AM_TESTS_ENVIRONMENT += export TEST_LOCK="apache2.pid"; \
303        export BACKEND_LOCK="backend.pid"; \
304        export OCSP_LOCK="ocsp.pid";
305.NOTPARALLEL:
306else
307AM_TESTS_ENVIRONMENT += export FLOCK="@FLOCK@"; \
308        export TEST_LOCK="$(test_lockfile)"; \
309        export BACKEND_LOCK="$(backend_lockfile)"; \
310        export OCSP_LOCK="$(ocsp_lockfile)";
311endif
312
313# Echo AM_TESTS_ENVIRONMENT. This can be useful for debugging, e.g. if
314# you want to manually run an Apache instance with Valgrind using the
315# same configuration as a test case.
316show-test-env: export TEST_ENV=$(AM_TESTS_ENVIRONMENT)
317show-test-env:
318        @echo "$${TEST_ENV}"
Note: See TracBrowser for help on using the repository browser.