Increase password complexity

Use upper and lower case letter as well as digits for characters
in password, also increase password length.

Change-Id: I2739166a95a09b4363eebe6b8cc6aac8e87f3c2d
This commit is contained in:
Liam Young 2021-09-09 08:14:18 +00:00
parent 5561c896b3
commit 26e80441c2
2 changed files with 5 additions and 3 deletions

View File

@ -424,9 +424,11 @@ class CephDashboardCharm(ops_openstack.core.OSBaseCharm):
self.TLS_KEY_PATH)
self.kick_dashboard()
def _gen_user_password(self, length: int = 8) -> str:
def _gen_user_password(self, length: int = 12) -> str:
"""Generate a password"""
alphabet = string.ascii_letters + string.digits
alphabet = (
string.ascii_lowercase + string.ascii_uppercase + string.digits)
return ''.join(secrets.choice(alphabet) for i in range(length))
def _add_user_action(self, event: ActionEvent) -> None:

View File

@ -470,7 +470,7 @@ class TestCephDashboardCharmBase(CharmTestCase):
_choice.return_value = 'r'
self.assertEqual(
self.harness.charm._gen_user_password(),
'rrrrrrrr')
'rrrrrrrrrrrr')
@patch.object(charm.tempfile, 'NamedTemporaryFile')
@patch.object(charm.secrets, 'choice')