Changeset bdf5917 in mod_gnutls


Ignore:
Timestamp:
Jan 5, 2020, 3:52:55 AM (3 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master
Children:
0b3733d
Parents:
fa14c32
git-author:
Fiona Klute <fiona.klute@…> (01/05/20 03:40:46)
git-committer:
Fiona Klute <fiona.klute@…> (01/05/20 03:52:55)
Message:

TestReq10: Implement checking expected headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    rfa14c32 rbdf5917  
    329329    """
    330330    yaml_tag = '!request10'
    331     status_re = re.compile('^HTTP/([\d\.]+) (\d+) (.*)$')
     331    status_re = re.compile(r'^HTTP/([\d\.]+) (\d+) (.*)$')
     332    header_re = re.compile(r'^([-\w]+):\s+(.*)$')
    332333
    333334    def __init__(self, **kwargs):
     
    364365        status, rest = outs.decode().split('\r\n', maxsplit=1)
    365366        # headers and body are separated by double newline
    366         headers, body = rest.split('\r\n\r\n', maxsplit=1)
     367        head, body = rest.split('\r\n\r\n', maxsplit=1)
    367368        # log response for debugging
    368         print(f'{status}\n{headers}\n\n{body}')
     369        print(f'{status}\n{head}\n\n{body}')
    369370        if response_log:
    370             print(f'{status}\n{headers}\n\n{body}', file=response_log)
     371            print(f'{status}\n{head}\n\n{body}', file=response_log)
    371372
    372373        m = self.status_re.match(status)
     
    380381        else:
    381382            raise TestExpectationFailed(f'Invalid status line: "{status}"')
     383
     384        if 'headers' in self.expect:
     385            headers = dict()
     386            for line in head.splitlines():
     387                m = self.header_re.fullmatch(line)
     388                if m:
     389                    headers[m.group(1)] = m.group(2)
     390            self.check_headers(headers)
    382391
    383392        if 'body' in self.expect:
Note: See TracChangeset for help on using the changeset viewer.