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