@@ -26,13 +26,15 @@ def test_ssl_with_invalid_cert(self, request):
26
26
sslclient = redis .from_url (ssl_url )
27
27
with pytest .raises (ConnectionError ) as e :
28
28
sslclient .ping ()
29
- assert "SSL: CERTIFICATE_VERIFY_FAILED" in str (e )
29
+ assert "SSL: CERTIFICATE_VERIFY_FAILED" in str (e )
30
+ sslclient .close ()
30
31
31
32
def test_ssl_connection (self , request ):
32
33
ssl_url = request .config .option .redis_ssl_url
33
34
p = urlparse (ssl_url )[1 ].split (":" )
34
35
r = redis .Redis (host = p [0 ], port = p [1 ], ssl = True , ssl_cert_reqs = "none" )
35
36
assert r .ping ()
37
+ r .close ()
36
38
37
39
def test_ssl_connection_without_ssl (self , request ):
38
40
ssl_url = request .config .option .redis_ssl_url
@@ -41,7 +43,8 @@ def test_ssl_connection_without_ssl(self, request):
41
43
42
44
with pytest .raises (ConnectionError ) as e :
43
45
r .ping ()
44
- assert "Connection closed by server" in str (e )
46
+ assert "Connection closed by server" in str (e )
47
+ r .close ()
45
48
46
49
def test_validating_self_signed_certificate (self , request ):
47
50
ssl_url = request .config .option .redis_ssl_url
@@ -56,6 +59,7 @@ def test_validating_self_signed_certificate(self, request):
56
59
ssl_ca_certs = self .SERVER_CERT ,
57
60
)
58
61
assert r .ping ()
62
+ r .close ()
59
63
60
64
def test_validating_self_signed_string_certificate (self , request ):
61
65
with open (self .SERVER_CERT ) as f :
@@ -72,6 +76,7 @@ def test_validating_self_signed_string_certificate(self, request):
72
76
ssl_ca_data = cert_data ,
73
77
)
74
78
assert r .ping ()
79
+ r .close ()
75
80
76
81
@pytest .mark .parametrize (
77
82
"ssl_ciphers" ,
@@ -154,22 +159,25 @@ def _create_oscp_conn(self, request):
154
159
def test_ssl_ocsp_called (self , request ):
155
160
r = self ._create_oscp_conn (request )
156
161
with pytest .raises (RedisError ) as e :
157
- assert r .ping ()
158
- assert "cryptography not installed" in str (e )
162
+ r .ping ()
163
+ assert "cryptography is not installed" in str (e )
164
+ r .close ()
159
165
160
166
@skip_if_nocryptography ()
161
167
def test_ssl_ocsp_called_withcrypto (self , request ):
162
168
r = self ._create_oscp_conn (request )
163
169
with pytest .raises (ConnectionError ) as e :
164
170
assert r .ping ()
165
- assert "No AIA information present in ssl certificate" in str (e )
171
+ assert "No AIA information present in ssl certificate" in str (e )
172
+ r .close ()
166
173
167
174
# rediss://, url based
168
175
ssl_url = request .config .option .redis_ssl_url
169
176
sslclient = redis .from_url (ssl_url )
170
177
with pytest .raises (ConnectionError ) as e :
171
178
sslclient .ping ()
172
- assert "No AIA information present in ssl certificate" in str (e )
179
+ assert "No AIA information present in ssl certificate" in str (e )
180
+ sslclient .close ()
173
181
174
182
@skip_if_nocryptography ()
175
183
def test_valid_ocsp_cert_http (self ):
@@ -194,7 +202,7 @@ def test_revoked_ocsp_certificate(self):
194
202
ocsp = OCSPVerifier (wrapped , hostname , 443 )
195
203
with pytest .raises (ConnectionError ) as e :
196
204
assert ocsp .is_valid ()
197
- assert "REVOKED" in str (e )
205
+ assert "REVOKED" in str (e )
198
206
199
207
@skip_if_nocryptography ()
200
208
def test_unauthorized_ocsp (self ):
@@ -219,7 +227,7 @@ def test_ocsp_not_present_in_response(self):
219
227
ocsp = OCSPVerifier (wrapped , hostname , 443 )
220
228
with pytest .raises (ConnectionError ) as e :
221
229
assert ocsp .is_valid ()
222
- assert "from the" in str (e )
230
+ assert "from the" in str (e )
223
231
224
232
@skip_if_nocryptography ()
225
233
def test_unauthorized_then_direct (self ):
@@ -255,6 +263,7 @@ def test_mock_ocsp_staple(self, request):
255
263
256
264
with pytest .raises (RedisError ):
257
265
r .ping ()
266
+ r .close ()
258
267
259
268
ctx = OpenSSL .SSL .Context (OpenSSL .SSL .SSLv23_METHOD )
260
269
ctx .use_certificate_file (self .SERVER_CERT )
@@ -275,7 +284,8 @@ def test_mock_ocsp_staple(self, request):
275
284
276
285
with pytest .raises (ConnectionError ) as e :
277
286
r .ping ()
278
- assert "no ocsp response present" in str (e )
287
+ assert "no ocsp response present" in str (e )
288
+ r .close ()
279
289
280
290
r = redis .Redis (
281
291
host = p [0 ],
@@ -290,4 +300,5 @@ def test_mock_ocsp_staple(self, request):
290
300
291
301
with pytest .raises (ConnectionError ) as e :
292
302
r .ping ()
293
- assert "no ocsp response present" in str (e )
303
+ assert "no ocsp response present" in str (e )
304
+ r .close ()
0 commit comments