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:
Ninh Khong 2020-08-03 19:42:42 +07:00 committed by GitHub
parent 252d679b27
commit 061c609a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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