source: mod_gnutls/test/Makefile.am @ d2f2f62

proxy-ticket
Last change on this file since d2f2f62 was e60e3b9, checked in by Krista Karppinen <krista.celestia@…>, 7 months ago

Add test for checking nonce in OCSP response

Identical to 27-OCSP-server test, except nonce is explicitly
enabled in configuration and checked to be received (no
verification yet)

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