@@ -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
def _create_oscp_conn (self , request ):
77
82
ssl_url = request .config .option .redis_ssl_url
@@ -92,22 +97,25 @@ def _create_oscp_conn(self, request):
92
97
def test_ssl_ocsp_called (self , request ):
93
98
r = self ._create_oscp_conn (request )
94
99
with pytest .raises (RedisError ) as e :
95
- assert r .ping ()
96
- assert "cryptography not installed" in str (e )
100
+ r .ping ()
101
+ assert "cryptography is not installed" in str (e )
102
+ r .close ()
97
103
98
104
@skip_if_nocryptography ()
99
105
def test_ssl_ocsp_called_withcrypto (self , request ):
100
106
r = self ._create_oscp_conn (request )
101
107
with pytest .raises (ConnectionError ) as e :
102
108
assert r .ping ()
103
- assert "No AIA information present in ssl certificate" in str (e )
109
+ assert "No AIA information present in ssl certificate" in str (e )
110
+ r .close ()
104
111
105
112
# rediss://, url based
106
113
ssl_url = request .config .option .redis_ssl_url
107
114
sslclient = redis .from_url (ssl_url )
108
115
with pytest .raises (ConnectionError ) as e :
109
116
sslclient .ping ()
110
- assert "No AIA information present in ssl certificate" in str (e )
117
+ assert "No AIA information present in ssl certificate" in str (e )
118
+ sslclient .close ()
111
119
112
120
@skip_if_nocryptography ()
113
121
def test_valid_ocsp_cert_http (self ):
@@ -132,7 +140,7 @@ def test_revoked_ocsp_certificate(self):
132
140
ocsp = OCSPVerifier (wrapped , hostname , 443 )
133
141
with pytest .raises (ConnectionError ) as e :
134
142
assert ocsp .is_valid ()
135
- assert "REVOKED" in str (e )
143
+ assert "REVOKED" in str (e )
136
144
137
145
@skip_if_nocryptography ()
138
146
def test_unauthorized_ocsp (self ):
@@ -157,7 +165,7 @@ def test_ocsp_not_present_in_response(self):
157
165
ocsp = OCSPVerifier (wrapped , hostname , 443 )
158
166
with pytest .raises (ConnectionError ) as e :
159
167
assert ocsp .is_valid ()
160
- assert "from the" in str (e )
168
+ assert "from the" in str (e )
161
169
162
170
@skip_if_nocryptography ()
163
171
def test_unauthorized_then_direct (self ):
@@ -193,6 +201,7 @@ def test_mock_ocsp_staple(self, request):
193
201
194
202
with pytest .raises (RedisError ):
195
203
r .ping ()
204
+ r .close ()
196
205
197
206
ctx = OpenSSL .SSL .Context (OpenSSL .SSL .SSLv23_METHOD )
198
207
ctx .use_certificate_file (self .SERVER_CERT )
@@ -213,7 +222,8 @@ def test_mock_ocsp_staple(self, request):
213
222
214
223
with pytest .raises (ConnectionError ) as e :
215
224
r .ping ()
216
- assert "no ocsp response present" in str (e )
225
+ assert "no ocsp response present" in str (e )
226
+ r .close ()
217
227
218
228
r = redis .Redis (
219
229
host = p [0 ],
@@ -228,4 +238,5 @@ def test_mock_ocsp_staple(self, request):
228
238
229
239
with pytest .raises (ConnectionError ) as e :
230
240
r .ping ()
231
- assert "no ocsp response present" in str (e )
241
+ assert "no ocsp response present" in str (e )
242
+ r .close ()
0 commit comments