From 3fe8afaa605f79c769e9b1204b3faee11d94d761 Mon Sep 17 00:00:00 2001 From: mattsb42-aws Date: Mon, 26 Aug 2019 23:29:30 -0700 Subject: [PATCH] add tests for generate_data_key and generate_master_key --- tests/test_kms/test_utils.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/test_kms/test_utils.py b/tests/test_kms/test_utils.py index 9d540d50..466c72ea 100644 --- a/tests/test_kms/test_utils.py +++ b/tests/test_kms/test_utils.py @@ -6,11 +6,12 @@ from parameterized import parameterized from moto.kms.exceptions import AccessDeniedException, InvalidCiphertextException, NotFoundException from moto.kms.models import Key from moto.kms.utils import ( + _deserialize_ciphertext_blob, + _serialize_ciphertext_blob, + _serialize_encryption_context, generate_data_key, generate_master_key, - _serialize_ciphertext_blob, - _deserialize_ciphertext_blob, - _serialize_encryption_context, + MASTER_KEY_LEN, encrypt, decrypt, Ciphertext, @@ -45,6 +46,20 @@ CIPHERTEXT_BLOB_VECTORS = ( ) +def test_generate_data_key(): + test = generate_data_key(123) + + test.should.be.a(bytes) + len(test).should.equal(123) + + +def test_generate_master_key(): + test = generate_master_key() + + test.should.be.a(bytes) + len(test).should.equal(MASTER_KEY_LEN) + + @parameterized(ENCRYPTION_CONTEXT_VECTORS) def test_serialize_encryption_context(raw, serialized): test = _serialize_encryption_context(raw)