Changeset 7054040 in mod_gnutls for test/mgstest/tests.py


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

Support checking response headers

File:
1 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)
Note: See TracChangeset for help on using the changeset viewer.