Fix linting

This commit is contained in:
William Richard 2019-11-04 13:04:10 -05:00
parent aeb7974549
commit 3816eba58f
No known key found for this signature in database
GPG Key ID: ACD9DA4E735E6D14
3 changed files with 51 additions and 34 deletions

View File

@ -521,7 +521,9 @@ class SimpleSystemManagerBackend(BaseBackend):
continue continue
if "/" in param_name[len(path) + 1 :] and not recursive: if "/" in param_name[len(path) + 1 :] and not recursive:
continue continue
if not self._match_filters(self.get_parameter(param_name, with_decryption), filters): if not self._match_filters(
self.get_parameter(param_name, with_decryption), filters
):
continue continue
result.append(self.get_parameter(param_name, with_decryption)) result.append(self.get_parameter(param_name, with_decryption))
@ -605,16 +607,18 @@ class SimpleSystemManagerBackend(BaseBackend):
return return
last_modified_date = time.time() last_modified_date = time.time()
self._parameters[name].append(Parameter( self._parameters[name].append(
name, Parameter(
value, name,
type, value,
description, type,
allowed_pattern, description,
keyid, allowed_pattern,
last_modified_date, keyid,
version, last_modified_date,
)) version,
)
)
return version return version
def add_tags_to_resource(self, resource_type, resource_id, tags): def add_tags_to_resource(self, resource_type, resource_id, tags):

View File

@ -140,15 +140,17 @@ class SimpleSystemManagerResponse(BaseResponse):
return json.dumps(response) return json.dumps(response)
def get_parameter_history(self): def get_parameter_history(self):
name = self._get_param('Name') name = self._get_param("Name")
with_decryption = self._get_param("WithDecryption") with_decryption = self._get_param("WithDecryption")
result = self.ssm_backend.get_parameter_history(name, with_decryption) result = self.ssm_backend.get_parameter_history(name, with_decryption)
response = {"Parameters": []} response = {"Parameters": []}
for parameter_version in result: for parameter_version in result:
param_data = parameter_version.describe_response_object(decrypt=with_decryption) param_data = parameter_version.describe_response_object(
response['Parameters'].append(param_data) decrypt=with_decryption
)
response["Parameters"].append(param_data)
return json.dumps(response) return json.dumps(response)

View File

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