Changeset 1de6754 in mod_gnutls


Ignore:
Timestamp:
Dec 4, 2019, 9:56:07 AM (12 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
6ea34b1
Parents:
2e736df
Message:

Move code for running a test connection into TestConnection?.run()

File:
1 edited

Legend:

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

    r2e736df r1de6754  
    194194                f'actions={self.actions!r}, transport={self.transport!r})')
    195195
     196    def run(self, host, port, timeout=5.0):
     197        # note: "--logfile" option requires GnuTLS version >= 3.6.7
     198        command = ['gnutls-cli', '--logfile=/dev/stderr']
     199        for s in self.gnutls_params:
     200            command.append('--' + s)
     201        command = command + ['-p', str(port), host]
     202
     203        conn = HTTPSubprocessConnection(command, host, port,
     204                                        output_filter=filter_cert_log,
     205                                        timeout=timeout)
     206
     207        try:
     208            for act in self.actions:
     209                if type(act) is TestRequest:
     210                    act.run(conn)
     211                elif type(act) is TestRaw10:
     212                    act.run(command, timeout)
     213                else:
     214                    raise TypeError(f'Unsupported action requested: {act!r}')
     215        finally:
     216            conn.close()
     217
    196218    @classmethod
    197219    def _from_yaml(cls, loader, node):
     
    359381        raise TypeError(f'Unsupported configuration: {config!r}')
    360382
    361     # note: "--logfile" option requires GnuTLS version >= 3.6.7
    362     command = ['gnutls-cli', '--logfile=/dev/stderr']
    363     for s in test_conn.gnutls_params:
    364         command.append('--' + s)
    365     command = command + ['-p', str(args.port), args.host]
    366 
    367     conn = HTTPSubprocessConnection(command, args.host, port=args.port,
    368                                     output_filter=filter_cert_log,
    369                                     timeout=6.0)
    370 
    371     try:
    372         for act in test_conn.actions:
    373             if type(act) is TestRequest:
    374                 act.run(conn)
    375             elif type(act) is TestRaw10:
    376                 act.run(command, conn.timeout)
    377             else:
    378                 raise TypeError(f'Unsupported action requested: {act!r}')
    379     finally:
    380         conn.close()
     383    test_conn.run(host=args.host, port=args.port)
Note: See TracChangeset for help on using the changeset viewer.