Changeset 7054040 in mod_gnutls


Ignore:
Timestamp:
Dec 7, 2019, 10:46:02 AM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, main, master, proxy-ticket
Children:
0e069b6
Parents:
8b72599
Message:

Support checking response headers

Location:
test
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/tests.py

    r8b72599 r7054040  
    136136        print(format_response(resp, body))
    137137        self.check_response(resp, body)
     138
     139    def check_headers(self, headers):
     140        for name, expected in self.expect['headers'].items():
     141            value = headers.get(name)
     142            expected = subst_env(expected)
     143            if value != expected:
     144                raise TestExpectationFailed(
     145                    f'Unexpected value in header {name}: "{value}", '
     146                    f'expected "{expected}"')
    138147
    139148    def check_body(self, body):
     
    177186                f'Unexpected status: {response.status} != '
    178187                f'{self.expect["status"]}')
     188        if 'headers' in self.expect:
     189            self.check_headers(dict(response.getheaders()))
    179190        if 'body' in self.expect:
    180191            self.check_body(body)
  • test/sample_test.yml

    r8b72599 r7054040  
    2121    expect:
    2222      status: 200
     23      headers:
     24        Content-Type: 'text/plain; charset=ISO-8859-1'
    2325      body:
    2426        contains:
Note: See TracChangeset for help on using the changeset viewer.