8
8
from hyper .common .connection import HTTPConnection
9
9
from hyper .compat import ssl
10
10
11
- import pytest
12
-
13
11
14
12
TEST_DIR = os .path .abspath (os .path .dirname (__file__ ))
15
13
TEST_CERTS_DIR = os .path .join (TEST_DIR , 'certs' )
@@ -25,11 +23,10 @@ class TestSSLContext(object):
25
23
def test_default_context (self ):
26
24
# Create default SSLContext
27
25
hyper .tls ._context = hyper .tls .init_context ()
28
- assert hyper .tls ._context .check_hostname == True
26
+ assert hyper .tls ._context .check_hostname
29
27
assert hyper .tls ._context .verify_mode == ssl .CERT_REQUIRED
30
28
assert hyper .tls ._context .options & ssl .OP_NO_COMPRESSION != 0
31
29
32
-
33
30
def test_custom_context (self ):
34
31
# The following SSLContext doesn't provide any valid certicate.
35
32
# Its purpose is only to confirm that hyper is not using its
@@ -40,11 +37,10 @@ def test_custom_context(self):
40
37
41
38
hyper .tls ._context = context
42
39
43
- assert hyper .tls ._context .check_hostname == False
40
+ assert not hyper .tls ._context .check_hostname
44
41
assert hyper .tls ._context .verify_mode == ssl .CERT_NONE
45
42
assert hyper .tls ._context .options & ssl .OP_NO_COMPRESSION == 0
46
43
47
-
48
44
def test_HTTPConnection_with_custom_context (self ):
49
45
context = ssl .SSLContext (ssl .PROTOCOL_SSLv23 )
50
46
context .set_default_verify_paths ()
@@ -55,13 +51,12 @@ def test_HTTPConnection_with_custom_context(self):
55
51
56
52
conn = HTTPConnection ('http2bin.org' , 443 , ssl_context = context )
57
53
58
- assert conn .ssl_context .check_hostname == True
54
+ assert conn .ssl_context .check_hostname
59
55
assert conn .ssl_context .verify_mode == ssl .CERT_REQUIRED
60
56
assert conn .ssl_context .options & ssl .OP_NO_COMPRESSION != 0
61
57
62
-
63
58
def test_client_certificates (self ):
64
- context = hyper .tls .init_context (
59
+ hyper .tls .init_context (
65
60
cert = (CLIENT_CERT_FILE , CLIENT_KEY_FILE ),
66
61
cert_password = b'abc123' )
67
- context = hyper .tls .init_context (cert = CLIENT_PEM_FILE )
62
+ hyper .tls .init_context (cert = CLIENT_PEM_FILE )
0 commit comments