Merge "Follow-up of "Move to python3.9 as minimal python version""
This commit is contained in:
commit
995f587560
@ -23,7 +23,6 @@ import logging
|
||||
import uuid
|
||||
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_utils.secretutils import md5
|
||||
|
||||
from time import sleep
|
||||
|
||||
@ -115,7 +114,7 @@ def get_hasher(hash_algo, usedforsecurity=True):
|
||||
:param usedforsecurity: whether the hashes are used in a security context
|
||||
"""
|
||||
if str(hash_algo) == 'md5':
|
||||
return md5(usedforsecurity=usedforsecurity)
|
||||
return hashlib.md5(usedforsecurity=usedforsecurity)
|
||||
else:
|
||||
return hashlib.new(str(hash_algo))
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
import hashlib
|
||||
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslotest import base
|
||||
|
||||
import glance_store.driver as driver
|
||||
@ -28,7 +27,7 @@ class _FakeStore(object):
|
||||
context=None, verifier=None):
|
||||
"""This is a 0.26.0+ add, returns a 5-tuple"""
|
||||
if hashing_algo == 'md5':
|
||||
hasher = md5(usedforsecurity=False)
|
||||
hasher = hashlib.md5(usedforsecurity=False)
|
||||
else:
|
||||
hasher = hashlib.new(str(hashing_algo))
|
||||
|
||||
@ -36,7 +35,7 @@ class _FakeStore(object):
|
||||
hasher.update(image_file)
|
||||
backend_url = "backend://%s" % image_id
|
||||
bytes_written = len(image_file)
|
||||
checksum = md5(image_file, usedforsecurity=False).hexdigest()
|
||||
checksum = hashlib.md5(image_file, usedforsecurity=False).hexdigest()
|
||||
multihash = hasher.hexdigest()
|
||||
metadata_dict = {"verifier_obj":
|
||||
verifier.name if verifier else None,
|
||||
@ -63,8 +62,8 @@ class TestBackCompatWrapper(base.BaseTestCase):
|
||||
self.img_id = '1234'
|
||||
self.img_file = b'0123456789'
|
||||
self.img_size = 10
|
||||
self.img_checksum = md5(self.img_file,
|
||||
usedforsecurity=False).hexdigest()
|
||||
self.img_checksum = hashlib.md5(self.img_file,
|
||||
usedforsecurity=False).hexdigest()
|
||||
self.hashing_algo = 'sha256'
|
||||
self.img_sha256 = hashlib.sha256(self.img_file).hexdigest()
|
||||
|
||||
|
@ -26,7 +26,6 @@ from unittest import mock
|
||||
import uuid
|
||||
|
||||
import fixtures
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
|
||||
from glance_store._drivers import filesystem
|
||||
@ -153,8 +152,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_file_contents).hexdigest()
|
||||
expected_location = "file://%s/%s" % (self.test_dir,
|
||||
expected_image_id)
|
||||
@ -604,8 +603,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_file_contents).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store_map[1],
|
||||
expected_image_id)
|
||||
@ -652,8 +651,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_file_contents).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store_map[1],
|
||||
expected_image_id)
|
||||
@ -763,8 +762,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_file_contents).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store,
|
||||
expected_image_id)
|
||||
@ -806,8 +805,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_file_contents).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store,
|
||||
expected_image_id)
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import builtins
|
||||
import errno
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
@ -26,7 +27,6 @@ import uuid
|
||||
|
||||
import fixtures
|
||||
from oslo_config import cfg
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
|
||||
import glance_store as store
|
||||
@ -187,8 +187,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (self.test_dir,
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
@ -228,8 +228,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (self.test_dir,
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
@ -583,8 +583,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store_map[1],
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
@ -631,8 +631,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store_map[1],
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
@ -743,8 +743,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store,
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
@ -788,8 +788,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_file_size = 5 * units.Ki # 5K
|
||||
expected_file_contents = b"*" * expected_file_size
|
||||
expected_checksum = md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_location = "file://%s/%s" % (store,
|
||||
expected_image_id)
|
||||
image_file = io.BytesIO(expected_file_contents)
|
||||
|
@ -25,7 +25,6 @@ import botocore
|
||||
from botocore import exceptions as boto_exceptions
|
||||
from botocore import stub
|
||||
from oslo_config import cfg
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
|
||||
import glance_store as store
|
||||
@ -247,8 +246,8 @@ class TestMultiS3Store(base.MultiStoreBaseTest,
|
||||
# 5KiB is smaller than WRITE_CHUNKSIZE
|
||||
expected_s3_size = FIVE_KB
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
@ -300,8 +299,8 @@ class TestMultiS3Store(base.MultiStoreBaseTest,
|
||||
# but smaller than s3_store_large_object_size
|
||||
expected_s3_size = 8 * units.Mi
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
@ -354,8 +353,8 @@ class TestMultiS3Store(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_s3_size = FIVE_KB
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
@ -428,8 +427,8 @@ class TestMultiS3Store(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_s3_size = 16 * units.Mi
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
|
@ -21,7 +21,6 @@ from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import secretutils
|
||||
from oslo_utils import units
|
||||
from oslo_vmware import api
|
||||
from oslo_vmware import exceptions as vmware_exceptions
|
||||
@ -176,7 +175,7 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_size = FIVE_KB
|
||||
expected_contents = b"*" * expected_size
|
||||
hash_code = secretutils.md5(expected_contents, usedforsecurity=False)
|
||||
hash_code = hashlib.md5(expected_contents, usedforsecurity=False)
|
||||
expected_checksum = hash_code.hexdigest()
|
||||
fake_size.__get__ = mock.Mock(return_value=expected_size)
|
||||
expected_cookie = 'vmware_soap_session=fake-uuid'
|
||||
@ -217,7 +216,7 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_size = FIVE_KB
|
||||
expected_contents = b"*" * expected_size
|
||||
hash_code = secretutils.md5(expected_contents, usedforsecurity=False)
|
||||
hash_code = hashlib.md5(expected_contents, usedforsecurity=False)
|
||||
expected_checksum = hash_code.hexdigest()
|
||||
fake_size.__get__ = mock.Mock(return_value=expected_size)
|
||||
with mock.patch('hashlib.md5') as md5:
|
||||
@ -331,8 +330,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
def test_reader_full(self):
|
||||
content = b'XXX'
|
||||
image = io.BytesIO(content)
|
||||
expected_checksum = secretutils.md5(content,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(
|
||||
content, usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(content).hexdigest()
|
||||
reader = vm_store._Reader(image, self.hash_algo)
|
||||
ret = reader.read()
|
||||
@ -344,8 +343,8 @@ class TestMultiStore(base.MultiStoreBaseTest,
|
||||
def test_reader_partial(self):
|
||||
content = b'XXX'
|
||||
image = io.BytesIO(content)
|
||||
expected_checksum = secretutils.md5(b'X',
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(
|
||||
b'X', usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(b'X').hexdigest()
|
||||
reader = vm_store._Reader(image, self.hash_algo)
|
||||
ret = reader.read(1)
|
||||
|
@ -17,7 +17,6 @@ import hashlib
|
||||
import io
|
||||
from unittest import mock
|
||||
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
|
||||
from glance_store._drivers import rbd as rbd_store
|
||||
@ -434,8 +433,8 @@ class TestStore(base.StoreBaseTest,
|
||||
file_size = 5 * units.Ki # 5K
|
||||
file_contents = b"*" * file_size
|
||||
image_file = io.BytesIO(file_contents)
|
||||
expected_checksum = md5(file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(file_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(file_contents).hexdigest()
|
||||
|
||||
with mock.patch.object(rbd_store.rbd.Image, 'write'):
|
||||
@ -508,8 +507,8 @@ class TestStore(base.StoreBaseTest,
|
||||
|
||||
image_id = 'fake_image_id'
|
||||
image_file = io.BytesIO(content)
|
||||
expected_checksum = md5(content,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(content,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(content).hexdigest()
|
||||
|
||||
with mock.patch.object(rbd_store.rbd.Image, 'write') as mock_write:
|
||||
|
@ -24,7 +24,6 @@ import boto3
|
||||
import botocore
|
||||
from botocore import exceptions as boto_exceptions
|
||||
from botocore import stub
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
|
||||
from glance_store._drivers import s3
|
||||
@ -209,8 +208,8 @@ class TestStore(base.StoreBaseTest,
|
||||
# 5KiB is smaller than WRITE_CHUNKSIZE
|
||||
expected_s3_size = FIVE_KB
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
@ -261,8 +260,8 @@ class TestStore(base.StoreBaseTest,
|
||||
# but smaller than s3_store_large_object_size
|
||||
expected_s3_size = 8 * units.Mi
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
@ -334,8 +333,8 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_s3_size = 16 * units.Mi
|
||||
expected_s3_contents = b"*" * expected_s3_size
|
||||
expected_checksum = md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_s3_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(expected_s3_contents).hexdigest()
|
||||
expected_location = format_s3_location(
|
||||
S3_CONF['s3_store_access_key'],
|
||||
|
@ -28,7 +28,6 @@ import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
import requests_mock
|
||||
import swiftclient
|
||||
@ -120,7 +119,7 @@ class SwiftTests(object):
|
||||
if kwargs.get('headers'):
|
||||
manifest = kwargs.get('headers').get('X-Object-Manifest')
|
||||
etag = kwargs.get('headers') \
|
||||
.get('ETag', md5(
|
||||
.get('ETag', hashlib.md5(
|
||||
b'', usedforsecurity=False).hexdigest())
|
||||
fixture_headers[fixture_key] = {
|
||||
'manifest': True,
|
||||
@ -133,7 +132,7 @@ class SwiftTests(object):
|
||||
fixture_object = io.BytesIO()
|
||||
read_len = 0
|
||||
chunk = contents.read(CHUNKSIZE)
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
while chunk:
|
||||
fixture_object.write(chunk)
|
||||
read_len += len(chunk)
|
||||
@ -143,8 +142,8 @@ class SwiftTests(object):
|
||||
else:
|
||||
fixture_object = io.BytesIO(contents)
|
||||
read_len = len(contents)
|
||||
etag = md5(fixture_object.getvalue(),
|
||||
usedforsecurity=False).hexdigest()
|
||||
etag = hashlib.md5(fixture_object.getvalue(),
|
||||
usedforsecurity=False).hexdigest()
|
||||
if read_len > MAX_SWIFT_OBJECT_SIZE:
|
||||
msg = ('Image size:%d exceeds Swift max:%d' %
|
||||
(read_len, MAX_SWIFT_OBJECT_SIZE))
|
||||
@ -422,8 +421,8 @@ class SwiftTests(object):
|
||||
self.store.configure()
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(
|
||||
expected_swift_contents).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
@ -571,7 +570,8 @@ class SwiftTests(object):
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = \
|
||||
md5(expected_swift_contents, usedforsecurity=False).hexdigest()
|
||||
hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = \
|
||||
hashlib.sha256(expected_swift_contents).hexdigest()
|
||||
|
||||
@ -647,8 +647,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = \
|
||||
hashlib.sha256(expected_swift_contents).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
@ -694,8 +694,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = \
|
||||
hashlib.sha256(expected_swift_contents).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
@ -916,8 +916,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = \
|
||||
hashlib.sha256(expected_swift_contents).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
@ -971,8 +971,8 @@ class SwiftTests(object):
|
||||
# Set up a 'large' image of 5KB
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = \
|
||||
hashlib.sha256(expected_swift_contents).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
@ -2037,14 +2037,15 @@ class TestChunkReader(base.StoreBaseTest):
|
||||
"""
|
||||
CHUNKSIZE = 100
|
||||
data = b'*' * units.Ki
|
||||
expected_checksum = md5(data, usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(data,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(data).hexdigest()
|
||||
data_file = tempfile.NamedTemporaryFile()
|
||||
data_file.write(data)
|
||||
data_file.flush()
|
||||
infile = open(data_file.name, 'rb')
|
||||
bytes_read = 0
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
while True:
|
||||
cr = swift.ChunkReader(infile, checksum, os_hash_value, CHUNKSIZE)
|
||||
@ -2066,10 +2067,10 @@ class TestChunkReader(base.StoreBaseTest):
|
||||
Replicate what goes on in the Swift driver with the
|
||||
repeated creation of the ChunkReader object
|
||||
"""
|
||||
expected_checksum = md5(b'', usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(b'', usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(b'').hexdigest()
|
||||
CHUNKSIZE = 100
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
data_file = tempfile.NamedTemporaryFile()
|
||||
infile = open(data_file.name, 'rb')
|
||||
@ -2165,7 +2166,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
self.infile = io.BytesIO(s)
|
||||
self.infile.seek(0)
|
||||
|
||||
self.checksum = md5(usedforsecurity=False)
|
||||
self.checksum = hashlib.md5(usedforsecurity=False)
|
||||
self.hash_algo = HASH_ALGO
|
||||
self.os_hash_value = hashlib.sha256()
|
||||
self.verifier = mock.MagicMock(name='mock_verifier')
|
||||
@ -2225,7 +2226,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
|
||||
def test_checksums(self):
|
||||
# checksums are updated only once on a full segment read
|
||||
expected_csum = md5(usedforsecurity=False)
|
||||
expected_csum = hashlib.md5(usedforsecurity=False)
|
||||
expected_csum.update(b'1234567')
|
||||
expected_multihash = hashlib.sha256()
|
||||
expected_multihash.update(b'1234567')
|
||||
@ -2237,7 +2238,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
def test_checksum_updated_only_once_w_full_segment_read(self):
|
||||
# Test that checksums are updated only once when a full segment read
|
||||
# is followed by a seek and partial reads.
|
||||
expected_csum = md5(usedforsecurity=False)
|
||||
expected_csum = hashlib.md5(usedforsecurity=False)
|
||||
expected_csum.update(b'1234567')
|
||||
expected_multihash = hashlib.sha256()
|
||||
expected_multihash.update(b'1234567')
|
||||
@ -2252,7 +2253,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
def test_checksum_updates_during_partial_segment_reads(self):
|
||||
# Test to check that checksums are updated with only the bytes
|
||||
# not seen when the number of bytes being read is changed
|
||||
expected_csum = md5(usedforsecurity=False)
|
||||
expected_csum = hashlib.md5(usedforsecurity=False)
|
||||
expected_multihash = hashlib.sha256()
|
||||
self.reader.read(4)
|
||||
expected_csum.update(b'1234')
|
||||
@ -2275,7 +2276,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
|
||||
def test_checksum_rolling_calls(self):
|
||||
# Test that the checksum continues on to the next segment
|
||||
expected_csum = md5(usedforsecurity=False)
|
||||
expected_csum = hashlib.md5(usedforsecurity=False)
|
||||
expected_multihash = hashlib.sha256()
|
||||
self.reader.read(7)
|
||||
expected_csum.update(b'1234567')
|
||||
@ -2344,7 +2345,7 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
infile = io.BytesIO(s)
|
||||
infile.seek(0)
|
||||
total = 7
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
self.reader = buffered.BufferedReader(
|
||||
infile, checksum, os_hash_value, total)
|
||||
@ -2369,14 +2370,15 @@ class TestBufferedReader(base.StoreBaseTest):
|
||||
"""
|
||||
CHUNKSIZE = 100
|
||||
data = b'*' * units.Ki
|
||||
expected_checksum = md5(data, usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(data,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(data).hexdigest()
|
||||
data_file = tempfile.NamedTemporaryFile()
|
||||
data_file.write(data)
|
||||
data_file.flush()
|
||||
infile = open(data_file.name, 'rb')
|
||||
bytes_read = 0
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
while True:
|
||||
cr = buffered.BufferedReader(infile, checksum, os_hash_value,
|
||||
|
@ -28,7 +28,6 @@ import uuid
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils.secretutils import md5
|
||||
from oslo_utils import units
|
||||
import requests_mock
|
||||
import swiftclient
|
||||
@ -111,7 +110,7 @@ class SwiftTests(object):
|
||||
if kwargs.get('headers'):
|
||||
manifest = kwargs.get('headers').get('X-Object-Manifest')
|
||||
etag = kwargs.get('headers') \
|
||||
.get('ETag', md5(
|
||||
.get('ETag', hashlib.md5(
|
||||
b'', usedforsecurity=False).hexdigest())
|
||||
fixture_headers[fixture_key] = {
|
||||
'manifest': True,
|
||||
@ -124,7 +123,7 @@ class SwiftTests(object):
|
||||
fixture_object = io.BytesIO()
|
||||
read_len = 0
|
||||
chunk = contents.read(CHUNKSIZE)
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
while chunk:
|
||||
fixture_object.write(chunk)
|
||||
read_len += len(chunk)
|
||||
@ -134,8 +133,8 @@ class SwiftTests(object):
|
||||
else:
|
||||
fixture_object = io.BytesIO(contents)
|
||||
read_len = len(contents)
|
||||
etag = md5(fixture_object.getvalue(),
|
||||
usedforsecurity=False).hexdigest()
|
||||
etag = hashlib.md5(fixture_object.getvalue(),
|
||||
usedforsecurity=False).hexdigest()
|
||||
if read_len > MAX_SWIFT_OBJECT_SIZE:
|
||||
msg = ('Image size:%d exceeds Swift max:%d' %
|
||||
(read_len, MAX_SWIFT_OBJECT_SIZE))
|
||||
@ -397,8 +396,8 @@ class SwiftTests(object):
|
||||
self.store.configure()
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
loc = "swift+https://tenant%%3Auser1:key@localhost:8080/glance/%s"
|
||||
expected_location = loc % (expected_image_id)
|
||||
@ -522,7 +521,8 @@ class SwiftTests(object):
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = \
|
||||
md5(expected_swift_contents, usedforsecurity=False).hexdigest()
|
||||
hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
|
||||
image_swift = io.BytesIO(expected_swift_contents)
|
||||
|
||||
@ -597,8 +597,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
loc = 'swift+config://ref1/noexist/%s'
|
||||
expected_location = loc % (expected_image_id)
|
||||
@ -644,8 +644,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
container = 'randomname_' + expected_image_id[:2]
|
||||
loc = 'swift+config://ref1/%s/%s'
|
||||
@ -869,8 +869,8 @@ class SwiftTests(object):
|
||||
"""
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
loc = 'swift+config://ref1/glance/%s'
|
||||
expected_location = loc % (expected_image_id)
|
||||
@ -924,8 +924,8 @@ class SwiftTests(object):
|
||||
# Set up a 'large' image of 5KB
|
||||
expected_swift_size = FIVE_KB
|
||||
expected_swift_contents = b"*" * expected_swift_size
|
||||
expected_checksum = md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(expected_swift_contents,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
loc = 'swift+config://ref1/glance/%s'
|
||||
expected_location = loc % (expected_image_id)
|
||||
@ -2139,14 +2139,15 @@ class TestChunkReader(base.MultiStoreBaseTest):
|
||||
"""
|
||||
CHUNKSIZE = 100
|
||||
data = b'*' * units.Ki
|
||||
expected_checksum = md5(data, usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(data,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(data).hexdigest()
|
||||
data_file = tempfile.NamedTemporaryFile()
|
||||
data_file.write(data)
|
||||
data_file.flush()
|
||||
infile = open(data_file.name, 'rb')
|
||||
bytes_read = 0
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
while True:
|
||||
cr = swift.ChunkReader(infile, checksum, os_hash_value, CHUNKSIZE)
|
||||
@ -2168,10 +2169,10 @@ class TestChunkReader(base.MultiStoreBaseTest):
|
||||
Replicate what goes on in the Swift driver with the
|
||||
repeated creation of the ChunkReader object
|
||||
"""
|
||||
expected_checksum = md5(b'', usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(b'', usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(b'').hexdigest()
|
||||
CHUNKSIZE = 100
|
||||
checksum = md5(usedforsecurity=False)
|
||||
checksum = hashlib.md5(usedforsecurity=False)
|
||||
os_hash_value = hashlib.sha256()
|
||||
data_file = tempfile.NamedTemporaryFile()
|
||||
infile = open(data_file.name, 'rb')
|
||||
|
@ -20,7 +20,6 @@ import io
|
||||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
from oslo_utils import secretutils
|
||||
from oslo_utils import units
|
||||
from oslo_vmware import api
|
||||
from oslo_vmware import exceptions as vmware_exceptions
|
||||
@ -146,7 +145,7 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_size = FIVE_KB
|
||||
expected_contents = b"*" * expected_size
|
||||
hash_code = secretutils.md5(expected_contents, usedforsecurity=False)
|
||||
hash_code = hashlib.md5(expected_contents, usedforsecurity=False)
|
||||
expected_checksum = hash_code.hexdigest()
|
||||
sha256_code = hashlib.sha256(expected_contents)
|
||||
expected_multihash = sha256_code.hexdigest()
|
||||
@ -191,7 +190,7 @@ class TestStore(base.StoreBaseTest,
|
||||
expected_image_id = str(uuid.uuid4())
|
||||
expected_size = FIVE_KB
|
||||
expected_contents = b"*" * expected_size
|
||||
hash_code = secretutils.md5(expected_contents, usedforsecurity=False)
|
||||
hash_code = hashlib.md5(expected_contents, usedforsecurity=False)
|
||||
expected_checksum = hash_code.hexdigest()
|
||||
sha256_code = hashlib.sha256(expected_contents)
|
||||
expected_multihash = sha256_code.hexdigest()
|
||||
@ -304,8 +303,8 @@ class TestStore(base.StoreBaseTest,
|
||||
def test_reader_full(self):
|
||||
content = b'XXX'
|
||||
image = io.BytesIO(content)
|
||||
expected_checksum = secretutils.md5(content,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(content,
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(content).hexdigest()
|
||||
reader = vm_store._Reader(image, self.hash_algo)
|
||||
ret = reader.read()
|
||||
@ -317,8 +316,8 @@ class TestStore(base.StoreBaseTest,
|
||||
def test_reader_partial(self):
|
||||
content = b'XXX'
|
||||
image = io.BytesIO(content)
|
||||
expected_checksum = secretutils.md5(b'X',
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_checksum = hashlib.md5(b'X',
|
||||
usedforsecurity=False).hexdigest()
|
||||
expected_multihash = hashlib.sha256(b'X').hexdigest()
|
||||
reader = vm_store._Reader(image, self.hash_algo)
|
||||
ret = reader.read(1)
|
||||
|
5
releasenotes/notes/remove-py38-ad3b92513d4381e3.yaml
Normal file
5
releasenotes/notes/remove-py38-ad3b92513d4381e3.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Support for Python 3.8 has been removed. Now the minimum python version
|
||||
supported is 3.9 .
|
Loading…
Reference in New Issue
Block a user