source: mod_gnutls/test/tests/16_view-status/hooks.py @ 2d25c1c

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

Test 16_view-status: Use post_check hook for GnuTLS 3.6.11 compatibility

Since 3.6.11 GnuTLS lists the certificate type used for authentication
in the TLS session information. In most tests (including this one) the
client does not authenticate, so the strings aren't exactly
equivalent. The new hook takes this into consideration.

  • Property mode set to 100644
File size: 1.5 KB
Line 
1from mgstest import first_line_match, TestExpectationFailed
2import re
3
4def post_check(conn_log, response_log):
5    """Compare the TLS session information reported by gnutls-cli and the
6    mod_gnutls status listing."""
7
8    # Group 1 is the TLS version, group 2 the ciphers. The certificate
9    # type that may be enclosed in the same brackets as the TLS
10    # version is ignored.
11    re_session = '\((TLS[\d\.]+).*?\)-(.*)'
12
13    # Prefix for gnutls-cli output
14    re_cli = re.compile('(?<=^-\sDescription:\s)' + re_session + '$')
15    # Prefix in mod_status output provided by mod_gnutls
16    re_status = re.compile('(?<=^Current TLS session:\s)' + re_session + '$')
17
18    cli_suite = first_line_match(re_cli, conn_log)
19    if not cli_suite:
20        raise TestExpectationFailed(
21            'Client cipher suite information is missing!')
22    status_suite = first_line_match(re_status, response_log)
23    if not status_suite:
24        raise TestExpectationFailed(
25            'Server cipher suite information is missing!')
26
27    print(f'Client session info: {cli_suite.group(0)}')
28    print(f'Server session info: {status_suite.group(0)}')
29
30    if cli_suite.group(1) != status_suite.group(1):
31        raise TestExpectationFailed(
32            f'Client ({cli_suite.group(1)}) and server '
33            f'({status_suite.group(1)}) report different protocols!')
34
35    if cli_suite.group(2) != status_suite.group(2):
36        raise TestExpectationFailed(
37            f'Client ({cli_suite.group(2)}) and server '
38            f'({status_suite.group(2)}) report different ciphers!')
Note: See TracBrowser for help on using the repository browser.