# Test playbook for the firewalld module - port operations
# (c) 2017, Adam Miller <admiller@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- name: firewalld port range test permanent enabled
  firewalld:
    port: 5500-6950/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port range test permanent enabled worked
  assert:
    that:
    - result is changed

- name: firewalld port range test permanent enabled rerun (verify not changed)
  firewalld:
    port: 5500-6950/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port range test permanent enabled rerun worked (verify not changed)
  assert:
    that:
    - result is not changed

- name: firewalld port test permanent enabled
  firewalld:
    port: 6900/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port test permanent enabled worked
  assert:
    that:
    - result is changed

- name: firewalld port test permanent enabled
  firewalld:
    port: 6900/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port test permanent enabled worked
  assert:
    that:
    - result is not changed

- name: firewalld port test disabled
  firewalld:
    port: "{{ item }}"
    permanent: true
    state: disabled
  loop:
    - 6900/tcp
    - 5500-6950/tcp

- name: firewalld port test permanent enabled
  firewalld:
    port: 8081/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port test permanent enabled worked
  assert:
    that:
    - result is changed

- name: firewalld port test permanent enabled rerun (verify not changed)
  firewalld:
    port: 8081/tcp
    permanent: true
    state: enabled
  register: result

- name: assert firewalld port test permanent enabled rerun worked (verify not changed)
  assert:
    that:
    - result is not changed

- name: firewalld port test permanent disabled
  firewalld:
    port: 8081/tcp
    permanent: true
    state: disabled
  register: result

- name: assert firewalld port test permanent disabled worked
  assert:
    that:
    - result is changed

- name: firewalld port test permanent disabled rerun (verify not changed)
  firewalld:
    port: 8081/tcp
    permanent: true
    state: disabled
  register: result

- name: assert firewalld port test permanent disabled rerun worked (verify not changed)
  assert:
    that:
    - result is not changed
