KMS - CreateKey without desc should return empty desc (#4305)
This commit is contained in:
parent
3d7d5eb7ed
commit
c0853aa99d
@ -24,7 +24,7 @@ class Key(CloudFormationModel):
|
||||
self.policy = policy or self.generate_default_policy()
|
||||
self.key_usage = key_usage
|
||||
self.key_state = "Enabled"
|
||||
self.description = description
|
||||
self.description = description or ""
|
||||
self.enabled = True
|
||||
self.region = region
|
||||
self.account_id = ACCOUNT_ID
|
||||
|
@ -30,6 +30,17 @@ def _get_encoded_value(plaintext):
|
||||
return plaintext.encode("utf-8")
|
||||
|
||||
|
||||
@mock_kms
|
||||
def test_create_key_without_description():
|
||||
conn = boto3.client("kms", region_name="us-east-1")
|
||||
metadata = conn.create_key(Policy="my policy")["KeyMetadata"]
|
||||
|
||||
metadata.should.have.key("AWSAccountId").equals(ACCOUNT_ID)
|
||||
metadata.should.have.key("KeyId")
|
||||
metadata.should.have.key("Arn")
|
||||
metadata.should.have.key("Description").equal("")
|
||||
|
||||
|
||||
@mock_kms
|
||||
def test_create_key():
|
||||
conn = boto3.client("kms", region_name="us-east-1")
|
||||
@ -41,9 +52,11 @@ def test_create_key():
|
||||
)
|
||||
|
||||
key["KeyMetadata"]["Arn"].should.equal(
|
||||
"arn:aws:kms:us-east-1:123456789012:key/{}".format(key["KeyMetadata"]["KeyId"])
|
||||
"arn:aws:kms:us-east-1:{}:key/{}".format(
|
||||
ACCOUNT_ID, key["KeyMetadata"]["KeyId"]
|
||||
)
|
||||
)
|
||||
key["KeyMetadata"]["AWSAccountId"].should.equal("123456789012")
|
||||
key["KeyMetadata"]["AWSAccountId"].should.equal(ACCOUNT_ID)
|
||||
key["KeyMetadata"]["CreationDate"].should.be.a(datetime)
|
||||
key["KeyMetadata"]["CustomerMasterKeySpec"].should.equal("SYMMETRIC_DEFAULT")
|
||||
key["KeyMetadata"]["Description"].should.equal("my key")
|
||||
|
Loading…
Reference in New Issue
Block a user