@@ -64,27 +64,31 @@ def test_client_certificates(self):
64
64
65
65
def test_HTTPConnection_with_missing_certs (self ):
66
66
# Clear any prevously created global context
67
+ backup_context = hyper .tls ._context
67
68
hyper .tls ._context = None
68
69
backup_cert_loc = hyper .tls .cert_loc
69
70
hyper .tls .cert_loc = MISSING_PEM_FILE
70
71
71
72
succeeded = False
72
73
threwExpectedException = False
73
74
try :
74
- hyper .HTTP20Connection ('http2bin.org' , 443 )
75
+ conn = hyper .HTTP20Connection ('http2bin.org' , 443 )
76
+ conn .request ('GET' , '/' , None , {})
75
77
succeeded = True
76
78
except hyper .common .exceptions .MissingCertFile :
77
79
threwExpectedException = True
78
80
except :
79
81
pass
80
82
81
83
hyper .tls .cert_loc = backup_cert_loc
84
+ hyper .tls ._context = backup_context
82
85
83
86
assert not succeeded
84
87
assert threwExpectedException
85
88
86
89
def test_HTTPConnection_with_missing_certs_and_custom_context (self ):
87
90
# Clear any prevously created global context
91
+ backup_context = hyper .tls ._context
88
92
hyper .tls ._context = None
89
93
backup_cert_loc = hyper .tls .cert_loc
90
94
hyper .tls .cert_loc = MISSING_PEM_FILE
@@ -97,8 +101,10 @@ def test_HTTPConnection_with_missing_certs_and_custom_context(self):
97
101
context .options |= ssl .OP_NO_COMPRESSION
98
102
99
103
conn = hyper .HTTP20Connection ('http2bin.org' , 443 , ssl_context = context )
104
+ conn .request ('GET' , '/' , None , {})
100
105
101
106
hyper .tls .cert_loc = backup_cert_loc
107
+ hyper .tls ._context = backup_context
102
108
103
109
assert conn .ssl_context .check_hostname
104
110
assert conn .ssl_context .verify_mode == ssl .CERT_REQUIRED
0 commit comments