Changeset 2e736df in mod_gnutls


Ignore:
Timestamp:
Dec 4, 2019, 9:41:20 AM (10 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
1de6754
Parents:
ce85a5f
Message:

https-test-client.py: Require --test-config parameter

This allows a lot of simplifications in the code, in particular it
limits the amount of parameters that influence the gnutls-cli command
to host and port.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/https-test-client.py

    rce85a5f r2e736df  
    336336    parser.add_argument('host', nargs='?', help='Access the specified host',
    337337                        default='localhost')
    338     parser.add_argument('--insecure', action='store_true',
    339                         help='do not validate the server certificate')
    340338    parser.add_argument('-p', '--port', type=int,
    341339                        help='Access the specified port', default='8000')
    342     parser.add_argument('--x509cafile', type=str,
    343                         help='Use the specified CA to validate the '
    344                         'server certificate')
    345340    parser.add_argument('--test-config', type=argparse.FileType('r'),
    346                         help='load YAML test configuration')
     341                        required=True, help='load YAML test configuration')
    347342
    348343    # enable bash completion if argcomplete is available
     
    356351
    357352    test_conn = None
    358     test_actions = None
    359 
    360     if args.test_config:
    361         config = yaml.load(args.test_config, Loader=yaml.Loader)
    362         if type(config) is TestConnection:
    363             test_conn = config
    364             print(test_conn)
    365             test_actions = test_conn.actions
     353
     354    config = yaml.load(args.test_config, Loader=yaml.Loader)
     355    if type(config) is TestConnection:
     356        test_conn = config
     357        print(test_conn)
    366358    else:
    367         # simple default request
    368         test_actions = [TestRequest(path='/test.txt',
    369                                     expect={'status': 200, 'body': 'test\n'},
    370                                     method='GET')]
    371 
     359        raise TypeError(f'Unsupported configuration: {config!r}')
    372360
    373361    # note: "--logfile" option requires GnuTLS version >= 3.6.7
    374362    command = ['gnutls-cli', '--logfile=/dev/stderr']
    375     if args.insecure:
    376         command.append('--insecure')
    377     if args.x509cafile:
    378         command.append('--x509cafile')
    379         command.append(args.x509cafile)
    380     if test_conn != None:
    381         for s in test_conn.gnutls_params:
    382             command.append('--' + s)
     363    for s in test_conn.gnutls_params:
     364        command.append('--' + s)
    383365    command = command + ['-p', str(args.port), args.host]
    384366
     
    388370
    389371    try:
    390         for act in test_actions:
     372        for act in test_conn.actions:
    391373            if type(act) is TestRequest:
    392374                act.run(conn)
Note: See TracChangeset for help on using the changeset viewer.