From 1c96335895357d79549094de55f722b5fe3b1be2 Mon Sep 17 00:00:00 2001 From: Ali Rizwan Date: Wed, 16 Aug 2017 12:49:03 +0200 Subject: [PATCH] get_parameters should list InvalidParameters Signed-off-by: Ali Rizwan --- moto/ssm/responses.py | 4 ++++ tests/test_ssm/test_ssm_boto3.py | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/moto/ssm/responses.py b/moto/ssm/responses.py index 73c29484a..7c31a6dd9 100644 --- a/moto/ssm/responses.py +++ b/moto/ssm/responses.py @@ -57,6 +57,10 @@ class SimpleSystemManagerResponse(BaseResponse): param_data = parameter.response_object(with_decryption) response['Parameters'].append(param_data) + param_names = [param.name for param in result] + for name in names: + if name not in param_names: + response['InvalidParameters'].append(name) return json.dumps(response) def describe_parameters(self): diff --git a/tests/test_ssm/test_ssm_boto3.py b/tests/test_ssm/test_ssm_boto3.py index 38e266445..7a783299b 100644 --- a/tests/test_ssm/test_ssm_boto3.py +++ b/tests/test_ssm/test_ssm_boto3.py @@ -161,7 +161,6 @@ def test_describe_parameters_filter_type(): p['KeyId'] = 'a key' client.put_parameter(**p) - response = client.describe_parameters(Filters=[ { 'Key': 'Type', @@ -188,7 +187,6 @@ def test_describe_parameters_filter_keyid(): p['KeyId'] = "key:%d" % i client.put_parameter(**p) - response = client.describe_parameters(Filters=[ { 'Key': 'KeyId', @@ -201,6 +199,20 @@ def test_describe_parameters_filter_keyid(): ''.should.equal(response.get('NextToken', '')) +@mock_ssm +def test_get_parameter_invalid(): + client = client = boto3.client('ssm', region_name='us-east-1') + response = client.get_parameters( + Names=[ + 'invalid' + ], + WithDecryption=False) + + len(response['Parameters']).should.equal(0) + len(response['InvalidParameters']).should.equal(1) + response['InvalidParameters'][0].should.equal('invalid') + + @mock_ssm def test_put_parameter_secure_default_kms(): client = boto3.client('ssm', region_name='us-east-1')