19
19
# limitations under the License.
20
20
21
21
22
+ from socket import socket
23
+ from ssl import SSLSocket
22
24
from unittest import TestCase
23
25
24
26
from mock import patch
@@ -59,9 +61,6 @@ def test_session_that_dies_in_the_pool_will_not_be_given_out(self):
59
61
session_2 = driver .session ()
60
62
assert session_2 is not session_1
61
63
62
-
63
- class RunTestCase (TestCase ):
64
-
65
64
def test_must_use_valid_url_scheme (self ):
66
65
with self .assertRaises (ValueError ):
67
66
GraphDatabase .driver ("x://xxx" )
@@ -82,6 +81,21 @@ def test_sessions_are_not_reused_if_still_in_use(self):
82
81
session_1 .close ()
83
82
assert session_1 is not session_2
84
83
84
+ def test_insecure_session_uses_insecure_socket (self ):
85
+ driver = GraphDatabase .driver ("bolt://localhost" , secure = False )
86
+ session = driver .session ()
87
+ assert isinstance (session .connection .channel .socket , socket )
88
+ session .close ()
89
+
90
+ def test_secure_session_uses_secure_socket (self ):
91
+ driver = GraphDatabase .driver ("bolt://localhost" , secure = True )
92
+ session = driver .session ()
93
+ assert isinstance (session .connection .channel .socket , SSLSocket )
94
+ session .close ()
95
+
96
+
97
+ class RunTestCase (TestCase ):
98
+
85
99
def test_can_run_simple_statement (self ):
86
100
session = GraphDatabase .driver ("bolt://localhost" ).session ()
87
101
count = 0
0 commit comments