Merge "Don't use custom password generating code"

This commit is contained in:
Zuul 2018-03-28 16:11:01 +00:00 committed by Gerrit Code Review
commit 575d7c855e
4 changed files with 19 additions and 6 deletions

View File

@ -14,6 +14,7 @@
# under the License.
import copy
import re
import time
import mock
@ -1299,6 +1300,11 @@ class XtremIODriverISCSITestCase(BaseXtremIODriverTestCase):
self.driver.create_group_from_src,
d.context, d.group, [], None, None, None, None)
def test_get_password(self, _req):
p = self.driver._get_password()
self.assertEqual(len(p), 12)
self.assertIsNotNone(re.match(r'[A-Z0-9]{12}', p), p)
@mock.patch('requests.request')
class XtremIODriverTestCase(BaseXtremIODriverTestCase):

View File

@ -15,6 +15,7 @@
# under the License.
import datetime
import re
import six
import ddt
@ -2049,3 +2050,9 @@ class SolidFireVolumeTestCase(test.TestCase):
'port': 443}
ep = sfv._build_endpoint_info(mvip='1.2.3.4', password='nunyabiz')
self.assertEqual(expected_ep, ep)
def test_generate_random_string(self):
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
a = sfv._generate_random_string(12)
self.assertEqual(len(a), 12)
self.assertIsNotNone(re.match(r'[A-Z0-9]{12}', a), a)

View File

@ -752,9 +752,9 @@ class XtremIOVolumeDriver(san.SanDriver):
LOG.warning('Failed to clean IG %d without mappings', idx)
def _get_password(self):
return ''.join(RANDOM.choice
(string.ascii_uppercase + string.digits)
for _ in range(12))
return vutils.generate_password(
length=12,
symbolgroups=(string.ascii_uppercase + string.digits))
def create_lun_map(self, volume, ig, lun_num=None):
try:

View File

@ -16,7 +16,6 @@
import inspect
import json
import math
import random
import re
import socket
import string
@ -655,8 +654,9 @@ class SolidFireDriver(san.SanISCSIDriver):
def _generate_random_string(self, length):
"""Generates random_string to use for CHAP password."""
char_set = string.ascii_uppercase + string.digits
return ''.join(random.sample(char_set, length))
return vol_utils.generate_password(
length=length,
symbolgroups=(string.ascii_uppercase + string.digits))
def _get_model_info(self, sfaccount, sf_volume_id, endpoint=None):
"""Gets the connection info for specified account and volume."""