Skip to content

Commit 20aed2c

Browse files
committed
Update comments
1 parent bbb35bb commit 20aed2c

File tree

5 files changed

+38
-65
lines changed

5 files changed

+38
-65
lines changed

tests/tls/test_explicit_options.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import nutkit.protocol as types
21
from nutkit.frontend import Driver
2+
import nutkit.protocol as types
33
from tests.shared import (
44
driver_feature,
55
get_driver_name,
66
TestkitTestCase,
77
)
88
from tests.tls.shared import TlsServer
99

10-
1110
schemes = ("bolt", "neo4j")
1211

1312

@@ -25,15 +24,16 @@ def tearDown(self):
2524
self._server = None
2625
super().tearDown()
2726

28-
@driver_feature(types.Feature.API_SSL_SCHEMES, types.Feature.API_SSL_CONFIG)
27+
@driver_feature(types.Feature.API_SSL_SCHEMES,
28+
types.Feature.API_SSL_CONFIG)
2929
def test_explicit_config_and_scheme_config(self):
3030
def _test():
3131
url = "%s://%s:%d" % (scheme, "thehost", 6666)
3232
auth = types.AuthorizationToken(scheme="basic", principal="neo4j",
3333
credentials="pass")
3434
with self.assertRaises(types.DriverError) as exc:
3535
Driver(self._backend, url, auth, encrypted=encrypted,
36-
trustedCertificates=certs)
36+
trusted_certificates=certs)
3737
if get_driver_name() in ["javascript"]:
3838
self.assertIs("encryption", exc.exception.msg.lower())
3939
self.assertIs("trust", exc.exception.msg.lower())
@@ -46,4 +46,3 @@ def _test():
4646
for certs in ("None", [], ["customRoot.crt"]):
4747
with self.subTest("%s-%s-%s" % (scheme, encrypted, certs)):
4848
_test()
49-

tests/tls/test_secure_scheme.py

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010

1111

1212
class TestSecureScheme(TestkitTestCase):
13-
"""
14-
Tests URL scheme neo4j+s/bolt+s where server is assumed to present a server
15-
certificate signed by a certificate authority recognized by the driver.
16-
"""
17-
13+
# Tests URL scheme neo4j+s/bolt+s where server is assumed to present a
14+
# server certificate signed by a certificate authority recognized by the
15+
# driver.
16+
1817
def setUp(self):
1918
super().setUp()
2019
self._server = None
@@ -45,10 +44,8 @@ def _start_server(self, cert_suffix, **kwargs):
4544
self._server = TlsServer(cert, **kwargs)
4645

4746
def test_trusted_ca_correct_hostname(self):
48-
"""
49-
Happy path, the server has a valid server certificate signed by a
50-
trusted certificate authority.
51-
"""
47+
# Happy path, the server has a valid server certificate signed by a
48+
# trusted certificate authority.
5249
self.skip_if_missing_driver_features(*self.feature_requirement)
5350
for driver_config in self.extra_driver_configs:
5451
for scheme in self.schemes:
@@ -60,10 +57,8 @@ def test_trusted_ca_correct_hostname(self):
6057
self._server.reset()
6158

6259
def test_trusted_ca_expired_server_correct_hostname(self):
63-
"""
64-
The certificate authority is ok, hostname is ok but the server
65-
certificate has expired. Should not connect on expired certificate.
66-
"""
60+
# The certificate authority is ok, hostname is ok but the server
61+
# certificate has expired. Should not connect on expired certificate.
6762
self.skip_if_missing_driver_features(*self.feature_requirement)
6863
for driver_config in self.extra_driver_configs:
6964
for scheme in self.schemes:
@@ -75,9 +70,7 @@ def test_trusted_ca_expired_server_correct_hostname(self):
7570
self._server.reset()
7671

7772
def test_trusted_ca_wrong_hostname(self):
78-
"""
79-
Verifies that driver rejects connection if host name doesn't match
80-
"""
73+
# Verifies that driver rejects connection if host name doesn't match
8174
self.skip_if_missing_driver_features(*self.feature_requirement)
8275
# TLS server is setup to serve under the name 'thehost' but driver will
8376
# connect to this server using 'thehostbutwrong'. Note that the docker
@@ -96,10 +89,8 @@ def test_trusted_ca_wrong_hostname(self):
9689
self._server.reset()
9790

9891
def test_untrusted_ca_correct_hostname(self):
99-
"""
100-
Verifies that driver rejects connection if host name doesn't match
101-
trusted
102-
"""
92+
# Verifies that driver rejects connection if host name doesn't match
93+
# trusted
10394
self.skip_if_missing_driver_features(*self.feature_requirement)
10495
for driver_config in self.extra_driver_configs:
10596
for scheme in self.schemes:
@@ -111,10 +102,8 @@ def test_untrusted_ca_correct_hostname(self):
111102
self._server.reset()
112103

113104
def test_unencrypted(self):
114-
"""
115-
Verifies that driver doesn't connect when it has been configured for
116-
TLS connections but the server doesn't speak TLS
117-
"""
105+
# Verifies that driver doesn't connect when it has been configured for
106+
# TLS connections but the server doesn't speak TLS
118107
self.skip_if_missing_driver_features(*self.feature_requirement)
119108
for driver_config in self.extra_driver_configs:
120109
for scheme in self.schemes:

tests/tls/test_self_signed_scheme.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010

1111

1212
class TestSelfSignedScheme(TestkitTestCase):
13-
"""
14-
Tests URL scheme neo4j+ssc/bolt+ssc where server is assumed to present a
15-
signed server certificate but not necessarily signed by an authority
16-
recognized by the driver.
17-
"""
18-
13+
# Tests URL scheme neo4j+ssc/bolt+ssc where server is assumed to present a
14+
# signed server certificate but not necessarily signed by an authority
15+
# recognized by the driver.
1916
def setUp(self):
2017
super().setUp()
2118
self._server = None
@@ -38,10 +35,8 @@ def _try_connect(self, scheme, host, driver_config):
3835
**driver_config)
3936

4037
def test_trusted_ca_correct_hostname(self):
41-
"""
42-
A server certificate signed by a trusted CA should be accepted even
43-
when configured for self signed.
44-
"""
38+
# A server certificate signed by a trusted CA should be accepted even
39+
# when configured for self signed.
4540
self.skip_if_missing_driver_features(*self.feature_requirement)
4641
for driver_config in self.extra_driver_configs:
4742
for scheme in self.schemes:
@@ -54,11 +49,9 @@ def test_trusted_ca_correct_hostname(self):
5449
self._server.reset()
5550

5651
def test_trusted_ca_expired_server_correct_hostname(self):
57-
"""
58-
A server certificate signed by a trusted CA but the certificate has
59-
expired. Go driver happily connects when InsecureSkipVerify is enabled,
60-
same for all drivers ?
61-
"""
52+
# A server certificate signed by a trusted CA but the certificate has
53+
# expired. Go driver happily connects when InsecureSkipVerify is
54+
# enabled, same for all drivers ?
6255
self.skip_if_missing_driver_features(*self.feature_requirement)
6356
for driver_config in self.extra_driver_configs:
6457
for scheme in self.schemes:
@@ -71,10 +64,8 @@ def test_trusted_ca_expired_server_correct_hostname(self):
7164
self._server.reset()
7265

7366
def test_trusted_ca_wrong_hostname(self):
74-
"""
75-
A server certificate signed by a trusted CA but with wrong hostname
76-
will still be accepted.
77-
"""
67+
# A server certificate signed by a trusted CA but with wrong hostname
68+
# will still be accepted.
7869
# TLS server is setup to serve under the name 'thehost' but driver will
7970
# connect to this server using 'thehostbutwrong'. Note that the docker
8071
# container must map this hostname to same IP as 'thehost', if this
@@ -94,7 +85,7 @@ def test_trusted_ca_wrong_hostname(self):
9485
self._server.reset()
9586

9687
def test_untrusted_ca_correct_hostname(self):
97-
""" Should connect """
88+
# Should connect
9889
self.skip_if_missing_driver_features(*self.feature_requirement)
9990
for driver_config in self.extra_driver_configs:
10091
for scheme in self.schemes:
@@ -107,7 +98,7 @@ def test_untrusted_ca_correct_hostname(self):
10798
self._server.reset()
10899

109100
def test_untrusted_ca_wrong_hostname(self):
110-
""" Should connect """
101+
# Should connect
111102
self.skip_if_missing_driver_features(*self.feature_requirement)
112103
for driver_config in self.extra_driver_configs:
113104
for scheme in self.schemes:
@@ -121,10 +112,8 @@ def test_untrusted_ca_wrong_hostname(self):
121112
self._server.reset()
122113

123114
def test_unencrypted(self):
124-
"""
125-
Verifies that driver doesn't connect when it has been configured for
126-
TLS connections but the server doesn't speak TLS
127-
"""
115+
# Verifies that driver doesn't connect when it has been configured for
116+
# TLS connections but the server doesn't speak TLS
128117
self.skip_if_missing_driver_features(*self.feature_requirement)
129118
for driver_config in self.extra_driver_configs:
130119
for scheme in self.schemes:

tests/tls/test_tls_versions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def _try_connect(self):
3232
return try_connect(self._backend, self._server, "neo4j", "thehost",
3333
)
3434
self.skipTest("Needs support for either of %s" % ", ".join(
35-
map(lambda f: f.value, (
36-
types.Feature.API_SSL_SCHEMES, types.Feature.API_SSL_CONFIG
37-
))
35+
map(lambda f: f.value,
36+
(types.Feature.API_SSL_SCHEMES, types.Feature.API_SSL_CONFIG))
3837
))
3938

4039
def test_1_1(self):

tests/tls/test_unsecure_scheme.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from nutkit import protocol as types
1+
import nutkit.protocol as types
22
from tests.shared import (
33
driver_feature,
44
get_driver_name,
@@ -9,17 +9,14 @@
99
try_connect,
1010
)
1111

12-
1312
schemes = ["neo4j", "bolt"]
1413

1514

1615
class TestUnsecureScheme(TestkitTestCase):
17-
"""
18-
Tests URL scheme neo4j/bolt where TLS is not used. The fact that driver can
19-
not connect to a TLS server with this configuration is less interesting
20-
than the error handling when this happens, the driver backend should
21-
"survive" (without special hacks in it).
22-
"""
16+
# Tests URL scheme neo4j/bolt where TLS is not used. The fact that driver
17+
# can not connect to a TLS server with this configuration is less
18+
# interesting than the error handling when this happens, the driver backend
19+
# should "survive" (without special hacks in it).
2320

2421
def setUp(self):
2522
super().setUp()

0 commit comments

Comments
 (0)