@@ -62,50 +62,16 @@ def test_client_certificates(self):
62
62
cert_password = b'abc123' )
63
63
hyper .tls .init_context (cert = CLIENT_PEM_FILE )
64
64
65
- def test_HTTPConnection_with_missing_certs (self ):
66
- # Clear any prevously created global context
67
- backup_context = hyper .tls ._context
68
- hyper .tls ._context = None
69
- backup_cert_loc = hyper .tls .cert_loc
70
- hyper .tls .cert_loc = MISSING_PEM_FILE
71
-
65
+ def test_missing_certs (self ):
72
66
succeeded = False
73
- threwExpectedException = False
67
+ threw_expected_exception = False
74
68
try :
75
- conn = hyper .HTTP20Connection ('http2bin.org' , 443 )
76
- conn .request ('GET' , '/' , None , {})
69
+ conn = hyper .tls .init_context (MISSING_PEM_FILE )
77
70
succeeded = True
78
71
except hyper .common .exceptions .MissingCertFile :
79
- threwExpectedException = True
72
+ threw_expected_exception = True
80
73
except :
81
74
pass
82
75
83
- hyper .tls .cert_loc = backup_cert_loc
84
- hyper .tls ._context = backup_context
85
-
86
76
assert not succeeded
87
- assert threwExpectedException
88
-
89
- def test_HTTPConnection_with_missing_certs_and_custom_context (self ):
90
- # Clear any prevously created global context
91
- backup_context = hyper .tls ._context
92
- hyper .tls ._context = None
93
- backup_cert_loc = hyper .tls .cert_loc
94
- hyper .tls .cert_loc = MISSING_PEM_FILE
95
-
96
- context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
97
- context .set_default_verify_paths ()
98
- context .verify_mode = ssl .CERT_REQUIRED
99
- context .check_hostname = True
100
- context .set_npn_protocols (['h2' , 'h2-15' ])
101
- context .options |= ssl .OP_NO_COMPRESSION
102
-
103
- conn = hyper .HTTP20Connection ('http2bin.org' , 443 , ssl_context = context )
104
- conn .request ('GET' , '/' , None , {})
105
-
106
- hyper .tls .cert_loc = backup_cert_loc
107
- hyper .tls ._context = backup_context
108
-
109
- assert conn .ssl_context .check_hostname
110
- assert conn .ssl_context .verify_mode == ssl .CERT_REQUIRED
111
- assert conn .ssl_context .options & ssl .OP_NO_COMPRESSION != 0
77
+ assert threw_expected_exception
0 commit comments