Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve warnings meraki firewalled services #374

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/warnings-.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
trivial:
- Resolved ansible-lint warnings in tests for module-meraki_firewalled_services
130 changes: 76 additions & 54 deletions tests/integration/targets/meraki_firewalled_services/tasks/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,101 +3,111 @@

# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- block:
- name: Block of tests
block:
- name: Create network
meraki_network:
cisco.meraki.meraki_network:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
type: appliance
register: create

- set_fact:
net_id: '{{create.data.id}}'
- name: Set fact net_id
ansible.builtin.set_fact:
net_id: '{{ create.data.id }}'

- name: Set icmp service to blocked with check mode
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: ICMP
access: blocked
register: icmp_blocked_check
check_mode: yes
check_mode: true

- debug:
- name: Debug icmp_blocked_check
ansible.builtin.debug:
var: icmp_blocked_check

- assert:
- name: Assert if icmp_blocked_check has been changed
ansible.builtin.assert:
that:
- icmp_blocked_check.data is defined
- icmp_blocked_check is changed

- name: Set icmp service to blocked
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: ICMP
access: blocked
register: icmp_blocked

- debug:
- name: Debug icmp_blocked
ansible.builtin.debug:
var: icmp_blocked

- assert:
- name: Assert ig icmp_blocked has been changed
ansible.builtin.assert:
that:
- icmp_blocked.data is defined
- icmp_blocked is changed

- name: Set icmp service to blocked with idempotency
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: ICMP
access: blocked
register: icmp_blocked_idempotent

- debug:
- name: Debug icmp_blocked_idempotent
ansible.builtin.debug:
var: icmp_blocked_idempotent

- assert:
- name: Assert icmp_blocked_idempotent
ansible.builtin.assert:
that:
- icmp_blocked_idempotent.data is defined
- icmp_blocked_idempotent is not changed

- name: Set icmp service to restricted with check mode
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: web
access: restricted
allowed_ips:
- 192.0.1.1
- 192.0.1.2
check_mode: yes
check_mode: true
register: web_restricted_check

- debug:
- name: Debug web_restricted_check
ansible.builtin.debug:
var: web_restricted_check

- assert:
- name: Assert web_restricted_check
ansible.builtin.assert:
that:
- web_restricted_check.data is defined
- web_restricted_check is changed

- name: Set icmp service to restricted
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: web
access: restricted
Expand All @@ -106,19 +116,21 @@
- 192.0.1.2
register: web_restricted

- debug:
- name: Debug web_restricted
ansible.builtin.debug:
var: web_restricted

- assert:
- name: Assert web_restricted
ansible.builtin.assert:
that:
- web_restricted.data is defined
- web_restricted is changed

- name: Set icmp service to restricted with idempotency
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: web
access: restricted
Expand All @@ -127,86 +139,96 @@
- 192.0.1.2
register: web_restricted_idempotent

- debug:
- name: Debug web_restricted_idempotent
ansible.builtin.debug:
var: web_restricted_idempotent

- assert:
- name: Assert web_restricted_idempotent
ansible.builtin.assert:
that:
- web_restricted_idempotent.data is defined
- web_restricted_idempotent is not changed

- name: Test error for access restricted and allowed_ips
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: present
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: web
access: unrestricted
allowed_ips:
- 192.0.1.1
- 192.0.1.2
register: access_error
ignore_errors: yes
failed_when: false
changed_when: false

- assert:
- name: Assert access_error
ansible.builtin.assert:
that:
- 'access_error.msg == "allowed_ips is only allowed when access is restricted."'

- name: Query appliance services with net_id
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: query
org_name: '{{test_org_name}}'
net_id: '{{net_id}}'
org_name: '{{ test_org_name }}'
net_id: '{{ net_id }}'
register: query_appliance_id

- debug:
- name: Debug query_appliance_id
ansible.builtin.debug:
var: query_appliance_id

- assert:
- name: Assert query_appliance_id
ansible.builtin.assert:
that:
- query_appliance_id.data is defined


- name: Query appliance services
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: query
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
register: query_appliance

- debug:
- name: Debug query_appliance
ansible.builtin.debug:
var: query_appliance

- assert:
- name: Assert query_appliance
ansible.builtin.assert:
that:
- query_appliance.data is defined

- name: Query services
meraki_firewalled_services:
cisco.meraki.meraki_firewalled_services:
auth_key: '{{ auth_key }}'
state: query
org_name: '{{test_org_name}}'
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance
service: ICMP
register: query_service

- debug:
- name: Debug query_service
ansible.builtin.debug:
var: query_service

- assert:
- name: Assert query_service
ansible.builtin.assert:
that:
- query_service.data is defined

#############################################################################
# Tear down starts here
#############################################################################
always:
- name: Delete all networks
meraki_network:
auth_key: '{{ auth_key }}'
state: absent
org_name: '{{test_org_name}}'
net_name: IntTestNetworkAppliance
- name: Delete all networks
cisco.meraki.meraki_network:
auth_key: '{{ auth_key }}'
state: absent
org_name: '{{ test_org_name }}'
net_name: IntTestNetworkAppliance