Merge lp:~jderose/degu/py3.10 into lp:degu

Proposed by Jason Gerard DeRose
Status: Merged
Merged at revision: 493
Proposed branch: lp:~jderose/degu/py3.10
Merge into: lp:degu
Diff against target: 439 lines (+61/-52)
9 files modified
debian/control (+1/-0)
degu/client.py (+3/-3)
degu/server.py (+3/-3)
degu/tests/test_base.py (+22/-16)
degu/tests/test_client.py (+10/-10)
degu/tests/test_server.py (+12/-12)
degu/tests/test_sslhelpers.py (+8/-5)
doc/degu.client.rst (+1/-1)
setup.py (+1/-2)
To merge this branch: bzr merge lp:~jderose/degu/py3.10
Reviewer Review Type Date Requested Status
Jeremy Soller (community) Approve
Review via email: mp+424913@code.launchpad.net

Commit message

Support Python 3.10

To post a comment you must log in.
Revision history for this message
Jeremy Soller (jackpot51) wrote :

Changes all look good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2021-01-13 13:00:43 +0000
+++ debian/control 2022-06-16 23:17:03 +0000
@@ -6,6 +6,7 @@
6 dh-python,6 dh-python,
7 python3-all-dev (>= 3.8),7 python3-all-dev (>= 3.8),
8 python3-all-dbg (>= 3.8),8 python3-all-dbg (>= 3.8),
9 python3-setuptools,
9 python3-sphinx,10 python3-sphinx,
10 pyflakes3,11 pyflakes3,
11 clang-tools,12 clang-tools,
1213
=== modified file 'degu/client.py'
--- degu/client.py 2016-05-18 04:00:39 +0000
+++ degu/client.py 2022-06-16 23:17:03 +0000
@@ -82,7 +82,7 @@
82 )82 )
83 )83 )
8484
85 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)85 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
86 sslctx.verify_mode = ssl.CERT_REQUIRED86 sslctx.verify_mode = ssl.CERT_REQUIRED
87 sslctx.set_ciphers(87 sslctx.set_ciphers(
88 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'88 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'
@@ -116,8 +116,8 @@
116116
117 if not isinstance(sslctx, ssl.SSLContext):117 if not isinstance(sslctx, ssl.SSLContext):
118 raise TypeError('sslctx must be an ssl.SSLContext')118 raise TypeError('sslctx must be an ssl.SSLContext')
119 if sslctx.protocol != ssl.PROTOCOL_TLSv1_2:119 if sslctx.protocol != ssl.PROTOCOL_TLS_CLIENT:
120 raise ValueError('sslctx.protocol must be ssl.PROTOCOL_TLSv1_2')120 raise ValueError('sslctx.protocol must be ssl.PROTOCOL_TLS_CLIENT')
121 if not (sslctx.options & ssl.OP_NO_COMPRESSION):121 if not (sslctx.options & ssl.OP_NO_COMPRESSION):
122 raise ValueError('sslctx.options must include ssl.OP_NO_COMPRESSION')122 raise ValueError('sslctx.options must include ssl.OP_NO_COMPRESSION')
123 if sslctx.verify_mode != ssl.CERT_REQUIRED:123 if sslctx.verify_mode != ssl.CERT_REQUIRED:
124124
=== modified file 'degu/server.py'
--- degu/server.py 2019-11-26 01:04:54 +0000
+++ degu/server.py 2022-06-16 23:17:03 +0000
@@ -69,7 +69,7 @@
69 )69 )
70 )70 )
7171
72 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)72 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
73 sslctx.set_ciphers(73 sslctx.set_ciphers(
74 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'74 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384'
75 )75 )
@@ -109,8 +109,8 @@
109109
110 if not isinstance(sslctx, ssl.SSLContext):110 if not isinstance(sslctx, ssl.SSLContext):
111 raise TypeError('sslctx must be an ssl.SSLContext')111 raise TypeError('sslctx must be an ssl.SSLContext')
112 if sslctx.protocol != ssl.PROTOCOL_TLSv1_2:112 if sslctx.protocol != ssl.PROTOCOL_TLS_SERVER:
113 raise ValueError('sslctx.protocol must be ssl.PROTOCOL_TLSv1_2')113 raise ValueError('sslctx.protocol must be ssl.PROTOCOL_TLS_SERVER')
114114
115 # We consider ssl.CERT_OPTIONAL to be a bad grey area:115 # We consider ssl.CERT_OPTIONAL to be a bad grey area:
116 if sslctx.verify_mode == ssl.CERT_OPTIONAL:116 if sslctx.verify_mode == ssl.CERT_OPTIONAL:
117117
=== modified file 'degu/tests/test_base.py'
--- degu/tests/test_base.py 2021-01-11 18:50:42 +0000
+++ degu/tests/test_base.py 2022-06-16 23:17:03 +0000
@@ -425,9 +425,9 @@
425 if self.backend is _base:425 if self.backend is _base:
426 msg = ARG_MSG_C.format(fullname, number, len(args))426 msg = ARG_MSG_C.format(fullname, number, len(args))
427 elif len(args) < number:427 elif len(args) < number:
428 msg = ARG_MSG_Py_1.format(name, missing)428 msg = ARG_MSG_Py_1.format(fullname, missing)
429 else:429 else:
430 msg = ARG_MSG_Py_2.format(name, number + 1, number + 2)430 msg = ARG_MSG_Py_2.format(fullname, number + 1, number + 2)
431 self.assertEqual(str(cm.exception), msg)431 self.assertEqual(str(cm.exception), msg)
432432
433 def check_method_args(self, inst, name, number, missing):433 def check_method_args(self, inst, name, number, missing):
@@ -803,10 +803,6 @@
803 self.assertEqual(str(r), 'bytes=0-9999999999999998')803 self.assertEqual(str(r), 'bytes=0-9999999999999998')
804804
805 # Check reference counting:805 # Check reference counting:
806 if self.backend is _base:
807 delmsg = 'readonly attribute'
808 else:
809 delmsg = "can't delete attribute"
810 for i in range(1000):806 for i in range(1000):
811 stop = random.randrange(1, MAX_LENGTH + 1)807 stop = random.randrange(1, MAX_LENGTH + 1)
812 start = random.randrange(0, stop)808 start = random.randrange(0, stop)
@@ -827,6 +823,10 @@
827 # start, stop should be read-only:823 # start, stop should be read-only:
828 r = self.Range(start, stop)824 r = self.Range(start, stop)
829 for name in ('start', 'stop'):825 for name in ('start', 'stop'):
826 if self.backend is _base:
827 delmsg = 'readonly attribute'
828 else:
829 delmsg = "can't delete attribute '" + name + "'"
830 with self.assertRaises(AttributeError) as cm:830 with self.assertRaises(AttributeError) as cm:
831 delattr(r, name)831 delattr(r, name)
832 self.assertEqual(str(cm.exception), delmsg)832 self.assertEqual(str(cm.exception), delmsg)
@@ -1139,10 +1139,6 @@
1139 )1139 )
11401140
1141 # Check reference counting:1141 # Check reference counting:
1142 if self.backend is _base:
1143 delmsg = 'readonly attribute'
1144 else:
1145 delmsg = "can't delete attribute"
1146 for i in range(1000):1142 for i in range(1000):
1147 stop = random.randrange(1, MAX_LENGTH + 1)1143 stop = random.randrange(1, MAX_LENGTH + 1)
1148 start = random.randrange(0, stop)1144 start = random.randrange(0, stop)
@@ -1172,6 +1168,10 @@
1172 # start, stop, total should be read-only:1168 # start, stop, total should be read-only:
1173 r = self.ContentRange(start, stop, total)1169 r = self.ContentRange(start, stop, total)
1174 for name in ('start', 'stop', 'total'):1170 for name in ('start', 'stop', 'total'):
1171 if self.backend is _base:
1172 delmsg = 'readonly attribute'
1173 else:
1174 delmsg = "can't delete attribute '" + name + "'"
1175 with self.assertRaises(AttributeError) as cm:1175 with self.assertRaises(AttributeError) as cm:
1176 delattr(r, name)1176 delattr(r, name)
1177 self.assertEqual(str(cm.exception), delmsg)1177 self.assertEqual(str(cm.exception), delmsg)
@@ -2170,6 +2170,7 @@
2170 self.assertEqual(str(cm.exception),2170 self.assertEqual(str(cm.exception),
2171 "'MissingReadline' object has no attribute 'readline'"2171 "'MissingReadline' object has no attribute 'readline'"
2172 )2172 )
2173 del cm # Must del context manager before testing refcount (py 3.10+):
2173 self.assertEqual(sys.getrefcount(rfile), 2)2174 self.assertEqual(sys.getrefcount(rfile), 2)
21742175
2175 # rfile.readline() not callable:2176 # rfile.readline() not callable:
@@ -2195,6 +2196,7 @@
2195 self.assertEqual(str(cm.exception),2196 self.assertEqual(str(cm.exception),
2196 "'MissingRead' object has no attribute 'readinto'"2197 "'MissingRead' object has no attribute 'readinto'"
2197 )2198 )
2199 del cm # Must del context manager before testing refcount (py 3.10+):
2198 self.assertEqual(sys.getrefcount(rfile), 2)2200 self.assertEqual(sys.getrefcount(rfile), 2)
21992201
2200 # rfile.readinto() not callable:2202 # rfile.readinto() not callable:
@@ -3505,13 +3507,13 @@
3505 Check body instance attributes that should be read-only.3507 Check body instance attributes that should be read-only.
3506 """3508 """
3507 assert len(members) >= 23509 assert len(members) >= 2
3508 if self.backend is _basepy:
3509 setmsg = "can't set attribute"
3510 delmsg = "can't delete attribute"
3511 else:
3512 setmsg = 'readonly attribute'
3513 delmsg = 'readonly attribute'
3514 for name in members:3510 for name in members:
3511 if self.backend is _basepy:
3512 setmsg = "can't set attribute '" + name + "'"
3513 delmsg = "can't delete attribute '" + name + "'"
3514 else:
3515 setmsg = 'readonly attribute'
3516 delmsg = 'readonly attribute'
3515 value = getattr(body, name)3517 value = getattr(body, name)
3516 with self.assertRaises(AttributeError) as cm:3518 with self.assertRaises(AttributeError) as cm:
3517 setattr(body, name, value)3519 setattr(body, name, value)
@@ -3993,6 +3995,7 @@
3993 self.assertEqual(str(cm.exception),3995 self.assertEqual(str(cm.exception),
3994 "'MissingReadline' object has no attribute 'readline'"3996 "'MissingReadline' object has no attribute 'readline'"
3995 )3997 )
3998 del cm # Must del context manager before testing refcount (py 3.10+):
3996 self.assertEqual(sys.getrefcount(rfile), 2)3999 self.assertEqual(sys.getrefcount(rfile), 2)
39974000
3998 # Not a backend.SocketWrapper, rfile.readline() not callable:4001 # Not a backend.SocketWrapper, rfile.readline() not callable:
@@ -4018,6 +4021,7 @@
4018 self.assertEqual(str(cm.exception),4021 self.assertEqual(str(cm.exception),
4019 "'MissingRead' object has no attribute 'readinto'"4022 "'MissingRead' object has no attribute 'readinto'"
4020 )4023 )
4024 del cm # Must del context manager before testing refcount (py 3.10+):
4021 self.assertEqual(sys.getrefcount(rfile), 2)4025 self.assertEqual(sys.getrefcount(rfile), 2)
40224026
4023 # Not a backend.SocketWrapper, rfile.readinto() not callable:4027 # Not a backend.SocketWrapper, rfile.readinto() not callable:
@@ -6245,6 +6249,7 @@
6245 self.assertEqual(str(cm.exception),6249 self.assertEqual(str(cm.exception),
6246 "'BadSocket1' object has no attribute 'recv_into'"6250 "'BadSocket1' object has no attribute 'recv_into'"
6247 )6251 )
6252 del cm # Must del context manager before testing refcount (py 3.10+):
6248 self.assertEqual(sys.getrefcount(sock), 2)6253 self.assertEqual(sys.getrefcount(sock), 2)
6249 self.assertEqual(sock._calls, ['close'])6254 self.assertEqual(sock._calls, ['close'])
62506255
@@ -6259,6 +6264,7 @@
6259 self.assertEqual(str(cm.exception),6264 self.assertEqual(str(cm.exception),
6260 "'BadSocket2' object has no attribute 'send'"6265 "'BadSocket2' object has no attribute 'send'"
6261 )6266 )
6267 del cm # Must del context manager before testing refcount (py 3.10+):
6262 self.assertEqual(sys.getrefcount(sock), 2)6268 self.assertEqual(sys.getrefcount(sock), 2)
6263 self.assertEqual(sock._calls, ['close'])6269 self.assertEqual(sock._calls, ['close'])
62646270
62656271
=== modified file 'degu/tests/test_client.py'
--- degu/tests/test_client.py 2017-09-04 23:38:30 +0000
+++ degu/tests/test_client.py 2022-06-16 23:17:03 +0000
@@ -142,7 +142,7 @@
142 for func in client_sslctx_funcs:142 for func in client_sslctx_funcs:
143 sslctx = func({})143 sslctx = func({})
144 self.assertIsInstance(sslctx, ssl.SSLContext)144 self.assertIsInstance(sslctx, ssl.SSLContext)
145 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)145 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
146 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)146 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
147 self.assertIs(sslctx.check_hostname, True)147 self.assertIs(sslctx.check_hostname, True)
148148
@@ -159,7 +159,7 @@
159 for func in client_sslctx_funcs:159 for func in client_sslctx_funcs:
160 sslctx = func({'check_hostname': True})160 sslctx = func({'check_hostname': True})
161 self.assertIsInstance(sslctx, ssl.SSLContext)161 self.assertIsInstance(sslctx, ssl.SSLContext)
162 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)162 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
163 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)163 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
164 self.assertIs(sslctx.check_hostname, True)164 self.assertIs(sslctx.check_hostname, True)
165165
@@ -173,7 +173,7 @@
173 for func in client_sslctx_funcs:173 for func in client_sslctx_funcs:
174 sslctx = func(sslconfig)174 sslctx = func(sslconfig)
175 self.assertIsInstance(sslctx, ssl.SSLContext)175 self.assertIsInstance(sslctx, ssl.SSLContext)
176 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)176 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
177 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)177 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
178 self.assertIs(sslctx.check_hostname, False)178 self.assertIs(sslctx.check_hostname, False)
179179
@@ -182,7 +182,7 @@
182 for func in client_sslctx_funcs:182 for func in client_sslctx_funcs:
183 sslctx = func(sslconfig)183 sslctx = func(sslconfig)
184 self.assertIsInstance(sslctx, ssl.SSLContext)184 self.assertIsInstance(sslctx, ssl.SSLContext)
185 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)185 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
186 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)186 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
187 self.assertIs(sslctx.check_hostname, True)187 self.assertIs(sslctx.check_hostname, True)
188188
@@ -193,7 +193,7 @@
193 for func in client_sslctx_funcs:193 for func in client_sslctx_funcs:
194 sslctx = func(sslconfig)194 sslctx = func(sslconfig)
195 self.assertIsInstance(sslctx, ssl.SSLContext)195 self.assertIsInstance(sslctx, ssl.SSLContext)
196 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)196 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
197 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)197 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
198 self.assertIs(sslctx.check_hostname, False)198 self.assertIs(sslctx.check_hostname, False)
199199
@@ -202,7 +202,7 @@
202 for func in client_sslctx_funcs:202 for func in client_sslctx_funcs:
203 sslctx = func(sslconfig)203 sslctx = func(sslconfig)
204 self.assertIsInstance(sslctx, ssl.SSLContext)204 self.assertIsInstance(sslctx, ssl.SSLContext)
205 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)205 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_CLIENT)
206 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)206 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
207 self.assertIs(sslctx.check_hostname, True)207 self.assertIs(sslctx.check_hostname, True)
208208
@@ -470,11 +470,11 @@
470 self.assertEqual(str(cm.exception), 'sslctx must be an ssl.SSLContext')470 self.assertEqual(str(cm.exception), 'sslctx must be an ssl.SSLContext')
471471
472 # Bad SSL protocol version:472 # Bad SSL protocol version:
473 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)473 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
474 with self.assertRaises(ValueError) as cm:474 with self.assertRaises(ValueError) as cm:
475 client.SSLClient(sslctx, None)475 client.SSLClient(sslctx, None)
476 self.assertEqual(str(cm.exception),476 self.assertEqual(str(cm.exception),
477 'sslctx.protocol must be ssl.PROTOCOL_TLSv1_2'477 'sslctx.protocol must be ssl.PROTOCOL_TLS_CLIENT'
478 )478 )
479479
480 # Note: Python 3.3.4 (and presumably 3.4.0) now disables SSLv2 by480 # Note: Python 3.3.4 (and presumably 3.4.0) now disables SSLv2 by
@@ -482,7 +482,7 @@
482 # we cannot unset the ssl.OP_NO_SSLv2 bit, we can't unit test to check482 # we cannot unset the ssl.OP_NO_SSLv2 bit, we can't unit test to check
483 # that Degu enforces this, so for now, we set the bit here so it works483 # that Degu enforces this, so for now, we set the bit here so it works
484 # with Python 3.3.3 still; see: http://bugs.python.org/issue20207484 # with Python 3.3.3 still; see: http://bugs.python.org/issue20207
485 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)485 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
486 sslctx.options |= ssl.OP_NO_SSLv2486 sslctx.options |= ssl.OP_NO_SSLv2
487487
488 # not (options & ssl.OP_NO_COMPRESSION)488 # not (options & ssl.OP_NO_COMPRESSION)
@@ -494,7 +494,7 @@
494 )494 )
495495
496 # verify_mode is not ssl.CERT_REQUIRED:496 # verify_mode is not ssl.CERT_REQUIRED:
497 sslctx.options |= ssl.OP_NO_COMPRESSION497 sslctx.verify_mode = ssl.CERT_OPTIONAL
498 with self.assertRaises(ValueError) as cm:498 with self.assertRaises(ValueError) as cm:
499 client.SSLClient(sslctx, None)499 client.SSLClient(sslctx, None)
500 self.assertEqual(str(cm.exception),500 self.assertEqual(str(cm.exception),
501501
=== modified file 'degu/tests/test_server.py'
--- degu/tests/test_server.py 2019-11-26 01:04:54 +0000
+++ degu/tests/test_server.py 2022-06-16 23:17:03 +0000
@@ -120,7 +120,7 @@
120 )120 )
121 for func in server_sslctx_funcs:121 for func in server_sslctx_funcs:
122 sslctx = func(pki.server_sslconfig)122 sslctx = func(pki.server_sslconfig)
123 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)123 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_SERVER)
124 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)124 self.assertEqual(sslctx.verify_mode, ssl.CERT_REQUIRED)
125125
126 # New in Degu 0.3: should not be able to accept connections from126 # New in Degu 0.3: should not be able to accept connections from
@@ -138,7 +138,7 @@
138 sslconfig['allow_unauthenticated_clients'] = True138 sslconfig['allow_unauthenticated_clients'] = True
139 for func in server_sslctx_funcs:139 for func in server_sslctx_funcs:
140 sslctx = func(sslconfig)140 sslctx = func(sslconfig)
141 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLSv1_2)141 self.assertEqual(sslctx.protocol, ssl.PROTOCOL_TLS_SERVER)
142 self.assertEqual(sslctx.verify_mode, ssl.CERT_NONE)142 self.assertEqual(sslctx.verify_mode, ssl.CERT_NONE)
143143
144 # Cannot mix ca_file/ca_path with allow_unauthenticated_clients:144 # Cannot mix ca_file/ca_path with allow_unauthenticated_clients:
@@ -176,13 +176,13 @@
176176
177 # Wrong protocol:177 # Wrong protocol:
178 with self.assertRaises(ValueError) as cm:178 with self.assertRaises(ValueError) as cm:
179 server._validate_server_sslctx(ssl.SSLContext(ssl.PROTOCOL_TLSv1))179 server._validate_server_sslctx(ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT))
180 self.assertEqual(str(cm.exception),180 self.assertEqual(str(cm.exception),
181 'sslctx.protocol must be ssl.PROTOCOL_TLSv1_2'181 'sslctx.protocol must be ssl.PROTOCOL_TLS_SERVER'
182 )182 )
183183
184 # Don't allow ssl.CERT_OPTIONAL:184 # Don't allow ssl.CERT_OPTIONAL:
185 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)185 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
186 sslctx.verify_mode = ssl.CERT_OPTIONAL186 sslctx.verify_mode = ssl.CERT_OPTIONAL
187 with self.assertRaises(ValueError) as cm:187 with self.assertRaises(ValueError) as cm:
188 server._validate_server_sslctx(sslctx)188 server._validate_server_sslctx(sslctx)
@@ -191,13 +191,13 @@
191 )191 )
192192
193 # All good:193 # All good:
194 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)194 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
195 self.assertIs(sslctx.verify_mode, ssl.CERT_NONE)195 self.assertIs(sslctx.verify_mode, ssl.CERT_NONE)
196 self.assertIs(server._validate_server_sslctx(sslctx), sslctx)196 self.assertIs(server._validate_server_sslctx(sslctx), sslctx)
197197
198 # Now again, this time with CERT_REQUIRED:198 # Now again, this time with CERT_REQUIRED:
199 # options missing OP_NO_COMPRESSION:199 # options missing OP_NO_COMPRESSION:
200 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)200 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
201 sslctx.verify_mode = ssl.CERT_REQUIRED201 sslctx.verify_mode = ssl.CERT_REQUIRED
202 self.assertIs(sslctx.verify_mode, ssl.CERT_REQUIRED)202 self.assertIs(sslctx.verify_mode, ssl.CERT_REQUIRED)
203 self.assertIs(server._validate_server_sslctx(sslctx), sslctx)203 self.assertIs(server._validate_server_sslctx(sslctx), sslctx)
@@ -426,15 +426,15 @@
426 self.assertEqual(str(cm.exception), 'sslctx must be an ssl.SSLContext')426 self.assertEqual(str(cm.exception), 'sslctx must be an ssl.SSLContext')
427427
428 # Bad SSL protocol version:428 # Bad SSL protocol version:
429 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)429 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
430 with self.assertRaises(ValueError) as cm:430 with self.assertRaises(ValueError) as cm:
431 server.SSLServer(sslctx, degu.IPv6_LOOPBACK, good_app)431 server.SSLServer(sslctx, degu.IPv6_LOOPBACK, good_app)
432 self.assertEqual(str(cm.exception),432 self.assertEqual(str(cm.exception),
433 'sslctx.protocol must be ssl.PROTOCOL_TLSv1_2'433 'sslctx.protocol must be ssl.PROTOCOL_TLS_SERVER'
434 )434 )
435435
436 # Good sslctx from here on:436 # Good sslctx from here on:
437 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)437 sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
438438
439 # Bad address type:439 # Bad address type:
440 with self.assertRaises(TypeError) as cm:440 with self.assertRaises(TypeError) as cm:
@@ -1003,7 +1003,7 @@
1003 with self.assertRaises(ssl.SSLError) as cm:1003 with self.assertRaises(ssl.SSLError) as cm:
1004 client.connect()1004 client.connect()
1005 self.assertTrue(1005 self.assertTrue(
1006 str(cm.exception).startswith('[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE]')1006 str(cm.exception).startswith('[SSL: CERTIFICATE_VERIFY_FAILED]')
1007 )1007 )
1008 self.assertIs(conn.closed, True)1008 self.assertIs(conn.closed, True)
10091009
@@ -1017,7 +1017,7 @@
1017 with self.assertRaises(ssl.SSLError) as cm:1017 with self.assertRaises(ssl.SSLError) as cm:
1018 client.connect()1018 client.connect()
1019 self.assertTrue(1019 self.assertTrue(
1020 str(cm.exception).startswith('[SSL: TLSV1_ALERT_UNKNOWN_CA]')1020 str(cm.exception).startswith('[SSL: CERTIFICATE_VERIFY_FAILED]')
1021 )1021 )
1022 self.assertIs(conn.closed, True)1022 self.assertIs(conn.closed, True)
10231023
10241024
=== modified file 'degu/tests/test_sslhelpers.py'
--- degu/tests/test_sslhelpers.py 2016-03-13 18:28:18 +0000
+++ degu/tests/test_sslhelpers.py 2022-06-16 23:17:03 +0000
@@ -36,22 +36,26 @@
36 def test_create_key(self):36 def test_create_key(self):
37 # 1024 bit:37 # 1024 bit:
38 key_data = sslhelpers.create_key(1024)38 key_data = sslhelpers.create_key(1024)
39 self.assertIn(len(key_data), [883, 887, 891])39 self.assertGreater(len(key_data), 512)
40 self.assertLess(len(key_data), 1024)
40 sslhelpers.get_pubkey(key_data)41 sslhelpers.get_pubkey(key_data)
4142
42 # 2048 bit:43 # 2048 bit:
43 key_data = sslhelpers.create_key(2048)44 key_data = sslhelpers.create_key(2048)
44 self.assertIn(len(key_data), [1671, 1675, 1679])45 self.assertGreater(len(key_data), 1024)
46 self.assertLess(len(key_data), 2048)
45 sslhelpers.get_pubkey(key_data)47 sslhelpers.get_pubkey(key_data)
4648
47 # 3072 bit:49 # 3072 bit:
48 key_data = sslhelpers.create_key(3072)50 key_data = sslhelpers.create_key(3072)
49 self.assertIn(len(key_data), [2455, 2459])51 self.assertGreater(len(key_data), 2048)
52 self.assertLess(len(key_data), 3072)
50 sslhelpers.get_pubkey(key_data)53 sslhelpers.get_pubkey(key_data)
5154
52 # 4096 bit:55 # 4096 bit:
53 key_data = sslhelpers.create_key(4096)56 key_data = sslhelpers.create_key(4096)
54 self.assertIn(len(key_data), [3239, 3243, 3247])57 self.assertGreater(len(key_data), 3072)
58 self.assertLess(len(key_data), 4096)
55 sslhelpers.get_pubkey(key_data)59 sslhelpers.get_pubkey(key_data)
5660
57 def test_create_ca(self):61 def test_create_ca(self):
@@ -179,7 +183,6 @@
179 set([183 set([
180 ca_id + '.key',184 ca_id + '.key',
181 ca_id + '.ca',185 ca_id + '.ca',
182 ca_id + '.srl',
183 cert_id + '.csr',186 cert_id + '.csr',
184 cert_id + '.cert',187 cert_id + '.cert',
185 ])188 ])
186189
=== modified file 'doc/degu.client.rst'
--- doc/degu.client.rst 2017-07-18 18:07:33 +0000
+++ doc/degu.client.rst 2022-06-16 23:17:03 +0000
@@ -42,7 +42,7 @@
42server certificate (more or less how a browser would configure SSL):42server certificate (more or less how a browser would configure SSL):
4343
44>>> import ssl44>>> import ssl
45>>> sslclient.sslctx.protocol == ssl.PROTOCOL_TLSv1_245>>> sslclient.sslctx.protocol == ssl.PROTOCOL_TLS_CLIENT
46True46True
47>>> sslclient.sslctx.verify_mode == ssl.CERT_REQUIRED47>>> sslclient.sslctx.verify_mode == ssl.CERT_REQUIRED
48True48True
4949
=== modified file 'setup.py'
--- setup.py 2021-01-13 13:00:43 +0000
+++ setup.py 2022-06-16 23:17:03 +0000
@@ -33,8 +33,7 @@
33import os33import os
34from os import path34from os import path
35import subprocess35import subprocess
36from distutils.core import setup, Extension36from setuptools import setup, Command, Extension
37from distutils.cmd import Command
3837
39import degu38import degu
40from degu.tests.run import run_tests39from degu.tests.run import run_tests

Subscribers

People subscribed via source and target branches