Changeset 019ab8e in mod_gnutls


Ignore:
Timestamp:
Dec 1, 2019, 1:30:59 PM (11 months ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
master, proxy-ticket
Children:
dec05c4
Parents:
8335f8c
Message:

https-test-client.py: Catch expected connection errors

Location:
test
Files:
1 added
1 edited

Legend:

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

    r8335f8c r019ab8e  
    113113
    114114    def check_response(self, response, body):
     115        if self.expects_conn_reset():
     116            raise TestExpectationFailed(
     117                'Got a response, but connection should have failed!')
    115118        if response.status != self.expect['status']:
    116119            raise TestExpectationFailed(
     
    119122        if 'body' in self.expect:
    120123            self._check_body(body)
     124
     125    def expects_conn_reset(self):
     126        if 'reset' in self.expect:
     127            return self.expect['reset']
     128        return False
    121129
    122130    @classmethod
     
    227235        for act in test_actions:
    228236            if type(act) is TestRequest:
    229                 # Add headers={'Host': 'test.host'} to provoke "421
    230                 # Misdirected
    231                 conn.request(act.method, act.path, headers=act.headers)
    232                 resp = conn.getresponse()
     237                try:
     238                    conn.request(act.method, act.path, headers=act.headers)
     239                    resp = conn.getresponse()
     240                except ConnectionResetError as err:
     241                    if act.expects_conn_reset():
     242                        print('connection reset as expected.')
     243                        break
     244                    else:
     245                        raise err
    233246                body = resp.read().decode()
    234247                print(format_response(resp, body))
Note: See TracChangeset for help on using the changeset viewer.