From dbdc8925e35a0bb244c265be87429f7a81d543f4 Mon Sep 17 00:00:00 2001 From: Earl Robinson Date: Fri, 29 Mar 2019 21:02:25 -0400 Subject: [PATCH] add KeyId value to kms.responses.encrypt and kms.responses.decrypt --- moto/kms/responses.py | 4 ++-- tests/test_kms/test_kms.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/moto/kms/responses.py b/moto/kms/responses.py index 2674f765c..ed6accc78 100644 --- a/moto/kms/responses.py +++ b/moto/kms/responses.py @@ -249,11 +249,11 @@ class KmsResponse(BaseResponse): value = self.parameters.get("Plaintext") if isinstance(value, six.text_type): value = value.encode('utf-8') - return json.dumps({"CiphertextBlob": base64.b64encode(value).decode("utf-8")}) + return json.dumps({"CiphertextBlob": base64.b64encode(value).decode("utf-8"), 'KeyId': 'key_id'}) def decrypt(self): value = self.parameters.get("CiphertextBlob") - return json.dumps({"Plaintext": base64.b64decode(value).decode("utf-8")}) + return json.dumps({"Plaintext": base64.b64decode(value).decode("utf-8"), 'KeyId': 'key_id'}) def disable_key(self): key_id = self.parameters.get('KeyId') diff --git a/tests/test_kms/test_kms.py b/tests/test_kms/test_kms.py index 95e39a0e7..79f95fa1b 100644 --- a/tests/test_kms/test_kms.py +++ b/tests/test_kms/test_kms.py @@ -171,6 +171,7 @@ def test_encrypt(): conn = boto.kms.connect_to_region("us-west-2") response = conn.encrypt('key_id', 'encryptme'.encode('utf-8')) response['CiphertextBlob'].should.equal(b'ZW5jcnlwdG1l') + response['KeyId'].should.equal('key_id') @mock_kms_deprecated @@ -178,6 +179,7 @@ def test_decrypt(): conn = boto.kms.connect_to_region('us-west-2') response = conn.decrypt('ZW5jcnlwdG1l'.encode('utf-8')) response['Plaintext'].should.equal(b'encryptme') + response['KeyId'].should.equal('key_id') @mock_kms_deprecated