Fix secretsmanager random password wrong length (#3213)
* Enhance function get_parameter by parameter name, version or labels * Fix random password with exclude characters return wrong length
This commit is contained in:
parent
252d679b27
commit
061c609a8f
@ -51,6 +51,8 @@ def random_password(
|
||||
if include_space:
|
||||
password += " "
|
||||
required_characters += " "
|
||||
if exclude_characters:
|
||||
password = _exclude_characters(password, exclude_characters)
|
||||
|
||||
password = "".join(
|
||||
six.text_type(random.choice(password)) for x in range(password_length)
|
||||
@ -61,7 +63,6 @@ def random_password(
|
||||
password, required_characters
|
||||
)
|
||||
|
||||
password = _exclude_characters(password, exclude_characters)
|
||||
return password
|
||||
|
||||
|
||||
|
@ -338,6 +338,7 @@ def test_get_random_exclude_characters_and_symbols():
|
||||
PasswordLength=20, ExcludeCharacters="xyzDje@?!."
|
||||
)
|
||||
assert any(c in "xyzDje@?!." for c in random_password["RandomPassword"]) == False
|
||||
assert len(random_password["RandomPassword"]) == 20
|
||||
|
||||
|
||||
@mock_secretsmanager
|
||||
|
Loading…
Reference in New Issue
Block a user