source: mod_gnutls/test/Makefile.am @ af412db

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

Integrate 29_force_handshake_vhost into 04_name_based_vhosts

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