Drop pycrypto from tests dependencies

pycrypto is unmaintained for a while and requirements team advises using
pycryptodome or cryptography libraries instead (see openstack-dev thread
[0]).

troveclient uses pycrypto to generate random data/content in its tests
which does not require any specific cryptographic need. This commit
replaces it by os.urandom from Python standard library.

[0] http://lists.openstack.org/pipermail/openstack-dev/2017-March/113568.html

Change-Id: Ia43c5883a51e8412c4a238d127c13db39e863da1
This commit is contained in:
Haikel Guemar 2017-07-18 12:23:40 +02:00
parent 348822b8a5
commit d512e4763d
3 changed files with 4 additions and 6 deletions

View File

@ -14,5 +14,4 @@ testscenarios>=0.4 # Apache-2.0/BSD
testtools>=1.4.0 # MIT
mock>=2.0 # BSD
httplib2>=0.7.5 # MIT
pycrypto>=2.6 # Public Domain
reno!=2.3.1,>=1.8.0 # Apache-2.0

View File

@ -14,8 +14,8 @@
# under the License.
#
import Crypto.Random
import mock
import os
import testtools
from troveclient.v1 import modules
@ -55,7 +55,7 @@ class TestModules(testtools.TestCase):
return path, body, mod
text_contents = "my_contents"
binary_contents = Crypto.Random.new().read(20)
binary_contents = os.urandom(20)
for contents in [text_contents, binary_contents]:
self.modules._create = mock.Mock(side_effect=side_effect_func)
path, body, mod = self.modules.create(

View File

@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import Crypto.Random
import os
import tempfile
import testtools
@ -55,8 +54,8 @@ class UtilsTest(testtools.TestCase):
text_data_bytes = bytes('This is a byte stream', 'utf-8')
except TypeError:
text_data_bytes = bytes('This is a byte stream')
random_data_str = Crypto.Random.new().read(12)
random_data_bytes = bytearray(Crypto.Random.new().read(12))
random_data_str = os.urandom(12)
random_data_bytes = bytearray(os.urandom(12))
special_char_str = '\x00\xFF\x00\xFF\xFF\x00'
special_char_bytes = bytearray(
[ord(item) for item in special_char_str])