Merge pull request #2534 from william-richard/add-ssm-get-parameter-history-support

Add ssm `get_parameter_history` support
This commit is contained in:
Steve Pulec 2019-11-04 22:54:57 -06:00 committed by GitHub
commit 1f9208e19c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 138 additions and 23 deletions

View file

@ -814,6 +814,85 @@ def test_put_parameter_secure_custom_kms():
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_get_parameter_history_missing_parameter():
client = boto3.client("ssm", region_name="us-east-1")
try:
client.get_parameter_history(Name="test_noexist")
raise RuntimeError("Should have failed")
except botocore.exceptions.ClientError as err:
err.operation_name.should.equal("GetParameterHistory")
err.response["Error"]["Message"].should.equal(
"Parameter test_noexist not found."
)
@mock_ssm
def test_add_remove_list_tags_for_resource():
client = boto3.client("ssm", region_name="us-east-1")