Modify SSM put_parameter()
to raise ValidationException if value is empty string (#3806)
* Modify put_parameter() to raise ValidationError when value is empty string * Simplify empty string check Co-authored-by: Tom Noble <tom.noble@bjss.com>
This commit is contained in:
parent
f549f1d087
commit
a001c59f7e
@ -1284,6 +1284,11 @@ class SimpleSystemManagerBackend(BaseBackend):
|
|||||||
def put_parameter(
|
def put_parameter(
|
||||||
self, name, description, value, type, allowed_pattern, keyid, overwrite, tags,
|
self, name, description, value, type, allowed_pattern, keyid, overwrite, tags,
|
||||||
):
|
):
|
||||||
|
if not value:
|
||||||
|
raise ValidationException(
|
||||||
|
"1 validation error detected: Value '' at 'value' failed to satisfy"
|
||||||
|
" constraint: Member must have length greater than or equal to 1."
|
||||||
|
)
|
||||||
if name.lower().lstrip("/").startswith("aws") or name.lower().lstrip(
|
if name.lower().lstrip("/").startswith("aws") or name.lower().lstrip(
|
||||||
"/"
|
"/"
|
||||||
).startswith("ssm"):
|
).startswith("ssm"):
|
||||||
|
@ -299,6 +299,22 @@ def test_put_parameter():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ssm
|
||||||
|
def test_put_parameter_empty_string_value():
|
||||||
|
client = boto3.client("ssm", region_name="us-east-1")
|
||||||
|
with pytest.raises(ClientError) as e:
|
||||||
|
client.put_parameter(Name="test_name", Value="", Type="String")
|
||||||
|
ex = e.value
|
||||||
|
ex.operation_name.should.equal("PutParameter")
|
||||||
|
ex.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||||
|
ex.response["Error"]["Code"].should.contain("ValidationException")
|
||||||
|
ex.response["Error"]["Message"].should.equal(
|
||||||
|
"1 validation error detected: "
|
||||||
|
"Value '' at 'value' failed to satisfy constraint: "
|
||||||
|
"Member must have length greater than or equal to 1."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_ssm
|
@mock_ssm
|
||||||
def test_put_parameter_invalid_names():
|
def test_put_parameter_invalid_names():
|
||||||
client = boto3.client("ssm", region_name="us-east-1")
|
client = boto3.client("ssm", region_name="us-east-1")
|
||||||
|
Loading…
Reference in New Issue
Block a user