Changeset 0e069b6 in mod_gnutls for test/mgstest/tests.py


Ignore:
Timestamp:
Dec 7, 2019, 11:22:36 AM (12 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
eb84747
Parents:
7054040
Message:

Support plain HTTP in the Python test framework

This makes it possible to run test 26 "redirect HTTP to HTTPS" without
an external HTTP client, the only thing still different from most
other tests is the TEST_HTTP_PORT environment variable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    r7054040 r0e069b6  
    2727import yaml
    2828
     29from enum import Enum, auto
     30from http.client import HTTPConnection
    2931from string import Template
    3032
    3133from . import TestExpectationFailed
    3234from .http import HTTPSubprocessConnection
     35
     36class Transports(Enum):
     37    GNUTLS = auto()
     38    PLAIN = auto()
     39
     40    def __repr__(self):
     41        return f'{self.__class__.__name__!s}.{self.name}'
    3342
    3443class TestConnection(yaml.YAMLObject):
     
    5059        self.gnutls_params = gnutls_params
    5160        self.actions = actions
    52         self.transport = transport
     61        self.transport = Transports[transport.upper()]
    5362        if host:
    5463            self.host = subst_env(host)
     
    7382        command = command + ['-p', str(self.port), self.host]
    7483
    75         conn = HTTPSubprocessConnection(command, self.host, self.port,
    76                                         output_filter=filter_cert_log,
    77                                         timeout=timeout)
     84        if self.transport == Transports.GNUTLS:
     85            conn = HTTPSubprocessConnection(command, self.host, self.port,
     86                                            output_filter=filter_cert_log,
     87                                            timeout=timeout)
     88        elif self.transport == Transports.PLAIN:
     89            conn = HTTPConnection(self.host, port=self.port,
     90                                  timeout=timeout)
    7891
    7992        try:
Note: See TracChangeset for help on using the changeset viewer.