Added GetParameter support

This commit is contained in:
Terry Cain 2017-09-18 14:13:02 +01:00
parent 2937cf4c45
commit cf7e07b728
3 changed files with 43 additions and 0 deletions

View File

@ -75,6 +75,11 @@ class SimpleSystemManagerBackend(BaseBackend):
result.append(self._parameters[name])
return result
def get_parameter(self, name, with_decryption):
if name in self._parameters:
return self._parameters[name]
return None
def put_parameter(self, name, description, value, type, keyid, overwrite):
if not overwrite and name in self._parameters:
return

View File

@ -42,6 +42,25 @@ class SimpleSystemManagerResponse(BaseResponse):
response['InvalidParameters'].append(name)
return json.dumps(response)
def get_parameter(self):
name = self._get_param('Name')
with_decryption = self._get_param('WithDecryption')
result = self.ssm_backend.get_parameter(name, with_decryption)
if result is None:
return '', dict(status=400)
response = {
'Parameter': {
'Name': name,
'Type': result.type,
'Value': result.value
}
}
return json.dumps(response)
def get_parameters(self):
names = self._get_param('Names')
with_decryption = self._get_param('WithDecryption')

View File

@ -66,6 +66,25 @@ def test_put_parameter():
response['Parameters'][0]['Type'].should.equal('String')
@mock_ssm
def test_get_parameter():
client = boto3.client('ssm', region_name='us-east-1')
client.put_parameter(
Name='test',
Description='A test parameter',
Value='value',
Type='String')
response = client.get_parameter(
Name='test',
WithDecryption=False)
response['Parameter']['Name'].should.equal('test')
response['Parameter']['Value'].should.equal('value')
response['Parameter']['Type'].should.equal('String')
@mock_ssm
def test_describe_parameters():
client = boto3.client('ssm', region_name='us-east-1')