Add get_parameter_history implementation and tests

This commit is contained in:
William Richard 2019-11-04 12:49:09 -05:00
commit aeb7974549
No known key found for this signature in database
GPG key ID: ACD9DA4E735E6D14
3 changed files with 71 additions and 1 deletions

View file

@ -813,6 +813,60 @@ def test_put_parameter_secure_custom_kms():
response["Parameters"][0]["Value"].should.equal("value")
response["Parameters"][0]["Type"].should.equal("SecureString")
@mock_ssm
def test_get_parameter_history():
client = boto3.client("ssm", region_name="us-east-1")
test_parameter_name = "test"
for i in range(3):
client.put_parameter(
Name=test_parameter_name, Description="A test parameter version %d" % i, Value="value-%d" % i, Type="String",
Overwrite=True
)
response = client.get_parameter_history(Name=test_parameter_name)
parameters_response = response['Parameters']
for index, param in enumerate(parameters_response):
param['Name'].should.equal(test_parameter_name)
param['Type'].should.equal('String')
param['Value'].should.equal('value-%d' % index)
param['Version'].should.equal(index + 1)
param['Description'].should.equal("A test parameter version %d" % index)
len(parameters_response).should.equal(3)
@mock_ssm
def test_get_parameter_history_with_secure_string():
client = boto3.client("ssm", region_name="us-east-1")
test_parameter_name = "test"
for i in range(3):
client.put_parameter(
Name=test_parameter_name, Description="A test parameter version %d" % i, Value="value-%d" % i, Type="SecureString",
Overwrite=True
)
for with_decryption in [True, False]:
response = client.get_parameter_history(Name=test_parameter_name, WithDecryption=with_decryption)
parameters_response = response['Parameters']
for index, param in enumerate(parameters_response):
param['Name'].should.equal(test_parameter_name)
param['Type'].should.equal('SecureString')
expected_plaintext_value = 'value-%d' % index
if with_decryption:
param['Value'].should.equal(expected_plaintext_value)
else:
param['Value'].should.equal('kms:alias/aws/ssm:%s' % expected_plaintext_value)
param['Version'].should.equal(index + 1)
param['Description'].should.equal("A test parameter version %d" % index)
len(parameters_response).should.equal(3)
@mock_ssm
def test_add_remove_list_tags_for_resource():