diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 84edfa4595..80594adebe 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -5450,7 +5450,11 @@ class SchedulePreviewSerializer(BaseSerializer): for a_rule in match_multiple_rrule: if 'interval' not in a_rule.lower(): errors.append("{0}: {1}".format(_('INTERVAL required in rrule'), a_rule)) - elif 'secondly' in a_rule.lower(): + else: + match_interval = re.match(r".*?INTERVAL=([0-9]+)", a_rule) + if match_interval and int(match_interval.group(1)) < 1: + errors.append("{0}: {1}".format(_("INTERVAL must be a positive integer"), a_rule)) + if 'secondly' in a_rule.lower(): errors.append("{0}: {1}".format(_('SECONDLY is not supported'), a_rule)) if re.match(by_day_with_numeric_prefix, a_rule): errors.append("{0}: {1}".format(_("BYDAY with numeric prefix not supported"), a_rule)) diff --git a/awx/main/tests/functional/api/test_schedules.py b/awx/main/tests/functional/api/test_schedules.py index cb49a53d22..516edb341a 100644 --- a/awx/main/tests/functional/api/test_schedules.py +++ b/awx/main/tests/functional/api/test_schedules.py @@ -139,6 +139,7 @@ def test_survey_password_default(post, patch, admin_user, project, inventory, su ("DTSTART:20300308T050000Z", "One or more rule required in rrule"), ("DTSTART:20300308T050000Z RRULE:FREQ=MONTHLY;INTERVAL=1; EXDATE:20220401", "EXDATE not allowed in rrule"), ("DTSTART:20300308T050000Z RRULE:FREQ=MONTHLY;INTERVAL=1; RDATE:20220401", "RDATE not allowed in rrule"), + ("DTSTART:20300308T050000Z RRULE:FREQ=YEARLY;INTERVAL=0;BYDAY=MO", "INTERVAL must be a positive integer"), ("DTSTART:20300308T050000Z RRULE:FREQ=SECONDLY;INTERVAL=5;COUNT=6", "SECONDLY is not supported"), # Individual rule test ("DTSTART:20300308T050000Z RRULE:NONSENSE", "INTERVAL required in rrule"), @@ -202,6 +203,7 @@ def test_multiple_invalid_rrules(post, admin_user, project, inventory): "rrule": [ "Multiple DTSTART is not supported.", "INTERVAL required in rrule: RULE:FREQ=SECONDLY", + "SECONDLY is not supported: RULE:FREQ=SECONDLY", "RRULE may not contain both COUNT and UNTIL: RULE:FREQ=MINUTELY;INTERVAL=10;COUNT=5;UNTIL=20220101", "rrule parsing failed validation: 'NoneType' object has no attribute 'group'", ]