---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

- name: Create with invalid device name (check)
  luks_device:
    device: /dev/asdfasdfasdf
    state: present
    keyfile: "{{ remote_tmp_dir }}/keyfile1"
    pbkdf:
      iteration_time: 0.1
  check_mode: true
  ignore_errors: true
  become: true
  register: create_check
- name: Create with invalid device name
  luks_device:
    device: /dev/asdfasdfasdf
    state: present
    keyfile: "{{ remote_tmp_dir }}/keyfile1"
    pbkdf:
      iteration_time: 0.1
  ignore_errors: true
  become: true
  register: create
- assert:
    that:
      - create_check is failed
      - create is failed
      - "'o such file or directory' in create_check.msg"
      - "'o such file or directory' in create.msg"

- name: Create with something which is not a device (check)
  luks_device:
    device: /tmp/
    state: present
    keyfile: "{{ remote_tmp_dir }}/keyfile1"
    pbkdf:
      iteration_time: 0.1
  check_mode: true
  ignore_errors: true
  become: true
  register: create_check
- name: Create with something which is not a device
  luks_device:
    device: /tmp/
    state: present
    keyfile: "{{ remote_tmp_dir }}/keyfile1"
    pbkdf:
      iteration_time: 0.1
  ignore_errors: true
  become: true
  register: create
- assert:
    that:
      - create_check is failed
      - create is failed
      - "'is not a device' in create_check.msg"
      - "'is not a device' in create.msg"
