- import_role:
    name: prepare_vmware_tests

# Testcase 0003: Add Local user in vCenter server
- name: add local user
  vmware_local_user_manager:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    validate_certs: no
    local_user_name: testuser_0003
    local_user_password: "SamplePassword!"
    state: present
  register: user_add_0003
  ignore_errors: yes

- name: ensure user is created
  assert:
    that:
        - user_add_0003.changed == false
        - "{{ 'Failed to get local account manager settings' in user_add_0003.msg }}"

# Testcase 0003: Delete Local user in vCenter server
- name: Delete local user
  vmware_local_user_manager:
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    validate_certs: no
    local_user_name: testuser_0003
    state: absent
  register: user_delete_0004
  ignore_errors: yes

- name: ensure user is deleted
  assert:
    that:
        - user_delete_0004.changed == false
        - "{{ 'Failed to get local account manager settings' in user_delete_0004.msg }}"
