fix(secretsmanager): fix update of no-value initial secret (#6771)

This commit is contained in:
JoshuaLicense 2023-09-05 22:04:44 +01:00 committed by GitHub
parent 3256af7454
commit 49f5a48f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -126,9 +126,12 @@ class FakeSecret:
if "AWSPREVIOUS" in old_version["version_stages"]:
old_version["version_stages"].remove("AWSPREVIOUS")
# set old AWSCURRENT secret to AWSPREVIOUS
previous_current_version_id = self.default_version_id
self.versions[previous_current_version_id]["version_stages"] = ["AWSPREVIOUS"] # type: ignore
if self.default_version_id:
# set old AWSCURRENT secret to AWSPREVIOUS
previous_current_version_id = self.default_version_id
self.versions[previous_current_version_id]["version_stages"] = [
"AWSPREVIOUS"
]
self.versions[version_id] = secret_version
self.default_version_id = version_id

View File

@ -292,6 +292,22 @@ def test_create_secret_without_value():
assert set(deleted.keys()) == {"ARN", "Name", "DeletionDate", "ResponseMetadata"}
@mock_secretsmanager
def test_create_secret_that_has_no_value_and_then_update():
conn = boto3.client("secretsmanager", region_name="us-west-2")
conn.create_secret(Name="secret-no-value")
conn.update_secret(
SecretId="secret-no-value",
SecretString="barsecret",
Description="desc",
)
secret = conn.get_secret_value(SecretId="secret-no-value")
assert secret["SecretString"] == "barsecret"
@mock_secretsmanager
def test_update_secret_without_value():
conn = boto3.client("secretsmanager", region_name="us-east-2")