parameters return from root path (#1701)

This commit is contained in:
Nate Peterson 2018-07-13 03:24:11 -06:00 committed by Terry Cain
parent 51db19067c
commit dcdaca8984
2 changed files with 24 additions and 1 deletions

View File

@ -100,7 +100,7 @@ class SimpleSystemManagerBackend(BaseBackend):
# difference here. # difference here.
path = path.rstrip('/') + '/' path = path.rstrip('/') + '/'
for param in self._parameters: for param in self._parameters:
if not param.startswith(path): if path != '/' and not param.startswith(path):
continue continue
if '/' in param[len(path) + 1:] and not recursive: if '/' in param[len(path) + 1:] and not recursive:
continue continue

View File

@ -95,6 +95,27 @@ def test_get_parameters_by_path():
Type='SecureString', Type='SecureString',
KeyId='alias/aws/ssm') KeyId='alias/aws/ssm')
client.put_parameter(
Name='foo',
Description='A test parameter',
Value='bar',
Type='String')
client.put_parameter(
Name='baz',
Description='A test parameter',
Value='qux',
Type='String')
response = client.get_parameters_by_path(Path='/', Recursive=False)
len(response['Parameters']).should.equal(2)
{p['Value'] for p in response['Parameters']}.should.equal(
set(['bar', 'qux'])
)
response = client.get_parameters_by_path(Path='/', Recursive=True)
len(response['Parameters']).should.equal(9)
response = client.get_parameters_by_path(Path='/foo') response = client.get_parameters_by_path(Path='/foo')
len(response['Parameters']).should.equal(2) len(response['Parameters']).should.equal(2)
{p['Value'] for p in response['Parameters']}.should.equal( {p['Value'] for p in response['Parameters']}.should.equal(
@ -417,6 +438,7 @@ def test_describe_parameters_filter_keyid():
response['Parameters'][0]['Type'].should.equal('SecureString') response['Parameters'][0]['Type'].should.equal('SecureString')
''.should.equal(response.get('NextToken', '')) ''.should.equal(response.get('NextToken', ''))
@mock_ssm @mock_ssm
def test_describe_parameters_attributes(): def test_describe_parameters_attributes():
client = boto3.client('ssm', region_name='us-east-1') client = boto3.client('ssm', region_name='us-east-1')
@ -445,6 +467,7 @@ def test_describe_parameters_attributes():
response['Parameters'][1].get('Description').should.be.none response['Parameters'][1].get('Description').should.be.none
response['Parameters'][1]['Version'].should.equal(1) response['Parameters'][1]['Version'].should.equal(1)
@mock_ssm @mock_ssm
def test_get_parameter_invalid(): def test_get_parameter_invalid():
client = client = boto3.client('ssm', region_name='us-east-1') client = client = boto3.client('ssm', region_name='us-east-1')