Implement SSM Parameter Store filters support (GetParametersByPath API) (#1604)

* added tests for SSM Parameter Store filters (GetParametersByPath - ParameterStringFilter)

* implemented SSM Parameter Store filters support (only for get_parameters_by_path API)

* adding myself to authors file
This commit is contained in:
Alex Casalboni 2018-04-30 20:02:47 +02:00 committed by Jack Danger
commit cb364eedc6
4 changed files with 117 additions and 2 deletions

View file

@ -76,6 +76,25 @@ def test_get_parameters_by_path():
Value='value4',
Type='String')
client.put_parameter(
Name='/baz/name1',
Description='A test parameter (list)',
Value='value1,value2,value3',
Type='StringList')
client.put_parameter(
Name='/baz/name2',
Description='A test parameter',
Value='value1',
Type='String')
client.put_parameter(
Name='/baz/pwd',
Description='A secure test parameter',
Value='my_secret',
Type='SecureString',
KeyId='alias/aws/ssm')
response = client.get_parameters_by_path(Path='/foo')
len(response['Parameters']).should.equal(2)
{p['Value'] for p in response['Parameters']}.should.equal(
@ -92,6 +111,75 @@ def test_get_parameters_by_path():
set(['value3', 'value4'])
)
response = client.get_parameters_by_path(Path='/baz')
len(response['Parameters']).should.equal(3)
filters = [{
'Key': 'Type',
'Option': 'Equals',
'Values': ['StringList'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(1)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/name1'])
)
# note: 'Option' is optional (default: 'Equals')
filters = [{
'Key': 'Type',
'Values': ['StringList'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(1)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/name1'])
)
filters = [{
'Key': 'Type',
'Option': 'Equals',
'Values': ['String'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(1)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/name2'])
)
filters = [{
'Key': 'Type',
'Option': 'Equals',
'Values': ['String', 'SecureString'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(2)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/name2', '/baz/pwd'])
)
filters = [{
'Key': 'Type',
'Option': 'BeginsWith',
'Values': ['String'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(2)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/name1', '/baz/name2'])
)
filters = [{
'Key': 'KeyId',
'Option': 'Equals',
'Values': ['alias/aws/ssm'],
}]
response = client.get_parameters_by_path(Path='/baz', ParameterFilters=filters)
len(response['Parameters']).should.equal(1)
{p['Name'] for p in response['Parameters']}.should.equal(
set(['/baz/pwd'])
)
@mock_ssm
def test_put_parameter():