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

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

Fix flake8 warnings in test hooks.py

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