include pending days input for schedule key deletion and update tests since boto client returns DeletionDate as datetime

This commit is contained in:
Jon Beilke 2018-10-06 00:13:47 -05:00
parent 6277983e3f
commit 21c8914efe
2 changed files with 4 additions and 4 deletions

View File

@ -269,11 +269,12 @@ class KmsResponse(BaseResponse):
def schedule_key_deletion(self):
key_id = self.parameters.get('KeyId')
pending_window_in_days = self.parameters.get('PendingWindowInDays')
_assert_valid_key_id(self.kms_backend.get_key_id(key_id))
try:
return json.dumps({
'KeyId': key_id,
'DeletionDate': iso_8601_datetime_without_milliseconds(self.kms_backend.schedule_key_deletion(key_id))
'DeletionDate': iso_8601_datetime_without_milliseconds(self.kms_backend.schedule_key_deletion(key_id, pending_window_in_days))
})
except KeyError:
raise JSONResponseError(404, 'Not Found', body={

View File

@ -7,7 +7,6 @@ from boto.exception import JSONResponseError
from boto.kms.exceptions import AlreadyExistsException, NotFoundException
import sure # noqa
from moto import mock_kms, mock_kms_deprecated
from moto.core.utils import iso_8601_datetime_without_milliseconds
from nose.tools import assert_raises
from freezegun import freeze_time
from datetime import datetime, timedelta
@ -660,7 +659,7 @@ def test_schedule_key_deletion():
KeyId=key['KeyMetadata']['KeyId']
)
assert response['KeyId'] == key['KeyMetadata']['KeyId']
assert response['DeletionDate'] == iso_8601_datetime_without_milliseconds(datetime.now() + timedelta(days=30))
assert response['DeletionDate'] == datetime.now() + timedelta(days=30)
result = client.describe_key(KeyId=key['KeyMetadata']['KeyId'])
assert result["KeyMetadata"]["Enabled"] == False
@ -678,7 +677,7 @@ def test_schedule_key_deletion_custom():
PendingWindowInDays=7
)
assert response['KeyId'] == key['KeyMetadata']['KeyId']
assert response['DeletionDate'] == iso_8601_datetime_without_milliseconds(datetime.now() + timedelta(days=7))
assert response['DeletionDate'] == datetime.now() + timedelta(days=7)
result = client.describe_key(KeyId=key['KeyMetadata']['KeyId'])
assert result["KeyMetadata"]["Enabled"] == False