Merge "Replace generate password for alternative in passlib"
This commit is contained in:
commit
827659b6ac
@ -6,6 +6,7 @@ pbr>=0.6,!=0.7,<1.0
|
||||
Babel>=1.3
|
||||
cliff>=1.7.0 # Apache-2.0
|
||||
ipaddress
|
||||
passlib>=1.6
|
||||
python-ironic-inspector-client>=1.0.1
|
||||
os-cloud-config
|
||||
python-heatclient>=0.3.0
|
||||
|
@ -25,7 +25,7 @@ from unittest import TestCase
|
||||
class TestPasswordsUtil(TestCase):
|
||||
|
||||
@mock.patch("os.path.isfile", return_value=False)
|
||||
@mock.patch("tripleoclient.utils._generate_password",
|
||||
@mock.patch("passlib.utils.generate_password",
|
||||
return_value="PASSWORD")
|
||||
def test_generate_passwords(self, generate_password_mock, isfile_mock):
|
||||
|
||||
@ -54,7 +54,7 @@ class TestPasswordsUtil(TestCase):
|
||||
self.assertEqual(len(passwords), 13)
|
||||
|
||||
@mock.patch("os.path.isfile", return_value=True)
|
||||
@mock.patch("tripleoclient.utils._generate_password",
|
||||
@mock.patch("passlib.utils.generate_password",
|
||||
return_value="PASSWORD")
|
||||
def test_load_passwords(self, generate_password_mock, isfile_mock):
|
||||
PASSWORDS = [
|
||||
|
@ -18,13 +18,13 @@ import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import passlib.utils as passutils
|
||||
import re
|
||||
import six
|
||||
import struct
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from tripleoclient import exceptions
|
||||
|
||||
@ -48,16 +48,7 @@ SERVICE_LIST = {
|
||||
}
|
||||
|
||||
|
||||
def _generate_password():
|
||||
"""Create a random password
|
||||
|
||||
The password is made by taking a uuid and passing it though sha1sum.
|
||||
We may change this in future to gain more entropy.
|
||||
|
||||
This is based on the tripleo command os-make-password
|
||||
"""
|
||||
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
|
||||
return hashlib.sha1(uuid_str).hexdigest()
|
||||
_MIN_PASSWORD_SIZE = 25
|
||||
|
||||
|
||||
def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
|
||||
@ -88,7 +79,8 @@ def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
|
||||
"OVERCLOUD_SWIFT_PASSWORD",
|
||||
)
|
||||
|
||||
passwords = dict((p, _generate_password()) for p in password_names)
|
||||
passwords = dict((p, passutils.generate_password(size=_MIN_PASSWORD_SIZE))
|
||||
for p in password_names)
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
for name, password in passwords.items():
|
||||
|
Loading…
x
Reference in New Issue
Block a user