source: mod_gnutls/test/Makefile.am

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

Test what happens if the HTTPS server receives plaintext

The new test tries to

  • send an unencrypted HTTP request to the HTTPS port,
  • establish a TLS connection, send a proper HTTPS request, then send a plaintext HTTP request over the same TCP connections.

In both cases the server has to respond with an appropriate alert.

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