Changeset e3e0de1 in mod_gnutls
- Timestamp:
- Dec 7, 2019, 9:42:07 AM (3 years ago)
- Branches:
- asyncio, main, master, proxy-ticket
- Children:
- 8b72599
- Parents:
- 09d923b
- Location:
- test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
test/https-test-client.py
r09d923b re3e0de1 16 16 # limitations under the License. 17 17 18 import os 18 19 import yaml 19 20 … … 25 26 description='Send HTTP requests through gnutls-cli', 26 27 formatter_class=argparse.ArgumentDefaultsHelpFormatter) 27 parser.add_argument('host', nargs='?', help='Access the specified host', 28 default='localhost') 29 parser.add_argument('-p', '--port', type=int, 30 help='Access the specified port', default='8000') 28 parser.add_argument('host', nargs='?', default=None, 29 help='Access this host. Overrides TEST_TARGET, ' 30 'but not the test configuration file.') 31 parser.add_argument('-p', '--port', default=None, 32 help='Access this port. Overrides TEST_PORT, ' 33 'but not the test configuration file.') 31 34 parser.add_argument('--timeout', type=float, 32 35 help='Timeout for HTTP requests', default='5.0') … … 43 46 args = parser.parse_args() 44 47 48 if args.host: 49 os.environ['TEST_TARGET'] = args.host 50 if args.port: 51 os.environ['TEST_PORT'] = args.port 52 45 53 conns = None 46 54 … … 56 64 57 65 for test_conn in conns: 58 test_conn.run( host=args.host, port=args.port,timeout=args.timeout)66 test_conn.run(timeout=args.timeout) -
test/mgstest/tests.py
r09d923b re3e0de1 21 21 """ 22 22 23 import os 23 24 import re 24 25 import subprocess 25 26 import yaml 27 28 from string import Template 26 29 27 30 from . import TestExpectationFailed … … 42 45 yaml_tag = '!connection' 43 46 44 def __init__(self, actions, gnutls_params=[], transport='gnutls'): 47 def __init__(self, actions, host=None, port=None, gnutls_params=[], 48 transport='gnutls'): 45 49 self.gnutls_params = gnutls_params 46 50 self.actions = actions 47 51 self.transport = transport 52 if host: 53 self.host = subst_env(host) 54 else: 55 self.host = os.environ.get('TEST_TARGET', 'localhost') 56 if port: 57 self.port = int(subst_env(port)) 58 else: 59 self.port = int(os.environ.get('TEST_PORT', 8000)) 48 60 49 61 def __repr__(self): 50 62 return (f'{self.__class__.__name__!s}' 51 f'(gnutls_params={self.gnutls_params!r}, ' 63 f'(host={self.host!r}, port={self.port!r}, ' 64 f'gnutls_params={self.gnutls_params!r}, ' 52 65 f'actions={self.actions!r}, transport={self.transport!r})') 53 66 54 def run(self, host, port,timeout=5.0):67 def run(self, timeout=5.0): 55 68 # note: "--logfile" option requires GnuTLS version >= 3.6.7 56 69 command = ['gnutls-cli', '--logfile=/dev/stderr'] 57 70 for s in self.gnutls_params: 58 71 command.append('--' + s) 59 command = command + ['-p', str( port),host]60 61 conn = HTTPSubprocessConnection(command, host,port,72 command = command + ['-p', str(self.port), self.host] 73 74 conn = HTTPSubprocessConnection(command, self.host, self.port, 62 75 output_filter=filter_cert_log, 63 76 timeout=timeout) … … 322 335 s = s + '\n\n' + body 323 336 return s 337 338 339 340 def subst_env(text): 341 t = Template(text) 342 return t.substitute(os.environ) -
test/runtests
r09d923b re3e0de1 191 191 192 192 if [ -n "${TARGET_IP}" ]; then 193 TARGET="${TARGET_IP}"194 else 195 TARGET="${TEST_HOST}"196 fi 197 198 ${PYTHON} ${srcdir}/https-test-client.py -p "${TEST_PORT}" "${TARGET}"\193 export TEST_TARGET="${TARGET_IP}" 194 else 195 export TEST_TARGET="${TEST_HOST}" 196 fi 197 198 ${PYTHON} ${srcdir}/https-test-client.py \ 199 199 --test-config "${testdir}/test.yml" \ 200 200 --timeout "${TEST_QUERY_TIMEOUT}" \ -
test/tests/21_TLS_reverse_proxy_wrong_cert/test.yml
r09d923b re3e0de1 1 !connection 2 gnutls_params: 3 - x509cafile=authority/x509.pem 4 actions: 5 - !request 6 path: /proxy/test.txt 7 expect: 8 status: 502 9 body: 10 contains: 11 - 'Proxy Error' 12 - 'Error reading from remote server' 1 # The reverse proxy can't access the backend (certificate validation 2 # fails) 3 - !connection 4 gnutls_params: 5 - x509cafile=authority/x509.pem 6 actions: 7 - !request 8 path: /proxy/test.txt 9 expect: 10 status: 502 11 body: 12 contains: 13 - 'Proxy Error' 14 - 'Error reading from remote server' 15 16 # Check if the proxy itself works correctly and presents the expected 17 # bad certificate 18 - !connection 19 host: '${BACKEND_HOST}' 20 port: '${BACKEND_PORT}' 21 gnutls_params: 22 - x509cafile=authority/x509.pem 23 - verify-hostname=imposter.example 24 actions: 25 - !request 26 path: /test.txt 27 expect: 28 status: 200 29 body: 30 exactly: | 31 test
Note: See TracChangeset
for help on using the changeset viewer.