Merge pull request #2133 from earlrob/add_keyid_to_kms_encrypt_and_decrypt

add KeyId value to kms.responses.encrypt and kms.responses.decrypt
This commit is contained in:
Mike Grima 2019-04-17 11:07:00 -07:00 committed by GitHub
commit 51ef03b03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -249,11 +249,11 @@ class KmsResponse(BaseResponse):
value = self.parameters.get("Plaintext") value = self.parameters.get("Plaintext")
if isinstance(value, six.text_type): if isinstance(value, six.text_type):
value = value.encode('utf-8') 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): def decrypt(self):
value = self.parameters.get("CiphertextBlob") 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): def disable_key(self):
key_id = self.parameters.get('KeyId') key_id = self.parameters.get('KeyId')

View File

@ -171,6 +171,7 @@ def test_encrypt():
conn = boto.kms.connect_to_region("us-west-2") conn = boto.kms.connect_to_region("us-west-2")
response = conn.encrypt('key_id', 'encryptme'.encode('utf-8')) response = conn.encrypt('key_id', 'encryptme'.encode('utf-8'))
response['CiphertextBlob'].should.equal(b'ZW5jcnlwdG1l') response['CiphertextBlob'].should.equal(b'ZW5jcnlwdG1l')
response['KeyId'].should.equal('key_id')
@mock_kms_deprecated @mock_kms_deprecated
@ -178,6 +179,7 @@ def test_decrypt():
conn = boto.kms.connect_to_region('us-west-2') conn = boto.kms.connect_to_region('us-west-2')
response = conn.decrypt('ZW5jcnlwdG1l'.encode('utf-8')) response = conn.decrypt('ZW5jcnlwdG1l'.encode('utf-8'))
response['Plaintext'].should.equal(b'encryptme') response['Plaintext'].should.equal(b'encryptme')
response['KeyId'].should.equal('key_id')
@mock_kms_deprecated @mock_kms_deprecated