diff --git a/src/charm.py b/src/charm.py index bed3f58..9a2cc02 100755 --- a/src/charm.py +++ b/src/charm.py @@ -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: diff --git a/unit_tests/test_ceph_dashboard_charm.py b/unit_tests/test_ceph_dashboard_charm.py index b835c0a..14d226a 100644 --- a/unit_tests/test_ceph_dashboard_charm.py +++ b/unit_tests/test_ceph_dashboard_charm.py @@ -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')