mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-38270: Check for hash digest algorithms and avoid MD5 (GH-16382)
Make it easier to run and test Python on systems with restrict crypto policies: * add requires_hashdigest to test.support to check if a hash digest algorithm is available and working * avoid MD5 in test_hmac * replace MD5 with SHA256 in test_tarfile * mark network tests that require MD5 for MD5-based digest auth or CRAM-MD5 https://bugs.python.org/issue38270
This commit is contained in:
parent
417089e88b
commit
c64a1a61e6
8 changed files with 119 additions and 45 deletions
|
@ -10,7 +10,8 @@ import threading
|
|||
import socket
|
||||
|
||||
from test.support import (reap_threads, verbose, transient_internet,
|
||||
run_with_tz, run_with_locale, cpython_only)
|
||||
run_with_tz, run_with_locale, cpython_only,
|
||||
requires_hashdigest)
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
@ -370,6 +371,7 @@ class NewIMAPTestsMixin():
|
|||
self.assertEqual(code, 'OK')
|
||||
self.assertEqual(server.response, b'ZmFrZQ==\r\n') # b64 encoded 'fake'
|
||||
|
||||
@requires_hashdigest('md5')
|
||||
def test_login_cram_md5_bytes(self):
|
||||
class AuthHandler(SimpleIMAPHandler):
|
||||
capabilities = 'LOGINDISABLED AUTH=CRAM-MD5'
|
||||
|
@ -387,6 +389,7 @@ class NewIMAPTestsMixin():
|
|||
ret, _ = client.login_cram_md5("tim", b"tanstaaftanstaaf")
|
||||
self.assertEqual(ret, "OK")
|
||||
|
||||
@requires_hashdigest('md5')
|
||||
def test_login_cram_md5_plain_text(self):
|
||||
class AuthHandler(SimpleIMAPHandler):
|
||||
capabilities = 'LOGINDISABLED AUTH=CRAM-MD5'
|
||||
|
@ -797,6 +800,7 @@ class ThreadedNetworkedTests(unittest.TestCase):
|
|||
b'ZmFrZQ==\r\n') # b64 encoded 'fake'
|
||||
|
||||
@reap_threads
|
||||
@requires_hashdigest('md5')
|
||||
def test_login_cram_md5(self):
|
||||
|
||||
class AuthHandler(SimpleIMAPHandler):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue