#########################
### check mode remove ###
#########################
- name: check mode disable category
  win_audit_policy_system:
    category: "{{ category_name }}"
    audit_type: none
  check_mode: yes
  register: category

- name: check mode disable subcategory
  win_audit_policy_system:
    subcategory: "{{ subcategory_name }}"
    audit_type: none
  check_mode: yes
  register: subcategory

- name: check mode assert that changed is true
  assert:
    that:
      - category is changed
      - subcategory is changed

- name: check mode assert that audit_type is still "success" (old value) for category
  assert:
    that:
      - item == "success"
  with_items:
    - "{{ category.current_audit_policy.values() | list | unique }}"

- name: check mode assert that audit_type is still "success and failure" (old value) for subcategory
  assert:
    that:
      - item == "success and failure"
  with_items:
    - "{{ subcategory.current_audit_policy.values() | list }}"

######################
### disable policy ###
######################

- name: disable category
  win_audit_policy_system:
    category: "{{ category_name }}"
    audit_type: none
  register: category

- name: disable subcategory
  win_audit_policy_system:
    subcategory: "{{ subcategory_name }}"
    audit_type: none
  register: subcategory

- name: assert that changed is true
  assert:
    that:
      - category is changed
      - subcategory is changed

- name: assert that audit_type is "no auditing"
  assert:
    that:
      - item == "no auditing"
  with_items:
    - "{{ subcategory.current_audit_policy.values() | list }}"
    - "{{ category.current_audit_policy.values() | list | unique }}"

##########################
### idempotent disable ###
##########################

- name: idem disable category
  win_audit_policy_system:
    category: "{{ category_name }}"
    audit_type: none
  register: category

- name: idem disable subcategory
  win_audit_policy_system:
    subcategory: "{{ subcategory_name }}"
    audit_type: none
  register: subcategory

- name: idem assert that changed is false
  assert:
    that:
      - category is not changed
      - subcategory is not changed

- name: assert that audit_type is "no auditing"
  assert:
    that:
      - item == "no auditing"
  with_items:
    - "{{ subcategory.current_audit_policy.values() | list }}"
    - "{{ category.current_audit_policy.values() | list | unique }}"
