Skip to content

Commit e9269db

Browse files
committed
Adjusted to default TOFU security level
1 parent 844dce5 commit e9269db

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

examples/test_examples.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
# limitations under the License.
2020

2121

22-
from unittest import TestCase
22+
from test.util import ServerTestCase
2323

2424
# tag::minimal-example-import[]
2525
from neo4j.v1 import GraphDatabase
2626
# end::minimal-example-import[]
2727

2828

29-
class FreshDatabaseTestCase(TestCase):
29+
class FreshDatabaseTestCase(ServerTestCase):
3030

3131
def setUp(self):
32+
ServerTestCase.setUp(self)
3233
session = GraphDatabase.driver("bolt://localhost").session()
3334
session.run("MATCH (n) DETACH DELETE n")
3435
session.close()

neo4j/v1/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,8 @@ def match_or_trust(self, host, der_encoded_certificate):
342342
with open(self.path) as f_in:
343343
for line in f_in:
344344
known_host, _, known_cert = line.strip().partition(":")
345+
known_cert = known_cert.encode("utf-8")
345346
if host == known_host:
346-
print("Received: %s" % base64_encoded_certificate)
347-
print("Known: %s" % known_cert)
348347
return base64_encoded_certificate == known_cert
349348
# First use (no hosts match)
350349
try:

test/tck/tck_util.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
2020

21-
from neo4j.v1 import compat, Relationship, Node, Path
21+
from neo4j.v1 import GraphDatabase, Relationship, Node, Path, SECURITY_NONE
22+
from neo4j.v1.compat import string
2223

23-
from neo4j.v1 import GraphDatabase
2424

25-
driver = GraphDatabase.driver("bolt://localhost")
25+
driver = GraphDatabase.driver("bolt://localhost", security=SECURITY_NONE)
2626

2727

2828
def send_string(text):
@@ -39,11 +39,10 @@ def send_parameters(statement, parameters):
3939
return list(cursor.stream())
4040

4141

42-
def to_unicode(val):
43-
try:
44-
return unicode(val)
45-
except NameError:
46-
return str(val)
42+
try:
43+
to_unicode = unicode
44+
except NameError:
45+
to_unicode = str
4746

4847

4948
def string_to_type(str):
@@ -91,7 +90,7 @@ def __init__(self, entity):
9190
elif isinstance(entity, Path):
9291
self.content = self.create_path(entity)
9392
elif isinstance(entity, int) or isinstance(entity, float) or isinstance(entity,
94-
(str, compat.string)) or entity is None:
93+
(str, string)) or entity is None:
9594
self.content['value'] = entity
9695
else:
9796
raise ValueError("Do not support object type: %s" % entity)

test/test_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def test_keys_with_an_error(self):
256256
_ = list(cursor.keys())
257257

258258

259-
class SummaryTestCase(TestCase):
259+
class SummaryTestCase(ServerTestCase):
260260

261261
def test_can_obtain_summary_after_consuming_result(self):
262262
with GraphDatabase.driver("bolt://localhost").session() as session:

0 commit comments

Comments
 (0)