diff --git a/tempest_lib/common/utils/data_utils.py b/tempest_lib/common/utils/data_utils.py index 046dd6c..01b6477 100644 --- a/tempest_lib/common/utils/data_utils.py +++ b/tempest_lib/common/utils/data_utils.py @@ -61,6 +61,7 @@ def rand_password(length=15): """Generate a random password :param int length: The length of password that you expect to set + (If it's smaller than 3, it's same as 3.) :return: a random password. The format is '-- -' diff --git a/tempest_lib/tests/common/utils/test_data_utils.py b/tempest_lib/tests/common/utils/test_data_utils.py index 81dee57..2d7b8fc 100644 --- a/tempest_lib/tests/common/utils/test_data_utils.py +++ b/tempest_lib/tests/common/utils/test_data_utils.py @@ -66,10 +66,19 @@ class TestDataUtils(base.TestCase): def test_rand_password_with_len(self): actual = data_utils.rand_password(8) self.assertIsInstance(actual, str) + self.assertEqual(len(actual), 8) self.assertRegexpMatches(actual, "[A-Za-z0-9~!@#$%^&*_=+]{8}") actual2 = data_utils.rand_password(8) self.assertNotEqual(actual, actual2) + def test_rand_password_with_len_2(self): + actual = data_utils.rand_password(2) + self.assertIsInstance(actual, str) + self.assertEqual(len(actual), 3) + self.assertRegexpMatches(actual, "[A-Za-z0-9~!@#$%^&*_=+]{3}") + actual2 = data_utils.rand_password(2) + self.assertNotEqual(actual, actual2) + def test_rand_url(self): actual = data_utils.rand_url() self.assertIsInstance(actual, str)