add KeyId value to kms.responses.encrypt and kms.responses.decrypt

This commit is contained in:
Earl Robinson 2019-03-29 21:02:25 -04:00
parent 62da0839ae
commit dbdc8925e3
2 changed files with 4 additions and 2 deletions

View File

@ -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')

View File

@ -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