add kms:GenerateRandom and tests

This commit is contained in:
mattsb42-aws 2019-08-27 20:55:58 -07:00
commit f7043e1eaf
2 changed files with 26 additions and 0 deletions

View file

@ -908,6 +908,21 @@ def test_re_encrypt_to_invalid_destination():
)
@parameterized(((12,), (44,), (91,)))
@mock_kms
def test_generate_random(number_of_bytes):
client = boto3.client("kms", region_name="us-west-2")
response = client.generate_random(NumberOfBytes=number_of_bytes)
# Plaintext must NOT be base64-encoded
with assert_raises(Exception):
base64.b64decode(response["Plaintext"], validate=True)
response["Plaintext"].should.be.a(bytes)
len(response["Plaintext"]).should.equal(number_of_bytes)
@mock_kms
def test_enable_key_rotation_key_not_found():
client = boto3.client("kms", region_name="us-east-1")