mirror of
https://github.com/VinylDNS/vinyldns
synced 2025-08-31 06:15:49 +00:00
validate scheduled time is in the future (#784)
This commit is contained in:
@@ -276,7 +276,7 @@ def test_create_batch_change_with_scheduled_time_and_owner_group_succeeds(shared
|
||||
Test successfully creating a batch change with scheduled time and owner group set
|
||||
"""
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
dt = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
dt = (datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
batch_change_input = {
|
||||
"comments": "this is optional",
|
||||
@@ -298,7 +298,7 @@ def test_create_scheduled_batch_change_with_zone_discovery_error_without_owner_g
|
||||
Test creating a scheduled batch without owner group ID fails if there is a zone discovery error
|
||||
"""
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
dt = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
dt = (datetime.datetime.now() + datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
batch_change_input = {
|
||||
"comments": "this is optional",
|
||||
@@ -313,6 +313,28 @@ def test_create_scheduled_batch_change_with_zone_discovery_error_without_owner_g
|
||||
assert_that(errors, is_("Batch change requires owner group for manual review/scheduled changes."))
|
||||
|
||||
|
||||
@pytest.mark.manual_batch_review
|
||||
def test_create_scheduled_batch_change_with_scheduled_time_in_the_past_fails(shared_zone_test_context):
|
||||
"""
|
||||
Test creating a scheduled batch with a scheduled time in the past
|
||||
"""
|
||||
client = shared_zone_test_context.ok_vinyldns_client
|
||||
yesterday = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
batch_change_input = {
|
||||
"comments": "this is optional",
|
||||
"changes": [
|
||||
get_change_A_AAAA_json("no-owner-group.scheduled.parent.com.", address="4.5.6.7"),
|
||||
],
|
||||
"ownerGroupId": shared_zone_test_context.ok_group['id'],
|
||||
"scheduledTime": yesterday
|
||||
}
|
||||
|
||||
errors = client.create_batch_change(batch_change_input, status=400)
|
||||
|
||||
assert_that(errors, is_("Scheduled time must be in the future."))
|
||||
|
||||
|
||||
def test_create_batch_change_without_scheduled_time_succeeds(shared_zone_test_context):
|
||||
"""
|
||||
Test successfully creating a batch change without scheduled time set
|
||||
|
Reference in New Issue
Block a user