meraki_content_filtering - Enable check mode (#54638)

* Add support for check mode.

* Add diff support
- Need to analyze diff for accuracy
- Updated check mode changed value

* Improve test coverage

* Remove a duplicate integration test
This commit is contained in:
Kevin Breit
2019-06-05 09:31:50 -05:00
committed by Nathaniel Case
parent 6da2d40500
commit 72f2d05b6f
3 changed files with 94 additions and 31 deletions

View File

@@ -8,24 +8,8 @@
fail:
msg: Please define an API key
when: auth_key is not defined
- name: Use an invalid domain
meraki_config_template:
auth_key: '{{ auth_key }}'
host: marrrraki.com
state: query
org_name: DevTestOrg
output_level: debug
delegate_to: localhost
register: invalid_domain
ignore_errors: yes
- name: Connection assertions
assert:
that:
- '"Failed to connect to" in invalid_domain.msg'
- name: Create network with type switch
- name: Create network
meraki_network:
auth_key: '{{ auth_key }}'
state: present
@@ -36,6 +20,38 @@
delegate_to: localhost
register: create_net_appliance
- name: Test net_name and id exclusivity
meraki_content_filtering:
auth_key: '{{auth_key}}'
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
net_id: 12345
state: present
allowed_urls:
- "http://www.ansible.com/*"
register: net_exclusive
ignore_errors: yes
- assert:
that:
- 'net_exclusive.msg == "net_name and net_id are mutually exclusive"'
- name: Set single allowed URL pattern with check mode
meraki_content_filtering:
auth_key: '{{auth_key}}'
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
state: present
allowed_urls:
- "http://www.ansible.com/*"
register: single_allowed_check
check_mode: yes
- assert:
that:
- single_allowed_check.data.allowedUrlPatterns | length == 1
- single_allowed_check is changed
- name: Set single allowed URL pattern
meraki_content_filtering:
auth_key: '{{auth_key}}'
@@ -46,13 +62,28 @@
- "http://www.ansible.com/*"
register: single_allowed
- debug:
var: single_allowed.data.allowedUrlPatterns
- assert:
that:
- single_allowed.data.allowedUrlPatterns | length == 1
- name: Set single allowed URL pattern for idempotency with check mode
meraki_content_filtering:
auth_key: '{{auth_key}}'
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
state: present
allowed_urls:
- "http://www.ansible.com/*"
register: single_allowed_idempotent_check
check_mode: yes
- debug:
var: single_allowed_idempotent_check
- assert:
that:
- single_allowed_idempotent_check is not changed
- name: Set single allowed URL pattern for idempotency
meraki_content_filtering:
auth_key: '{{auth_key}}'
@@ -116,16 +147,36 @@
category_list_size: full list
blocked_categories:
- "Adult and Pornography"
register: blocked_cateogry
register: blocked_category
- debug:
var: blocked_cateogry
var: blocked_category
- assert:
that:
- blocked_cateogry.changed == True
- blocked_cateogry.data.blockedUrlCategories | length == 1
- blocked_cateogry.data.urlCategoryListSize == "fullList"
- blocked_category.changed == True
- blocked_category.data.blockedUrlCategories | length == 1
- blocked_category.data.urlCategoryListSize == "fullList"
- name: Set blocked URL category with top sites
meraki_content_filtering:
auth_key: '{{auth_key}}'
org_name: '{{test_org_name}}'
net_name: '{{test_net_name}}'
state: present
category_list_size: top sites
blocked_categories:
- "Adult and Pornography"
register: blocked_category
- debug:
var: blocked_category
- assert:
that:
- blocked_category.changed == True
- blocked_category.data.blockedUrlCategories | length == 1
- blocked_category.data.urlCategoryListSize == "topSites"
always:
- name: Reset policies
@@ -139,5 +190,3 @@
-
blocked_urls:
-
# blocked_categories:
# -