ansible/test/integration/targets/win_scheduled_task/tasks/failures.yml
Brian Scholer eaa6848932 Allow password to be null in Scheduled Task for gMSA (#60990)
* Allow password to be null in Scheduled Task for gMSA

* Remove test for removed password validation, linting fixes
2019-08-28 08:44:45 +10:00

149 lines
5.7 KiB
YAML

# test out the known failure cases to ensure we have decent error messages
---
- name: fail create task without an action
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
register: fail_create_without_action
failed_when: fail_create_without_action.msg != 'cannot create a task with no actions, set at least one action with a path to an executable'
- name: fail both username and group are set
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
username: '{{ansible_user}}'
group: '{{ansible_user}}'
register: fail_username_and_group
failed_when: fail_username_and_group.msg != 'username and group can not be set at the same time'
- name: fail logon type s4u but no password set
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
logon_type: s4u
register: fail_lt_s4u_not_set
failed_when: fail_lt_s4u_not_set.msg != 'password must be set when logon_type=s4u'
- name: fail logon type group but no group set
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
logon_type: group
register: fail_lt_group_not_set
failed_when: fail_lt_group_not_set.msg != 'group must be set when logon_type=group'
- name: fail logon type service but non service user set
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
logon_type: service_account
username: '{{ansible_user}}'
register: fail_lt_service_invalid_user
failed_when: fail_lt_service_invalid_user.msg != 'username must be SYSTEM, LOCAL SERVICE or NETWORK SERVICE when logon_type=service_account'
- name: fail trigger with no type
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- delay: test
register: fail_trigger_no_type
failed_when: fail_trigger_no_type.msg != "a trigger entry must contain a key 'type' with a value of 'event', 'time', 'daily', 'weekly', 'monthly', 'monthlydow', 'idle', 'registration', 'boot', 'logon', 'session_state_change'"
- name: fail trigger with datetime in incorrect format
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: time
start_boundary: fake
register: fail_trigger_invalid_datetime
failed_when: fail_trigger_invalid_datetime.msg != "trigger option 'start_boundary' must be in the format 'YYYY-MM-DDThh:mm:ss' format but was 'fake'"
- name: fail trigger with duration in incorrect format
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: boot
execution_time_limit: fake
register: fail_trigger_invalid_duration
failed_when: fail_trigger_invalid_duration.msg != "trigger option 'execution_time_limit' must be in the XML duration format but was 'fake'"
- name: fail trigger option invalid day of the week
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: weekly
start_boundary: '2000-01-01T00:00:01'
days_of_week: fakeday
register: fail_trigger_invalid_day_of_week
failed_when: fail_trigger_invalid_day_of_week.msg != "invalid day of week 'fakeday', check the spelling matches the full day name"
- name: fail trigger option invalid day of the month
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: monthly
start_boundary: '2000-01-01T00:00:01'
days_of_month: 35
register: fail_trigger_invalid_day_of_month
failed_when: fail_trigger_invalid_day_of_month.msg != "invalid day of month '35', please specify numbers from 1-31"
- name: fail trigger option invalid week of the month
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: monthlydow
start_boundary: '2000-01-01T00:00:01'
weeks_of_month: 5
register: fail_trigger_invalid_week_of_month
failed_when: fail_trigger_invalid_week_of_month.msg != "invalid week of month '5', please specify weeks from 1-4"
- name: fail trigger option invalid month of the year
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: monthlydow
start_boundary: '2000-01-01T00:00:01'
months_of_year: fakemonth
register: fail_trigger_invalid_month_of_year
failed_when: fail_trigger_invalid_month_of_year.msg != "invalid month name 'fakemonth', please specify full month name"
- name: fail trigger repetition with duration in incorrect format
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: boot
repetition:
- duration: fake
register: fail_trigger_repetition_invalid_duration
failed_when: fail_trigger_repetition_invalid_duration.msg != "trigger option 'duration' must be in the XML duration format but was 'fake'"
- name: fail trigger repetition with interval in incorrect format
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: boot
repetition:
- interval: fake
register: fail_trigger_repetition_invalid_interval
failed_when: fail_trigger_repetition_invalid_interval.msg != "trigger option 'interval' must be in the XML duration format but was 'fake'"
- name: fail trigger repetition option interval greater than duration
win_scheduled_task:
name: '{{test_scheduled_task_name}}'
state: present
triggers:
- type: boot
repetition:
- interval: PT5M
duration: PT1M
register: fail_trigger_repetition_interval_greater_than_duration
failed_when: fail_trigger_repetition_interval_greater_than_duration.msg != "trigger repetition option 'interval' value 'PT5M' must be less than or equal to 'duration' value 'PT1M'"