diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:04:41 +0000 |
commit | 975f66f2eebe9dadba04f275774d4ab83f74cf25 (patch) | |
tree | 89bd26a93aaae6a25749145b7e4bca4a1e75b2be /ansible_collections/community/fortios/tests | |
parent | Initial commit. (diff) | |
download | ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.tar.xz ansible-975f66f2eebe9dadba04f275774d4ab83f74cf25.zip |
Adding upstream version 7.7.0+dfsg.upstream/7.7.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/fortios/tests')
42 files changed, 9786 insertions, 0 deletions
diff --git a/ansible_collections/community/fortios/tests/requirements.yml b/ansible_collections/community/fortios/tests/requirements.yml new file mode 100644 index 000000000..36ee27096 --- /dev/null +++ b/ansible_collections/community/fortios/tests/requirements.yml @@ -0,0 +1,2 @@ +unit_tests_dependencies: +- fortinet.fortios diff --git a/ansible_collections/community/fortios/tests/sanity/ignore-2.10.txt b/ansible_collections/community/fortios/tests/sanity/ignore-2.10.txt new file mode 100644 index 000000000..4a289a0fb --- /dev/null +++ b/ansible_collections/community/fortios/tests/sanity/ignore-2.10.txt @@ -0,0 +1,51 @@ +plugins/modules/faz_device.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_config.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_group.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_provision_template.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device_provision_template.py validate-modules:invalid-argument-name +plugins/modules/fmgr_device_provision_template.py validate-modules:nonexistent-parameter-documented +plugins/modules/fmgr_device_provision_template.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_address.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_ippool.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool6.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_ippool6.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_service.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_vip.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_vip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_ipv4.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwpol_ipv4.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_package.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_fwpol_package.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_ha.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_provisioning.py validate-modules:doc-missing-type +plugins/modules/fmgr_provisioning.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_provisioning.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_query.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_query.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_script.py validate-modules:doc-default-does-not-match-spec +plugins/modules/fmgr_script.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_script.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_appctrl.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_appctrl.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_av.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_av.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_dns.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ips.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_ips.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_profile_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_proxy.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_proxy.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_spam.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_spam.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ssl_ssh.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_ssl_ssh.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_voip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_waf.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_waf.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_wanopt.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_web.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_web.py validate-modules:parameter-type-not-in-doc diff --git a/ansible_collections/community/fortios/tests/sanity/ignore-2.11.txt b/ansible_collections/community/fortios/tests/sanity/ignore-2.11.txt new file mode 100644 index 000000000..4a289a0fb --- /dev/null +++ b/ansible_collections/community/fortios/tests/sanity/ignore-2.11.txt @@ -0,0 +1,51 @@ +plugins/modules/faz_device.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_config.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_group.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_provision_template.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_device_provision_template.py validate-modules:invalid-argument-name +plugins/modules/fmgr_device_provision_template.py validate-modules:nonexistent-parameter-documented +plugins/modules/fmgr_device_provision_template.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_address.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_ippool.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool6.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_ippool6.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_service.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_vip.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwobj_vip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_ipv4.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_fwpol_ipv4.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_package.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_fwpol_package.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_ha.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_provisioning.py validate-modules:doc-missing-type +plugins/modules/fmgr_provisioning.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_provisioning.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_query.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_query.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_script.py validate-modules:doc-default-does-not-match-spec +plugins/modules/fmgr_script.py validate-modules:doc-required-mismatch +plugins/modules/fmgr_script.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_appctrl.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_appctrl.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_av.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_av.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_dns.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ips.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_ips.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_profile_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_proxy.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_proxy.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_spam.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_spam.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ssl_ssh.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_ssl_ssh.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_voip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_waf.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_waf.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_wanopt.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_web.py validate-modules:parameter-list-no-elements +plugins/modules/fmgr_secprof_web.py validate-modules:parameter-type-not-in-doc diff --git a/ansible_collections/community/fortios/tests/sanity/ignore-2.9.txt b/ansible_collections/community/fortios/tests/sanity/ignore-2.9.txt new file mode 100644 index 000000000..fc1eac658 --- /dev/null +++ b/ansible_collections/community/fortios/tests/sanity/ignore-2.9.txt @@ -0,0 +1,29 @@ +plugins/modules/fmgr_device.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_config.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_device_provision_template.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_address.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_ippool6.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_service.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwobj_vip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_ipv4.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_fwpol_package.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_ha.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_provisioning.py validate-modules:doc-missing-type +plugins/modules/fmgr_provisioning.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_query.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_script.py validate-modules:doc-default-does-not-match-spec +plugins/modules/fmgr_script.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_appctrl.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_av.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_dns.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ips.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_profile_group.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_proxy.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_spam.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_ssl_ssh.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_voip.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_waf.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_wanopt.py validate-modules:parameter-type-not-in-doc +plugins/modules/fmgr_secprof_web.py validate-modules:parameter-type-not-in-doc diff --git a/ansible_collections/community/fortios/tests/unit/compat/__init__.py b/ansible_collections/community/fortios/tests/unit/compat/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/compat/__init__.py diff --git a/ansible_collections/community/fortios/tests/unit/compat/mock.py b/ansible_collections/community/fortios/tests/unit/compat/mock.py new file mode 100644 index 000000000..0972cd2e8 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/compat/mock.py @@ -0,0 +1,122 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +''' +Compat module for Python3.x's unittest.mock module +''' +import sys + +# Python 2.7 + +# Note: Could use the pypi mock library on python3.x as well as python2.x. It +# is the same as the python3 stdlib mock library + +try: + # Allow wildcard import because we really do want to import all of mock's + # symbols into this compat shim + # pylint: disable=wildcard-import,unused-wildcard-import + from unittest.mock import * +except ImportError: + # Python 2 + # pylint: disable=wildcard-import,unused-wildcard-import + try: + from mock import * + except ImportError: + print('You need the mock library installed on python2.x to run tests') + + +# Prior to 3.4.4, mock_open cannot handle binary read_data +if sys.version_info >= (3,) and sys.version_info < (3, 4, 4): + file_spec = None + + def _iterate_read_data(read_data): + # Helper for mock_open: + # Retrieve lines from read_data via a generator so that separate calls to + # readline, read, and readlines are properly interleaved + sep = b'\n' if isinstance(read_data, bytes) else '\n' + data_as_list = [l + sep for l in read_data.split(sep)] + + if data_as_list[-1] == sep: + # If the last line ended in a newline, the list comprehension will have an + # extra entry that's just a newline. Remove this. + data_as_list = data_as_list[:-1] + else: + # If there wasn't an extra newline by itself, then the file being + # emulated doesn't have a newline to end the last line remove the + # newline that our naive format() added + data_as_list[-1] = data_as_list[-1][:-1] + + for line in data_as_list: + yield line + + def mock_open(mock=None, read_data=''): + """ + A helper function to create a mock to replace the use of `open`. It works + for `open` called directly or used as a context manager. + + The `mock` argument is the mock object to configure. If `None` (the + default) then a `MagicMock` will be created for you, with the API limited + to methods or attributes available on standard file handles. + + `read_data` is a string for the `read` methoddline`, and `readlines` of the + file handle to return. This is an empty string by default. + """ + def _readlines_side_effect(*args, **kwargs): + if handle.readlines.return_value is not None: + return handle.readlines.return_value + return list(_data) + + def _read_side_effect(*args, **kwargs): + if handle.read.return_value is not None: + return handle.read.return_value + return type(read_data)().join(_data) + + def _readline_side_effect(): + if handle.readline.return_value is not None: + while True: + yield handle.readline.return_value + for line in _data: + yield line + + global file_spec + if file_spec is None: + import _io + file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO)))) + + if mock is None: + mock = MagicMock(name='open', spec=open) + + handle = MagicMock(spec=file_spec) + handle.__enter__.return_value = handle + + _data = _iterate_read_data(read_data) + + handle.write.return_value = None + handle.read.return_value = None + handle.readline.return_value = None + handle.readlines.return_value = None + + handle.read.side_effect = _read_side_effect + handle.readline.side_effect = _readline_side_effect() + handle.readlines.side_effect = _readlines_side_effect + + mock.return_value = handle + return mock diff --git a/ansible_collections/community/fortios/tests/unit/compat/unittest.py b/ansible_collections/community/fortios/tests/unit/compat/unittest.py new file mode 100644 index 000000000..98f08ad6a --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/compat/unittest.py @@ -0,0 +1,38 @@ +# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com> +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +''' +Compat module for Python2.7's unittest module +''' + +import sys + +# Allow wildcard import because we really do want to import all of +# unittests's symbols into this compat shim +# pylint: disable=wildcard-import,unused-wildcard-import +if sys.version_info < (2, 7): + try: + # Need unittest2 on python2.6 + from unittest2 import * + except ImportError: + print('You need unittest2 installed on python2.6.x to run tests') +else: + from unittest import * diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device.json b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device.json new file mode 100644 index 000000000..90dba75f0 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device.json @@ -0,0 +1,934 @@ +{ + "add_device": [ + { + "url": "/dvm/cmd/add/device/", + "raw_response": { + "device": { + "adm_pass": "fortinet", + "os_ver": 6, + "ip": "10.7.220.151", + "mgmt.__data[6]": 1, + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "platform_id": 112, + "branch_pt": 231, + "hostname": "ansible-fgt01", + "source": 1, + "mgmt_id": 1014939351, + "version": 600, + "build": 231, + "mgmt_mode": 3, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "mgmt.__data[4]": 1052262400, + "oid": 403, + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698141, + "vm_mem_limit": 6144, + "mgmt.__data[0]": 3870643, + "name": "FGT1", + "tab_status": "<unknown>", + "patch": 4, + "vm_cpu_limit": 4, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097169, + "sn": "FGVM04TM18000391", + "mr": 0, + "os_type": 0, + "vm_cpu": 1 + } + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "name": "FGT1", + "ip": "10.7.220.151", + "flags": 24, + "sn": null, + "mgmt_mode": "fmgfaz", + "adm_usr": "admin" + }, + "flags": [ + "create_task", + "nonblocking" + ], + "odd_request_form": "True", + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.151", + "device_unique_name": "FGT1", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "exec" + }, + { + "url": "/dvm/cmd/add/device/", + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.152", + "device_unique_name": "FGT2", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "name": "FGT2", + "ip": "10.7.220.152", + "flags": 24, + "sn": null, + "mgmt_mode": "fmgfaz", + "adm_usr": "admin" + }, + "flags": [ + "create_task", + "nonblocking" + ], + "odd_request_form": "True", + "adom": "ansible" + }, + "raw_response": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.152", + "mgmt.__data[6]": 1, + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "vm_cpu_limit": 4, + "vm_cpu": 1, + "branch_pt": 231, + "hostname": "ansible-fgt02", + "source": 1, + "mgmt_id": 1879100317, + "version": 600, + "build": 231, + "mgmt_mode": 3, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "oid": 415, + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698177, + "patch": 4, + "vm_mem_limit": 6144, + "mgmt.__data[0]": 3870643, + "name": "FGT2", + "tab_status": "<unknown>", + "mgmt.__data[4]": 1052262400, + "platform_id": 112, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097169, + "sn": "FGVM04TM18000392", + "mr": 0, + "os_type": 0, + "os_ver": 6 + } + }, + "post_method": "exec" + }, + { + "url": "/dvm/cmd/add/device/", + "raw_response": { + "device": { + "adm_pass": "fortinet", + "os_ver": 6, + "ip": "10.7.220.153", + "mgmt.__data[6]": 1, + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "platform_id": 112, + "branch_pt": 231, + "hostname": "ansible-fgt03", + "source": 1, + "mgmt_id": 104863251, + "version": 600, + "build": 231, + "mgmt_mode": 3, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "mgmt.__data[4]": 1052262400, + "oid": 427, + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698204, + "vm_mem_limit": 6144, + "mgmt.__data[0]": 3870643, + "name": "FGT3", + "tab_status": "<unknown>", + "patch": 4, + "vm_cpu_limit": 4, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097169, + "sn": "FGVM04TM18000393", + "mr": 0, + "os_type": 0, + "vm_cpu": 1 + } + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "name": "FGT3", + "ip": "10.7.220.153", + "flags": 24, + "sn": null, + "mgmt_mode": "fmgfaz", + "adm_usr": "admin" + }, + "flags": [ + "create_task", + "nonblocking" + ], + "odd_request_form": "True", + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.153", + "device_unique_name": "FGT3", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "exec" + } + ], + "discover_device": [ + { + "url": "/dvm/cmd/discover/device/", + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.151", + "device_unique_name": "FGT1", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.151", + "adm_usr": "admin" + }, + "odd_request_form": "True" + }, + "raw_response": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.151", + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "vm_cpu_limit": 4, + "vm_cpu": 1, + "branch_pt": 231, + "hostname": "ansible-fgt01", + "source": 1, + "version": 600, + "build": 231, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698136, + "vm_mem_limit": 6144, + "name": "ansible-fgt01", + "tab_status": "<unknown>", + "patch": 4, + "platform_id": 112, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097153, + "sn": "FGVM04TM18000391", + "mr": 0, + "os_type": 0, + "os_ver": 6 + } + }, + "post_method": "exec" + }, + { + "url": "/dvm/cmd/discover/device/", + "raw_response": { + "device": { + "adm_pass": "fortinet", + "os_ver": 6, + "ip": "10.7.220.152", + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "platform_id": 112, + "branch_pt": 231, + "hostname": "ansible-fgt02", + "source": 1, + "version": 600, + "build": 231, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698173, + "vm_mem_limit": 6144, + "name": "ansible-fgt02", + "tab_status": "<unknown>", + "patch": 4, + "vm_cpu_limit": 4, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097153, + "sn": "FGVM04TM18000392", + "mr": 0, + "os_type": 0, + "vm_cpu": 1 + } + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.152", + "adm_usr": "admin" + }, + "odd_request_form": "True" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.152", + "device_unique_name": "FGT2", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "exec" + }, + { + "url": "/dvm/cmd/discover/device/", + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.153", + "device_unique_name": "FGT3", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.153", + "adm_usr": "admin" + }, + "odd_request_form": "True" + }, + "raw_response": { + "device": { + "adm_pass": "fortinet", + "ip": "10.7.220.153", + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": 1, + "vm_cpu_limit": 4, + "vm_cpu": 1, + "branch_pt": 231, + "hostname": "ansible-fgt03", + "source": 1, + "version": 600, + "build": 231, + "adm_usr": "admin", + "av_ver": "1.00000(2018-04-09 18:07)", + "conn_status": 1, + "beta": -1, + "dev_status": 1, + "platform_str": "FortiGate-VM64", + "last_checked": 1550698200, + "vm_mem_limit": 6144, + "name": "ansible-fgt03", + "tab_status": "<unknown>", + "patch": 4, + "platform_id": 112, + "vm_status": 3, + "ips_ver": "6.00741(2015-12-01 02:30)", + "flags": 2097153, + "sn": "FGVM04TM18000393", + "mr": 0, + "os_type": 0, + "os_ver": 6 + } + }, + "post_method": "exec" + } + ], + "get_device": [ + { + "url": "/dvmdb/adom/ansible/device/FGT1", + "raw_response": { + "adm_pass": [ + "ENC", + "tUEPOPpQM6XsNwOPcWyrWoPoKo2DMjtFqOYEzLfF+99FpTkDmKa+GTmwBMLV1ns0OYrNgWnk6RPbRjSZSvu2LPYvCcWfQONLEZ1HlczZ00kEtDRCvRxG6l7FGtcj1Pl7QO9khy2lKWx4/lbPmLNqCzwCmlkAO5fGXR3nCbWPXH5BrRwO" + ], + "faz.perm": 0, + "foslic_ram": 0, + "foslic_type": "temporary", + "last_checked": 1550635232, + "psk": "", + "opts": 0, + "ip": "10.7.220.151", + "foslic_utm": null, + "logdisk_size": 30235, + "mgmt.__data[6]": 1, + "foslic_last_sync": 0, + "app_ver": "", + "ips_ext": 0, + "vm_mem": 1003, + "mgmt.__data[4]": 1052262400, + "maxvdom": 10, + "conn_mode": "passive", + "location_from": "GUI(10.0.0.151)", + "mgmt.__data[1]": 0, + "mgmt.__data[2]": 0, + "faz.full_act": 0, + "os_ver": "6.0", + "node_flags": 0, + "hostname": "ansible-fgt01", + "mgmt.__data[5]": 0, + "mgmt_id": 2076985412, + "hw_rev_minor": 0, + "mgmt_if": "port1", + "source": "faz", + "ha_mode": "standalone", + "version": 600, + "build": 231, + "latitude": "47.473991", + "foslic_cpu": 0, + "last_resync": 1550634702, + "desc": "", + "adm_usr": "admin", + "vm_lic_expire": 0, + "ha_slave": null, + "av_ver": "1.00000(2018-04-09 18:07)", + "fsw_cnt": 0, + "tunnel_cookie": "", + "foslic_inst_time": 0, + "lic_flags": 0, + "checksum": "89 1f b7 b7 2a a6 af 54 c5 a5 aa e3 32 92 c7 55", + "oid": 366, + "conn_status": "up", + "fex_cnt": 0, + "mgmt.__data[3]": 0, + "beta": -1, + "ha_group_name": "", + "dev_status": "installed", + "platform_str": "FortiGate-VM64", + "mgmt.__data[7]": 0, + "faz.used": 0, + "fap_cnt": 0, + "foslic_dr_site": "disable", + "mgmt_mode": "fmgfaz", + "vdom": [ + { + "status": null, + "oid": 3, + "name": "root", + "node_flags": 0, + "devid": "FGT1", + "tab_status": null, + "comments": "", + "flags": null, + "opmode": "nat", + "ext_flags": 1, + "rtm_prof_id": 0 + } + ], + "hdisk_size": 30720, + "vm_mem_limit": 6144, + "mgmt.__data[0]": 3870643, + "ha_group_id": 0, + "name": "FGT1", + "faz.quota": 0, + "mgt_vdom": "root", + "tab_status": "", + "tunnel_ip": "169.254.0.5", + "longitude": "-122.260963", + "patch": 4, + "vm_cpu_limit": 4, + "vm_status": 3, + "lic_region": "", + "hw_rev_major": 0, + "flags": [ + "has_hdd", + "reload" + ], + "sn": "FGVM04TM18000391", + "mr": 0, + "conf_status": "insync", + "os_type": "fos", + "ips_ver": "6.00741(2015-12-01 02:30)", + "db_status": "nomod", + "branch_pt": 231, + "vm_cpu": 1 + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT1" + ], + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.151", + "device_unique_name": "FGT1", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "get" + }, + { + "url": "/dvmdb/adom/ansible/device/FGT2", + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.152", + "device_unique_name": "FGT2", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT2" + ], + "adom": "ansible" + }, + "raw_response": { + "adm_pass": [ + "ENC", + "F27zJSIl5O8O5rlXIi7BzHIUO5d3ZAuNxoniR42zOxGHyqZCx1OyA81b7v6dNwE30nBhjqfD+IDRmSPEW6qxKIQ2UV5eh8zgDNj8i5lj5gTvbLN5A4BR4CMLQo7nYTTomHUJQrGPfYskuxm74JGik+di9TrqOhvpZL8d1zj3XHx5pq+d" + ], + "faz.perm": 0, + "hostname": "ansible-fgt02", + "foslic_type": "temporary", + "mgmt.__data[7]": 0, + "av_ver": "1.00000(2018-04-09 18:07)", + "ip": "10.7.220.152", + "foslic_utm": null, + "logdisk_size": 30235, + "mgmt.__data[6]": 1, + "fsw_cnt": 0, + "app_ver": "", + "ips_ext": 0, + "vm_mem": 1003, + "maxvdom": 10, + "conn_mode": "passive", + "mgt_vdom": "root", + "mgmt.__data[1]": 0, + "hw_rev_major": 0, + "name": "FGT2", + "node_flags": 0, + "foslic_ram": 0, + "mgmt.__data[5]": 0, + "ha_mode": "standalone", + "hw_rev_minor": 0, + "mgmt_if": "port1", + "source": "faz", + "mgmt_id": 1555154046, + "version": 600, + "build": 231, + "latitude": "47.473991", + "foslic_cpu": 0, + "last_resync": 1550634728, + "hdisk_size": 30720, + "adm_usr": "admin", + "vm_lic_expire": 0, + "sn": "FGVM04TM18000392", + "ha_slave": null, + "psk": "", + "foslic_last_sync": 0, + "tunnel_cookie": "", + "vm_mem_limit": 6144, + "mr": 0, + "lic_flags": 0, + "oid": 378, + "conn_status": "up", + "fex_cnt": 0, + "vm_cpu": 1, + "beta": -1, + "ha_group_name": "", + "dev_status": "retrieved", + "platform_str": "FortiGate-VM64", + "last_checked": 1550634728, + "branch_pt": 231, + "faz.used": 0, + "patch": 4, + "fap_cnt": 0, + "foslic_dr_site": "disable", + "mgmt_mode": "fmgfaz", + "vdom": [ + { + "status": null, + "oid": 3, + "name": "root", + "node_flags": 4, + "devid": "FGT2", + "tab_status": null, + "comments": "", + "flags": null, + "opmode": "nat", + "ext_flags": 1, + "rtm_prof_id": 0 + } + ], + "desc": "", + "foslic_inst_time": 0, + "mgmt.__data[0]": 3870643, + "ha_group_id": 0, + "location_from": "GUI(10.0.0.151)", + "faz.quota": 0, + "faz.full_act": 0, + "tab_status": "", + "tunnel_ip": "169.254.0.3", + "longitude": "-122.260963", + "mgmt.__data[4]": 1052262400, + "vm_cpu_limit": 4, + "vm_status": 3, + "lic_region": "", + "mgmt.__data[2]": 0, + "flags": [ + "has_hdd", + "reload" + ], + "opts": 0, + "checksum": "56 e9 a7 14 e2 61 05 f9 ec 2b 00 1e 36 bc af c8", + "conf_status": "insync", + "os_type": "fos", + "ips_ver": "6.00741(2015-12-01 02:30)", + "db_status": "mod", + "mgmt.__data[3]": 0, + "os_ver": "6.0" + }, + "post_method": "get" + }, + { + "url": "/dvmdb/adom/ansible/device/FGT3", + "raw_response": { + "adm_pass": [ + "ENC", + "F27zJSIl5O8O5rlXIi7BzHIUO5d3ZAuNxoniR42zOxGHyqZCx1OyA81b7v6dNwE30nBhjqfD+IDRmSPEW6qxKIQ2UV5eh8zgDNj8i5lj5gTvbLN5A4BR4CMLQo7nYTTomHUJQrGPfYskuxm74JGik+di9TrqOhvpZL8d1zj3XHx5pq+d" + ], + "faz.perm": 0, + "foslic_ram": 0, + "foslic_type": "temporary", + "last_checked": 1550634754, + "psk": "", + "opts": 0, + "ip": "10.7.220.153", + "foslic_utm": null, + "logdisk_size": 30235, + "mgmt.__data[6]": 1, + "foslic_last_sync": 0, + "app_ver": "", + "ips_ext": 0, + "vm_mem": 1003, + "mgmt.__data[4]": 1052262400, + "desc": "", + "maxvdom": 10, + "conn_mode": "passive", + "location_from": "GUI(10.0.0.151)", + "mgmt.__data[1]": 0, + "os_ver": "6.0", + "faz.full_act": 0, + "node_flags": 0, + "hostname": "ansible-fgt03", + "mgmt.__data[5]": 0, + "mgmt_id": 1175062219, + "hw_rev_minor": 0, + "mgmt_if": "port1", + "source": "faz", + "ha_mode": "standalone", + "version": 600, + "build": 231, + "latitude": "47.473991", + "foslic_cpu": 0, + "last_resync": 1550634754, + "hdisk_size": 30720, + "adm_usr": "admin", + "vm_lic_expire": 0, + "conf_status": "insync", + "ha_slave": null, + "av_ver": "1.00000(2018-04-09 18:07)", + "fsw_cnt": 0, + "tunnel_cookie": "", + "foslic_inst_time": 0, + "lic_flags": 0, + "oid": 390, + "conn_status": "up", + "fex_cnt": 0, + "mgmt.__data[3]": 0, + "beta": -1, + "ha_group_name": "", + "dev_status": "retrieved", + "platform_str": "FortiGate-VM64", + "mgmt.__data[7]": 0, + "faz.used": 0, + "fap_cnt": 0, + "foslic_dr_site": "disable", + "mgmt_mode": "fmgfaz", + "vdom": [ + { + "status": null, + "oid": 3, + "name": "root", + "node_flags": 4, + "devid": "FGT3", + "tab_status": null, + "comments": "", + "flags": null, + "opmode": "nat", + "ext_flags": 1, + "rtm_prof_id": 0 + } + ], + "name": "FGT3", + "vm_mem_limit": 6144, + "mgmt.__data[0]": 3870643, + "ha_group_id": 0, + "mgmt.__data[2]": 0, + "faz.quota": 0, + "checksum": "30 fc af f5 58 e4 1e 2d 46 c0 07 4b b6 4b c2 1b", + "tab_status": "", + "tunnel_ip": "169.254.0.4", + "longitude": "-122.260963", + "patch": 4, + "vm_cpu_limit": 4, + "vm_status": 3, + "lic_region": "", + "mgt_vdom": "root", + "flags": [ + "has_hdd", + "reload" + ], + "sn": "FGVM04TM18000393", + "mr": 0, + "hw_rev_major": 0, + "os_type": "fos", + "ips_ver": "6.00741(2015-12-01 02:30)", + "db_status": "mod", + "branch_pt": 231, + "vm_cpu": 1 + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT3" + ], + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.153", + "device_unique_name": "FGT3", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "get" + }, + { + "raw_response": { + "status": { + "message": "Object does not exist", + "code": -3 + }, + "url": "/dvmdb/adom/ansible/device/FGT1" + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT1" + ], + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.151", + "device_unique_name": "FGT1", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "get" + }, + { + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.152", + "device_unique_name": "FGT2", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT2" + ], + "adom": "ansible" + }, + "raw_response": { + "status": { + "message": "Object does not exist", + "code": -3 + }, + "url": "/dvmdb/adom/ansible/device/FGT2" + }, + "post_method": "get" + }, + { + "raw_response": { + "status": { + "message": "Object does not exist", + "code": -3 + }, + "url": "/dvmdb/adom/ansible/device/FGT3" + }, + "datagram_sent": { + "filter": [ + "name", + "==", + "FGT3" + ], + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.153", + "device_unique_name": "FGT3", + "mode": "add", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "get" + } + ], + "delete_device": [ + { + "paramgram_used": { + "device_username": "admin", + "adom": "root", + "device_ip": "10.7.220.151", + "device_unique_name": "FGT1", + "mode": "delete", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "device": "FGT1", + "flags": [ + "create_task", + "nonblocking" + ], + "adom": "root" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/dvm/cmd/del/device/" + }, + "post_method": "exec" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/dvm/cmd/del/device/" + }, + "datagram_sent": { + "device": "FGT2", + "flags": [ + "create_task", + "nonblocking" + ], + "adom": "ansible" + }, + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.152", + "device_unique_name": "FGT2", + "mode": "delete", + "device_serial": null, + "device_password": "fortinet" + }, + "post_method": "exec" + }, + { + "paramgram_used": { + "device_username": "admin", + "adom": "ansible", + "device_ip": "10.7.220.153", + "device_unique_name": "FGT3", + "mode": "delete", + "device_serial": null, + "device_password": "fortinet" + }, + "datagram_sent": { + "device": "FGT3", + "flags": [ + "create_task", + "nonblocking" + ], + "adom": "ansible" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/dvm/cmd/del/device/" + }, + "post_method": "exec" + } + ] +} diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device_provision_template.json b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device_provision_template.json new file mode 100644 index 000000000..fb65ca5da --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_device_provision_template.json @@ -0,0 +1,2063 @@ +{ + "set_devprof_admin": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": 4433, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": "enable", + "admin_timeout": 60, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_fortianalyzer_target": "10.7.220.38", + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": 8080, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": "blue", + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "ntp_v3": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": "this-fmg", + "dns_primary_ipv4": null, + "admin_language": "english", + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "smtp_replyto": null, + "admin_https_redirect": "enable" + }, + "datagram_sent": { + "admintimeout": 60, + "switch-controller": "enable", + "language": "english", + "admin-port": 8080, + "gui-theme": "blue", + "admin-https-redirect": "enable", + "admin-sport": 4433 + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/global" + }, + "post_method": "set" + } + ], + "set_devprof_snmp_v3": [ + { + "paramgram_used": { + "snmpv3_security_level": "auth-priv", + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": "enable", + "snmpv3_trap_status": "enable", + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": "ansibleSNMPv3", + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": "sha", + "smtp_port": null, + "snmpv3_priv_pwd": "fortinet", + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": 161, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": "10.7.220.59,10.7.220.60", + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": "enable", + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": "0.0.0.0", + "snmpv3_trap_rport": 162, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": "aes256", + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": "fortinet", + "smtp_source_ipv4": null, + "snmpv3_status": "enable", + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "ntp_v3": null + }, + "datagram_sent": { + "notify-hosts": [ + "10.7.220.59", + "10.7.220.60" + ], + "name": "ansibleSNMPv3", + "query-port": 161, + "auth-pwd": "fortinet", + "source-ip": "0.0.0.0", + "priv-pwd": "fortinet", + "trap-lport": 162, + "ha-direct": 0, + "trap-rport": 162, + "events": 1647387997183 + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/snmp/user" + }, + "post_method": "set" + } + ], + "set_devprof_scope": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": "FGT1,FGT2", + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "ntp_v3": null + }, + "datagram_sent": { + "type": "devprof", + "name": "ansibleTest", + "scope member": [ + { + "name": "FGT1" + }, + { + "name": "FGT2" + } + ], + "description": "CreatedByAnsible" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/devprof/adom/ansible" + }, + "post_method": "set" + } + ], + "set_devprof_snmp": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": "enable", + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "ntp_v3": null + }, + "datagram_sent": { + "status": "enable" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/snmp/sysinfo" + }, + "post_method": "set" + }, + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": "enable", + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": "ansibleV2c", + "syslog_facility": "syslog", + "snmp_v2c_status": "enable", + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": 1, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0", + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": 162, + "snmp_v2c_trap_status": "enable", + "snmp_status": "enable", + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": "10.7.220.41", + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "ntp_auth": null, + "snmp_v2c_trap_port": 161, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255", + "ntp_v3": null + }, + "datagram_sent": { + "status": "enable" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/snmp/sysinfo" + }, + "post_method": "set" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/snmp/sysinfo" + }, + "datagram_sent": { + "status": "enable" + }, + "paramgram_used": { + "snmpv3_security_level": "auth-priv", + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": "enable", + "snmpv3_trap_status": "enable", + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": "ansibleSNMPv3", + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": "sha", + "smtp_port": null, + "snmpv3_priv_pwd": "fortinet", + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": null, + "snmpv3_auth_pwd": "fortinet", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": 161, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": "10.7.220.59,10.7.220.60", + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": "enable", + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": "0.0.0.0", + "snmpv3_trap_rport": 162, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": "aes256", + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": "enable", + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_https_redirect": null + }, + "post_method": "set" + } + ], + "set_devprof": [ + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/devprof/adom/ansible/ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "smtp_port": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "ntp_auth": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "delete", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": "ansibleTest", + "ntp_v3": null, + "admin_https_redirect": null + }, + "post_method": "delete" + } + ], + "set_devprof_dns": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": "ansible.local", + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": "4.4.4.4", + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "ntp_v3": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": "8.8.8.8", + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "smtp_replyto": null, + "admin_https_redirect": null + }, + "datagram_sent": { + "domain": "ansible.local", + "primary": "8.8.8.8", + "secondary": "4.4.4.4" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/dns" + }, + "post_method": "set" + } + ], + "set_devprof_syslog": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "kernel", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": 514, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": "10.7.220.59", + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": "enable", + "snmp_v2c_trap_hosts_ipv4": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": "critical", + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "ntp_v3": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "smtp_replyto": null, + "admin_https_redirect": null + }, + "datagram_sent": { + "status": "enable", + "mode": "udp", + "server": "10.7.220.59", + "port": 514, + "facility": "kernel" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/log/syslogd/setting" + }, + "post_method": "set" + } + ], + "set_devprof_snmp_v2c": [ + { + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/snmp/community", + "raw_response": { + "id": 1 + }, + "datagram_sent": { + "status": "enable", + "trap-v2c-lport": 162, + "trap-v2c-status": "enable", + "name": "ansibleV2c", + "query-v1-port": 161, + "meta fields": {}, + "query-v1-status": 0, + "trap-v2c-rport": 161, + "trap-v1-rport": 162, + "query-v2c-port": 162, + "hosts": [ + { + "ip": [ + "10.7.220.59", + "255.255.255.255" + ], + "source-ip": "0.0.0.0", + "meta fields": {}, + "ha-direct": "enable", + "id": 1, + "host-type": "query" + }, + { + "ip": [ + "10.7.220.0", + "255.255.255.0" + ], + "source-ip": "0.0.0.0", + "meta fields": {}, + "ha-direct": "enable", + "id": 2, + "host-type": "query" + }, + { + "ip": [ + "10.7.220.59", + "255.255.255.255" + ], + "source-ip": "10.7.220.41", + "meta fields": {}, + "ha-direct": "enable", + "id": 3, + "host-type": "trap" + }, + { + "ip": [ + "10.7.220.60", + "255.255.255.255" + ], + "source-ip": "10.7.220.41", + "meta fields": {}, + "ha-direct": "enable", + "id": 4, + "host-type": "trap" + } + ], + "trap-v1-status": 0, + "events": 411578417151, + "query-v2c-status": "enable", + "id": 1, + "trap-v1-lport": 162 + }, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": "enable", + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": "ansibleV2c", + "syslog_facility": "syslog", + "snmp_v2c_status": "enable", + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": "10.7.220.41", + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": 162, + "snmp_v2c_trap_status": "enable", + "snmp_status": "enable", + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": 1, + "admin_http_port": null, + "snmp_v2c_query_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0", + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "snmp_v2c_trap_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255", + "provision_targets": null, + "snmp_v2c_trap_port": 161, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "ntp_v3": null, + "admin_https_redirect": null + }, + "post_method": "set" + } + ], + "get_devprof": [ + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": "enable", + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "kernel", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": 514, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": "10.7.220.59", + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": "enable", + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": "critical", + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "snmp_v2c_trap_hosts_ipv4": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "ntp_v3": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": "enable", + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": "ansibleV2c", + "syslog_facility": "syslog", + "snmp_v2c_status": "enable", + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": "10.7.220.41", + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": 162, + "snmp_v2c_trap_status": "enable", + "snmp_status": "enable", + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": 1, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0", + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "provision_targets": null, + "snmp_v2c_trap_port": 161, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": "10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255", + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "paramgram_used": { + "snmpv3_security_level": "auth-priv", + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": "enable", + "snmpv3_trap_status": "enable", + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": "ansibleSNMPv3", + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": "sha", + "smtp_port": null, + "snmpv3_priv_pwd": "fortinet", + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": 161, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": "10.7.220.59,10.7.220.60", + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": "enable", + "syslog_status": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": "0.0.0.0", + "snmpv3_trap_rport": 162, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "ntp_v3": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": "aes256", + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": "fortinet", + "smtp_source_ipv4": null, + "snmpv3_status": "enable", + "delete_provisioning_template": null, + "smtp_replyto": null, + "admin_https_redirect": null + }, + "datagram_sent": {}, + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": "fortiguard", + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": "enable", + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": 60, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "snmp_v2c_trap_hosts_ipv4": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "ntp_v3": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": "custom", + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": "10.7.220.32,10.7.220.1", + "admin_https_port": null, + "ntp_status": "enable", + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": "enable", + "snmp_v2c_id": null, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": 60, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": "fortinet", + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": 4433, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": 60, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": "10.7.220.38", + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": 8080, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": "blue", + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "snmp_v2c_trap_hosts_ipv4": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": "this-fmg", + "admin_switch_controller": "enable", + "admin_language": "english", + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "ntp_v3": null, + "admin_https_redirect": "enable" + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": "disable", + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": 25, + "snmpv3_priv_pwd": null, + "smtp_server": "10.7.220.32", + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": "ansible", + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": "fortinet", + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": "ansible@do-not-reply.com", + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": "starttls", + "mode": "set", + "smtp_source_ipv4": "0.0.0.0", + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": "ansible.local", + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": "8.8.8.8", + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": "4.4.4.4", + "smtp_replyto": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "snmp_v2c_trap_hosts_ipv4": null, + "provision_targets": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "ntp_v3": null, + "admin_https_redirect": null + }, + "post_method": "get" + }, + { + "url": "/pm/devprof/adom/ansible/ansibleTest", + "raw_response": { + "enabled options": [ + "dns", + "ntp", + "email", + "admin", + "snmp", + "repmsg", + "ftgd", + "log" + ], + "oid": 1542, + "type": "devprof", + "description": "CreatedByAnsible", + "name": "ansibleTest" + }, + "datagram_sent": {}, + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_trap_src_ipv4": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "dns_primary_ipv4": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "dns_secondary_ipv4": null, + "smtp_username": null, + "snmpv3_auth_pwd": null, + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_fortianalyzer_target": null, + "ntp_auth": null, + "snmp_v2c_id": null, + "admin_http_port": null, + "ntp_v3": null, + "snmp_v2c_query_hosts_ipv4": null, + "ntp_sync_interval": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "syslog_filter": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "provision_targets": "FGT1,FGT2", + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "admin_switch_controller": null, + "admin_language": null, + "smtp_conn_sec": null, + "mode": "set", + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_https_redirect": null + }, + "post_method": "get" + } + ], + "set_devprof_ntp": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": "fortiguard", + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": "enable", + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "snmp_v2c_trap_hosts_ipv4": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": 60, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "ntp_v3": null, + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "smtp_replyto": null, + "admin_https_redirect": null + }, + "datagram_sent": { + "ntpsync": 1, + "syncinterval": 60, + "type": 0 + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/ntp" + }, + "post_method": "set" + }, + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": "custom", + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": null, + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": "10.7.220.32,10.7.220.1", + "admin_https_port": null, + "ntp_status": "enable", + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": null, + "snmpv3_priv_pwd": null, + "smtp_server": null, + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": null, + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": null, + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": 60, + "ntp_auth_pwd": "fortinet", + "provisioning_template": "ansibleTest", + "smtp_replyto": null, + "ntp_auth": "enable", + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": null, + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": null, + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "ntp_v3": null + }, + "datagram_sent": { + "ntpsync": 1, + "syncinterval": 60, + "type": 1, + "ntpserver": [ + { + "ntpv3": 0, + "server": "10.7.220.32", + "authentication": 1, + "key": "fortinet", + "id": 1, + "key-id": 1 + }, + { + "ntpv3": 0, + "server": "10.7.220.1", + "authentication": 1, + "key": "fortinet", + "id": 2, + "key-id": 2 + } + ] + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/ntp" + }, + "post_method": "set" + } + ], + "set_devprof_smtp": [ + { + "paramgram_used": { + "snmpv3_security_level": null, + "snmp_v2c_query_status": null, + "provision_targets": null, + "ntp_type": null, + "dns_suffix": null, + "snmpv3_queries": null, + "snmpv3_trap_status": null, + "snmp_v2c_name": null, + "syslog_facility": "syslog", + "snmp_v2c_status": null, + "smtp_validate_cert": "disable", + "snmpv3_name": null, + "snmp_v2c_id": null, + "syslog_port": null, + "ntp_server": null, + "admin_https_port": null, + "ntp_status": null, + "syslog_server": null, + "admin_switch_controller": null, + "admin_timeout": null, + "snmpv3_auth_proto": null, + "smtp_port": 25, + "snmpv3_priv_pwd": null, + "smtp_server": "10.7.220.32", + "syslog_enc_algorithm": "disable", + "snmp_v2c_query_hosts_ipv4": null, + "smtp_username": "ansible", + "mode": "set", + "syslog_certificate": null, + "admin_fortiguard_target": null, + "snmpv3_query_port": null, + "smtp_password": "fortinet", + "adom": "ansible", + "snmpv3_notify_hosts": null, + "syslog_mode": "udp", + "snmp_v2c_query_port": null, + "snmp_v2c_trap_status": null, + "snmp_status": null, + "syslog_status": null, + "admin_https_redirect": null, + "admin_fortianalyzer_target": null, + "snmp_v2c_trap_src_ipv4": null, + "admin_http_port": null, + "dns_secondary_ipv4": null, + "syslog_filter": null, + "snmpv3_source_ip": null, + "snmpv3_trap_rport": null, + "admin_gui_theme": null, + "ntp_sync_interval": null, + "ntp_auth_pwd": null, + "provisioning_template": "ansibleTest", + "smtp_replyto": "ansible@do-not-reply.com", + "ntp_auth": null, + "snmp_v2c_trap_port": null, + "snmpv3_priv_proto": null, + "admin_enable_fortiguard": null, + "dns_primary_ipv4": null, + "admin_language": null, + "smtp_conn_sec": "starttls", + "snmpv3_auth_pwd": null, + "smtp_source_ipv4": "0.0.0.0", + "snmpv3_status": null, + "delete_provisioning_template": null, + "snmp_v2c_trap_hosts_ipv4": null, + "ntp_v3": null + }, + "datagram_sent": { + "username": "ansible", + "authenticate": 1, + "source-ip": "0.0.0.0", + "validate-server": 0, + "server": "10.7.220.32", + "port": 25, + "security": 1, + "password": "fortinet", + "reply-to": "ansible@do-not-reply.com" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/ansible/devprof/ansibleTest/system/email-server" + }, + "post_method": "set" + } + ] +} diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_ha.json b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_ha.json new file mode 100644 index 000000000..27c8483a5 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_ha.json @@ -0,0 +1,241 @@ +{ + "fmgr_set_ha_peer": [ + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha/peer/" + }, + "datagram_sent": { + "status": "enable", + "ip": "10.7.220.36", + "serial-number": "FMG-VMTM18001882", + "ip6": null, + "id": 1 + }, + "paramgram_used": { + "fmgr_ha_peer_sn": "FMG-VMTM18001882", + "next_peer_id": 2, + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": null, + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_peer_status": "enable", + "fmgr_ha_file_quota": 4096, + "fmgr_ha_cluster_id": 1, + "peer_id": 1, + "fmgr_ha_peer_ipv4": "10.7.220.36", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_mode": null + }, + "post_method": "set" + }, + { + "paramgram_used": { + "fmgr_ha_peer_sn": "FMG-VMTM18001881", + "next_peer_id": 1, + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": "fortinet", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_cluster_id": 2, + "fmgr_ha_file_quota": 4096, + "fmgr_ha_peer_status": "enable", + "peer_id": 1, + "fmgr_ha_peer_ipv4": "10.7.220.35", + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_mode": "slave" + }, + "datagram_sent": { + "status": "enable", + "ip": "10.7.220.35", + "serial-number": "FMG-VMTM18001881", + "ip6": null, + "id": 1 + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha/peer/" + }, + "post_method": "set" + } + ], + "fmgr_get_ha_peer_list": [ + { + "url": "/cli/global/system/ha/peer/", + "paramgram_used": { + "fmgr_ha_peer_sn": "FMG-VMTM18001882", + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": null, + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_peer_status": "enable", + "fmgr_ha_file_quota": 4096, + "fmgr_ha_cluster_id": 1, + "fmgr_ha_peer_ipv4": "10.7.220.36", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_mode": null + }, + "datagram_sent": {}, + "raw_response": [ + { + "status": "enable", + "ip": "10.7.220.140", + "serial-number": "FMG-VM0A17005535", + "ip6": "::", + "id": 1 + } + ], + "post_method": "get" + }, + { + "url": "/cli/global/system/ha/peer/", + "raw_response": [ + { + "status": "enable", + "ip": "10.7.220.35", + "serial-number": "FMG-VMTM18001881", + "ip6": "::", + "id": 1 + } + ], + "datagram_sent": {}, + "paramgram_used": { + "fmgr_ha_peer_sn": "FMG-VMTM18001881", + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": "fortinet", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_cluster_id": 2, + "fmgr_ha_file_quota": 4096, + "fmgr_ha_peer_status": "enable", + "fmgr_ha_peer_ipv4": "10.7.220.35", + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_mode": "slave" + }, + "post_method": "get" + } + ], + "fmgr_set_ha_mode": [ + { + "paramgram_used": { + "fmgr_ha_peer_sn": null, + "fmgr_ha_hb_threshold": 10, + "fmgr_ha_cluster_pw": "fortinet", + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_peer_status": null, + "fmgr_ha_file_quota": 2048, + "fmgr_ha_cluster_id": 2, + "fmgr_ha_peer_ipv4": null, + "fmgr_ha_hb_interval": 15, + "fmgr_ha_mode": "master" + }, + "datagram_sent": { + "file-quota": 2048, + "clusterid": 2, + "hb-lost-threshold": 10, + "mode": "master", + "hb-interval": 15, + "password": "fortinet" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha" + }, + "post_method": "set" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha" + }, + "datagram_sent": { + "file-quota": 4096, + "clusterid": 2, + "hb-lost-threshold": 3, + "mode": "slave", + "hb-interval": 5, + "password": "fortinet" + }, + "paramgram_used": { + "fmgr_ha_peer_sn": null, + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": "fortinet", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_cluster_id": 2, + "fmgr_ha_file_quota": 4096, + "fmgr_ha_peer_status": null, + "fmgr_ha_peer_ipv4": null, + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_mode": "slave" + }, + "post_method": "set" + }, + { + "paramgram_used": { + "fmgr_ha_peer_sn": "FMG-VMTM18001881", + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_cluster_pw": "fortinet", + "fmgr_ha_peer_ipv6": null, + "fmgr_ha_peer_status": "enable", + "fmgr_ha_file_quota": 4096, + "fmgr_ha_cluster_id": 2, + "fmgr_ha_peer_ipv4": "10.7.220.35", + "fmgr_ha_hb_interval": 5, + "fmgr_ha_mode": "slave" + }, + "datagram_sent": { + "file-quota": 4096, + "clusterid": 2, + "hb-lost-threshold": 3, + "mode": "slave", + "hb-interval": 5, + "password": "fortinet" + }, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha" + }, + "post_method": "set" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/cli/global/system/ha" + }, + "datagram_sent": { + "hb-lost-threshold": 3, + "hb-interval": 5, + "clusterid": 1, + "mode": "standalone", + "file-quota": 4096 + }, + "paramgram_used": { + "fmgr_ha_file_quota": 4096, + "fmgr_ha_cluster_pw": null, + "fmgr_ha_peer_sn": null, + "fmgr_ha_hb_interval": 5, + "fmgr_ha_cluster_id": 1, + "fmgr_ha_mode": "standalone", + "fmgr_ha_peer_status": null, + "fmgr_ha_hb_threshold": 3, + "fmgr_ha_peer_ipv4": null, + "fmgr_ha_peer_ipv6": null + }, + "post_method": "set" + } + ] +} diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_spam.json b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_spam.json new file mode 100644 index 000000000..d75156e1d --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_spam.json @@ -0,0 +1,157 @@ +{ + "fmgr_spamfilter_profile_modify": [ + { + "paramgram_used": { + "comment": null, + "smtp": { + "local-override": null, + "hdrip": null, + "log": null, + "tag-type": null, + "tag-msg": null, + "action": null + }, + "spam-log": null, + "gmail": { + "log": null + }, + "spam-bword-table": null, + "mapi": { + "action": null, + "log": null + }, + "flow-based": null, + "spam-mheader-table": null, + "spam-log-fortiguard-response": null, + "yahoo-mail": { + "log": null + }, + "adom": "root", + "pop3": { + "action": null, + "tag-msg": null, + "tag-type": null, + "log": null + }, + "external": null, + "spam-rbl-table": null, + "imap": { + "action": null, + "tag-msg": null, + "tag-type": null, + "log": null + }, + "spam-iptrust-table": null, + "replacemsg-group": null, + "name": "Ansible_Spam_Filter_Profile", + "spam-bwl-table": null, + "spam-filtering": null, + "msn-hotmail": { + "log": null + }, + "spam-bword-threshold": null, + "mode": "delete", + "options": null + }, + "datagram_sent": {}, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/root/obj/spamfilter/profile/Ansible_Spam_Filter_Profile" + }, + "post_method": "delete" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/root/obj/spamfilter/profile" + }, + "datagram_sent": { + "comment": "Created by Ansible", + "spam-log-fortiguard-response": "enable", + "spam-log": "enable", + "name": "Ansible_Spam_Filter_Profile", + "spam-filtering": "enable", + "flow-based": "enable", + "spam-bword-threshold": 10, + "external": "enable", + "options": [ + "bannedword", + "spamfsip", + "spamfsurl", + "spamrbl", + "spamfsphish", + "spambwl" + ], + "gmail": { + "log": "enable" + } + }, + "paramgram_used": { + "comment": "Created by Ansible", + "smtp": { + "local-override": null, + "hdrip": null, + "log": null, + "tag-type": null, + "tag-msg": null, + "action": null + }, + "yahoo-mail": { + "log": null + }, + "gmail": { + "log": "enable" + }, + "spam-bword-table": null, + "mapi": { + "action": null, + "log": null + }, + "flow-based": "enable", + "spam-mheader-table": null, + "spam-log-fortiguard-response": "enable", + "spam-log": "enable", + "adom": "root", + "pop3": { + "action": null, + "tag-type": null, + "log": null, + "tag-msg": null + }, + "external": "enable", + "spam-rbl-table": null, + "imap": { + "action": null, + "tag-type": null, + "log": null, + "tag-msg": null + }, + "spam-iptrust-table": null, + "name": "Ansible_Spam_Filter_Profile", + "replacemsg-group": null, + "spam-bwl-table": null, + "spam-filtering": "enable", + "msn-hotmail": { + "log": null + }, + "spam-bword-threshold": 10, + "mode": "set", + "options": [ + "bannedword", + "spamfsip", + "spamfsurl", + "spamrbl", + "spamfsphish", + "spambwl" + ] + }, + "post_method": "set" + } + ] +} diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_ssl_ssh.json b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_ssl_ssh.json new file mode 100644 index 000000000..6dc02883f --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fixtures/test_fmgr_secprof_ssl_ssh.json @@ -0,0 +1,214 @@ +{ + "fmgr_firewall_ssl_ssh_profile_modify": [ + { + "paramgram_used": { + "comment": null, + "untrusted-caname": null, + "mapi-over-https": null, + "whitelist": null, + "caname": null, + "ftps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "client-cert-request": null, + "ports": null, + "untrusted-cert": null + }, + "ssl-exemptions-log": null, + "https": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "client-cert-request": null, + "ports": null, + "untrusted-cert": null + }, + "imaps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "client-cert-request": null, + "ports": null, + "untrusted-cert": null + }, + "server-cert-mode": null, + "adom": "root", + "ssl-exempt": { + "regex": null, + "wildcard-fqdn": null, + "fortiguard-category": null, + "address6": null, + "address": null, + "type": null + }, + "ssl": { + "inspect-all": null, + "allow-invalid-server-cert": null, + "client-cert-request": null, + "untrusted-cert": null, + "unsupported-ssl": null + }, + "ssh": { + "status": null, + "inspect-all": null, + "ssh-tun-policy-check": null, + "ssh-policy-check": null, + "ssh-algorithm": null, + "unsupported-version": null, + "ports": null + }, + "use-ssl-server": null, + "server-cert": null, + "name": "Ansible_SSL_SSH_Profile", + "ssl-anomalies-log": null, + "ssl-server": { + "pop3s-client-cert-request": null, + "imaps-client-cert-request": null, + "smtps-client-cert-request": null, + "ip": null, + "ssl-other-client-cert-request": null, + "https-client-cert-request": null, + "ftps-client-cert-request": null + }, + "smtps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "client-cert-request": null, + "ports": null, + "untrusted-cert": null + }, + "rpc-over-https": null, + "mode": "delete", + "pop3s": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "client-cert-request": null, + "ports": null, + "untrusted-cert": null + } + }, + "datagram_sent": {}, + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/root/obj/firewall/ssl-ssh-profile/Ansible_SSL_SSH_Profile" + }, + "post_method": "delete" + }, + { + "raw_response": { + "status": { + "message": "OK", + "code": 0 + }, + "url": "/pm/config/adom/root/obj/firewall/ssl-ssh-profile" + }, + "datagram_sent": { + "comment": "Created by Ansible Module TEST", + "server-cert-mode": "replace", + "name": "Ansible_SSL_SSH_Profile", + "ssl-anomalies-log": "enable", + "mapi-over-https": "enable", + "whitelist": "enable", + "ssl-exemptions-log": "enable", + "rpc-over-https": "enable", + "use-ssl-server": "enable" + }, + "paramgram_used": { + "comment": "Created by Ansible Module TEST", + "untrusted-caname": null, + "mapi-over-https": "enable", + "whitelist": "enable", + "caname": null, + "ftps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "untrusted-cert": null, + "client-cert-request": null, + "ports": null + }, + "ssl-exemptions-log": "enable", + "https": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "untrusted-cert": null, + "client-cert-request": null, + "ports": null + }, + "pop3s": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "untrusted-cert": null, + "client-cert-request": null, + "ports": null + }, + "server-cert-mode": "replace", + "adom": "root", + "ssl-exempt": { + "regex": null, + "wildcard-fqdn": null, + "fortiguard-category": null, + "address6": null, + "address": null, + "type": null + }, + "ssl": { + "unsupported-ssl": null, + "inspect-all": null, + "allow-invalid-server-cert": null, + "untrusted-cert": null, + "client-cert-request": null + }, + "ssh": { + "status": null, + "inspect-all": null, + "ssh-tun-policy-check": null, + "ssh-policy-check": null, + "ssh-algorithm": null, + "unsupported-version": null, + "ports": null + }, + "server-cert": null, + "name": "Ansible_SSL_SSH_Profile", + "ssl-anomalies-log": "enable", + "ssl-server": { + "pop3s-client-cert-request": null, + "imaps-client-cert-request": null, + "smtps-client-cert-request": null, + "ip": null, + "ssl-other-client-cert-request": null, + "https-client-cert-request": null, + "ftps-client-cert-request": null + }, + "smtps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "untrusted-cert": null, + "client-cert-request": null, + "ports": null + }, + "imaps": { + "status": null, + "allow-invalid-server-cert": null, + "unsupported-ssl": null, + "untrusted-cert": null, + "client-cert-request": null, + "ports": null + }, + "rpc-over-https": "enable", + "mode": "set", + "use-ssl-server": "enable" + }, + "post_method": "set" + } + ] +} diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/fortimanager_module.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/fortimanager_module.py new file mode 100644 index 000000000..b45c6e01a --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/fortimanager_module.py @@ -0,0 +1,64 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + + +from ansible_collections.community.fortios.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase + + +class TestFortimanagerModule(ModuleTestCase): + + def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False): + + self.load_fixtures(commands) + + if failed: + result = self.failed() + self.assertTrue(result['failed'], result) + else: + result = self.changed(changed) + self.assertEqual(result['changed'], changed, result) + + if commands is not None: + if sort: + self.assertEqual(sorted(commands), sorted(result['commands']), result['commands']) + else: + self.assertEqual(commands, result['commands'], result['commands']) + + return result + + def failed(self): + with self.assertRaises(AnsibleFailJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertTrue(result['failed'], result) + return result + + def changed(self, changed=False): + with self.assertRaises(AnsibleExitJson) as exc: + self.module.main() + + result = exc.exception.args[0] + self.assertEqual(result['changed'], changed, result) + return result + + def load_fixtures(self, commands=None): + pass diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device.py new file mode 100644 index 000000000..0d3a3005d --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device.py @@ -0,0 +1,272 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_device +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_device.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_discover_device(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.151 + # device_unique_name: FGT1 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.152 + # device_unique_name: FGT2 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.153 + # device_unique_name: FGT3 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + + # Test using fixture 1 # + output = fmgr_device.discover_device(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_device.discover_device(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 3 # + output = fmgr_device.discover_device(fmg_instance, fixture_data[2]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + + +def test_add_device(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.151 + # device_unique_name: FGT1 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.152 + # device_unique_name: FGT2 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.153 + # device_unique_name: FGT3 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + + # Test using fixture 1 # + output = fmgr_device.add_device(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_device.add_device(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 3 # + output = fmgr_device.add_device(fmg_instance, fixture_data[2]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + + +def test_delete_device(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # device_username: admin + # adom: root + # device_ip: 10.7.220.151 + # device_unique_name: FGT1 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.152 + # device_unique_name: FGT2 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.153 + # device_unique_name: FGT3 + # mode: exec + # device_serial: None + # device_password: fortinet + ################################################## + + # Test using fixture 1 # + output = fmgr_device.delete_device(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device.delete_device(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_device.delete_device(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_get_device(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.151 + # device_unique_name: FGT1 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.152 + # device_unique_name: FGT2 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.153 + # device_unique_name: FGT3 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.151 + # device_unique_name: FGT1 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.152 + # device_unique_name: FGT2 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + ################################################## + # device_username: admin + # adom: ansible + # device_ip: 10.7.220.153 + # device_unique_name: FGT3 + # mode: get + # device_serial: None + # device_password: fortinet + ################################################## + + # Test using fixture 1 # + output = fmgr_device.get_device(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_device.get_device(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 3 # + output = fmgr_device.get_device(fmg_instance, fixture_data[2]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 4 # + output = fmgr_device.get_device(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 5 # + output = fmgr_device.get_device(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 6 # + output = fmgr_device.get_device(fmg_instance, fixture_data[5]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_config.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_config.py new file mode 100644 index 000000000..b0540e970 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_config.py @@ -0,0 +1,188 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_device_config +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_device_config.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_update_device_hostname(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # adom: ansible + # interface: None + # device_unique_name: FGT1 + # install_config: disable + # device_hostname: ansible-fgt01 + # interface_ip: None + # interface_allow_access: None + # mode: update + ################################################## + ################################################## + # adom: ansible + # interface: None + # device_unique_name: FGT2 + # install_config: disable + # device_hostname: ansible-fgt02 + # interface_ip: None + # interface_allow_access: None + # mode: update + ################################################## + ################################################## + # adom: ansible + # interface: None + # device_unique_name: FGT3 + # install_config: disable + # device_hostname: ansible-fgt03 + # interface_ip: None + # interface_allow_access: None + # mode: update + ################################################## + + # Test using fixture 1 # + output = fmgr_device_config.update_device_hostname(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_config.update_device_hostname(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_device_config.update_device_hostname(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_update_device_interface(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # adom: ansible + # install_config: disable + # device_unique_name: FGT1 + # interface: port2 + # device_hostname: None + # interface_ip: 10.1.1.1/24 + # interface_allow_access: ping, telnet, https, http + # mode: update + ################################################## + ################################################## + # adom: ansible + # install_config: disable + # device_unique_name: FGT2 + # interface: port2 + # device_hostname: None + # interface_ip: 10.1.2.1/24 + # interface_allow_access: ping, telnet, https, http + # mode: update + ################################################## + ################################################## + # adom: ansible + # install_config: disable + # device_unique_name: FGT3 + # interface: port2 + # device_hostname: None + # interface_ip: 10.1.3.1/24 + # interface_allow_access: ping, telnet, https, http + # mode: update + ################################################## + + # Test using fixture 1 # + output = fmgr_device_config.update_device_interface(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_config.update_device_interface(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_device_config.update_device_interface(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_exec_config(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # adom: ansible + # interface: None + # device_unique_name: FGT1 + # install_config: enable + # device_hostname: None + # interface_ip: None + # interface_allow_access: None + # mode: exec + ################################################## + ################################################## + # adom: ansible + # install_config: enable + # device_unique_name: FGT2, FGT3 + # interface: None + # device_hostname: None + # interface_ip: None + # interface_allow_access: None + # mode: exec + ################################################## + + # Test using fixture 1 # + output = fmgr_device_config.exec_config(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_device_config.exec_config(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_group.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_group.py new file mode 100644 index 000000000..723c29b11 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_group.py @@ -0,0 +1,202 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_device_group +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_device_group.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_add_device_group(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # grp_desc: CreatedbyAnsible + # adom: ansible + # grp_members: None + # mode: add + # grp_name: TestGroup + # vdom: root + ################################################## + ################################################## + # grp_desc: CreatedbyAnsible + # adom: ansible + # grp_members: None + # mode: add + # grp_name: testtest + # vdom: root + ################################################## + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT1 + # mode: add + # grp_name: TestGroup + # vdom: root + ################################################## + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT3 + # mode: add + # grp_name: testtest + # vdom: root + ################################################## + + # Test using fixture 1 # + output = fmgr_device_group.add_device_group(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -2 + # Test using fixture 2 # + output = fmgr_device_group.add_device_group(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_device_group.add_device_group(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == -2 + # Test using fixture 4 # + output = fmgr_device_group.add_device_group(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == -2 + + +def test_delete_device_group(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # grp_desc: CreatedbyAnsible + # adom: ansible + # grp_members: None + # mode: delete + # grp_name: TestGroup + # vdom: root + ################################################## + ################################################## + # grp_desc: CreatedbyAnsible + # adom: ansible + # grp_members: None + # mode: delete + # grp_name: testtest + # vdom: root + ################################################## + + # Test using fixture 1 # + output = fmgr_device_group.delete_device_group(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_group.delete_device_group(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_add_group_member(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT1 + # mode: add + # grp_name: TestGroup + # vdom: root + ################################################## + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT3 + # mode: add + # grp_name: testtest + # vdom: root + ################################################## + + # Test using fixture 1 # + output = fmgr_device_group.add_group_member(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_group.add_group_member(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_delete_group_member(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT3 + # mode: delete + # grp_name: testtest + # vdom: root + ################################################## + ################################################## + # grp_desc: None + # adom: ansible + # grp_members: FGT1 + # mode: delete + # grp_name: TestGroup + # vdom: root + ################################################## + + # Test using fixture 1 # + output = fmgr_device_group.delete_group_member(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_group.delete_group_member(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_provision_template.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_provision_template.py new file mode 100644 index 000000000..3ece0f222 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_device_provision_template.py @@ -0,0 +1,1758 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_device_provision_template +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_device_provision_template.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_get_devprof(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: enable + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: kernel + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: 514 + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: 10.7.220.59 + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: enable + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: critical + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # snmp_v2c_trap_hosts_ipv4: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # ntp_v3: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: enable + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: ansibleV2c + # syslog_facility: syslog + # snmp_v2c_status: enable + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: 10.7.220.41 + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: 162 + # snmp_v2c_trap_status: enable + # snmp_status: enable + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: 1 + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0 + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # provision_targets: None + # snmp_v2c_trap_port: 161 + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255 + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: auth-priv + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: enable + # snmpv3_trap_status: enable + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: ansibleSNMPv3 + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: sha + # smtp_port: None + # snmpv3_priv_pwd: fortinet + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: get + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: 161 + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: 10.7.220.59,10.7.220.60 + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: enable + # syslog_status: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: 0.0.0.0 + # snmpv3_trap_rport: 162 + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # ntp_v3: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: aes256 + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: fortinet + # smtp_source_ipv4: None + # snmpv3_status: enable + # delete_provisioning_template: None + # smtp_replyto: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: fortiguard + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: enable + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: 60 + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # snmp_v2c_trap_hosts_ipv4: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # ntp_v3: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: custom + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: 10.7.220.32,10.7.220.1 + # admin_https_port: None + # ntp_status: enable + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: enable + # snmp_v2c_id: None + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: 60 + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: fortinet + # provisioning_template: ansibleTest + # smtp_replyto: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: 4433 + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: 60 + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: 10.7.220.38 + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: 8080 + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: blue + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # snmp_v2c_trap_hosts_ipv4: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: this-fmg + # admin_switch_controller: enable + # admin_language: english + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # ntp_v3: None + # admin_https_redirect: enable + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: disable + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: 25 + # snmpv3_priv_pwd: None + # smtp_server: 10.7.220.32 + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: ansible + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: fortinet + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: ansible@do-not-reply.com + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: starttls + # mode: get + # smtp_source_ipv4: 0.0.0.0 + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: ansible.local + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: 8.8.8.8 + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: 4.4.4.4 + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # snmp_v2c_trap_hosts_ipv4: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # ntp_v3: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # provision_targets: FGT1,FGT2 + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: get + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 3 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[2]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 4 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[3]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 5 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[4]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 6 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[5]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 7 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[6]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 8 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[7]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 9 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[8]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 10 # + output = fmgr_device_provision_template.get_devprof(fmg_instance, fixture_data[9]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + + +def test_set_devprof(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # smtp_port: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # ntp_auth: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_fortianalyzer_target: None + # snmp_v2c_id: None + # admin_http_port: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: delete + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: ansibleTest + # ntp_v3: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_scope(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: FGT1,FGT2 + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # ntp_v3: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_scope(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_snmp(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: enable + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # ntp_v3: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: enable + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: ansibleV2c + # syslog_facility: syslog + # snmp_v2c_status: enable + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: 1 + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0 + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: 162 + # snmp_v2c_trap_status: enable + # snmp_status: enable + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: 10.7.220.41 + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # ntp_auth: None + # snmp_v2c_trap_port: 161 + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255 + # ntp_v3: None + ################################################## + ################################################## + # snmpv3_security_level: auth-priv + # snmp_v2c_query_status: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: enable + # snmpv3_trap_status: enable + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: ansibleSNMPv3 + # snmp_v2c_trap_src_ipv4: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: sha + # smtp_port: None + # snmpv3_priv_pwd: fortinet + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_username: None + # snmpv3_auth_pwd: fortinet + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: 161 + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: 10.7.220.59,10.7.220.60 + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: enable + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: None + # admin_http_port: None + # ntp_v3: None + # snmp_v2c_query_hosts_ipv4: None + # ntp_sync_interval: None + # snmpv3_source_ip: 0.0.0.0 + # snmpv3_trap_rport: 162 + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # provision_targets: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: aes256 + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: set + # smtp_source_ipv4: None + # snmpv3_status: enable + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_snmp(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_provision_template.set_devprof_snmp(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_device_provision_template.set_devprof_snmp(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_snmp_v2c(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: enable + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: ansibleV2c + # syslog_facility: syslog + # snmp_v2c_status: enable + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_trap_src_ipv4: 10.7.220.41 + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # dns_primary_ipv4: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # dns_secondary_ipv4: None + # smtp_replyto: None + # smtp_username: None + # snmpv3_auth_pwd: None + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: 162 + # snmp_v2c_trap_status: enable + # snmp_status: enable + # syslog_status: None + # admin_fortianalyzer_target: None + # ntp_auth: None + # snmp_v2c_id: 1 + # admin_http_port: None + # snmp_v2c_query_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.0 255.255.255.0 + # ntp_sync_interval: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # syslog_filter: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # snmp_v2c_trap_hosts_ipv4: 10.7.220.59 255.255.255.255, 10.7.220.60 255.255.255.255 + # provision_targets: None + # snmp_v2c_trap_port: 161 + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # admin_switch_controller: None + # admin_language: None + # smtp_conn_sec: None + # mode: set + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # ntp_v3: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_snmp_v2c(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + + +def test_set_devprof_snmp_v3(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: auth-priv + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: enable + # snmpv3_trap_status: enable + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: ansibleSNMPv3 + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: sha + # smtp_port: None + # snmpv3_priv_pwd: fortinet + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: 161 + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: 10.7.220.59,10.7.220.60 + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: enable + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: 0.0.0.0 + # snmpv3_trap_rport: 162 + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: aes256 + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: fortinet + # smtp_source_ipv4: None + # snmpv3_status: enable + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # ntp_v3: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_snmp_v3(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_syslog(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: kernel + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: 514 + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: 10.7.220.59 + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: enable + # snmp_v2c_trap_hosts_ipv4: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: critical + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # ntp_v3: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # smtp_replyto: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_syslog(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_ntp(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: fortiguard + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: enable + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: 60 + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # ntp_v3: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # smtp_replyto: None + # admin_https_redirect: None + ################################################## + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: custom + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: 10.7.220.32,10.7.220.1 + # admin_https_port: None + # ntp_status: enable + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: 60 + # ntp_auth_pwd: fortinet + # provisioning_template: ansibleTest + # smtp_replyto: None + # ntp_auth: enable + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # ntp_v3: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_ntp(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_device_provision_template.set_devprof_ntp(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_admin(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: 4433 + # ntp_status: None + # syslog_server: None + # admin_switch_controller: enable + # admin_timeout: 60 + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_fortianalyzer_target: 10.7.220.38 + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: 8080 + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: blue + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # ntp_v3: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: this-fmg + # dns_primary_ipv4: None + # admin_language: english + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # smtp_replyto: None + # admin_https_redirect: enable + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_admin(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_smtp(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: None + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: disable + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: 25 + # snmpv3_priv_pwd: None + # smtp_server: 10.7.220.32 + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: ansible + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: fortinet + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # admin_https_redirect: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: None + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # smtp_replyto: ansible@do-not-reply.com + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: None + # admin_language: None + # smtp_conn_sec: starttls + # snmpv3_auth_pwd: None + # smtp_source_ipv4: 0.0.0.0 + # snmpv3_status: None + # delete_provisioning_template: None + # snmp_v2c_trap_hosts_ipv4: None + # ntp_v3: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_smtp(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_set_devprof_dns(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # snmpv3_security_level: None + # snmp_v2c_query_status: None + # provision_targets: None + # ntp_type: None + # dns_suffix: ansible.local + # snmpv3_queries: None + # snmpv3_trap_status: None + # snmp_v2c_name: None + # syslog_facility: syslog + # snmp_v2c_status: None + # smtp_validate_cert: None + # snmpv3_name: None + # snmp_v2c_id: None + # syslog_port: None + # ntp_server: None + # admin_https_port: None + # ntp_status: None + # syslog_server: None + # admin_switch_controller: None + # admin_timeout: None + # snmpv3_auth_proto: None + # smtp_port: None + # snmpv3_priv_pwd: None + # smtp_server: None + # syslog_enc_algorithm: disable + # snmp_v2c_query_hosts_ipv4: None + # smtp_username: None + # mode: set + # syslog_certificate: None + # admin_fortiguard_target: None + # snmpv3_query_port: None + # smtp_password: None + # adom: ansible + # snmpv3_notify_hosts: None + # syslog_mode: udp + # snmp_v2c_query_port: None + # snmp_v2c_trap_status: None + # snmp_status: None + # syslog_status: None + # snmp_v2c_trap_hosts_ipv4: None + # admin_fortianalyzer_target: None + # snmp_v2c_trap_src_ipv4: None + # admin_http_port: None + # dns_secondary_ipv4: 4.4.4.4 + # syslog_filter: None + # snmpv3_source_ip: None + # snmpv3_trap_rport: None + # admin_gui_theme: None + # ntp_sync_interval: None + # ntp_auth_pwd: None + # provisioning_template: ansibleTest + # ntp_v3: None + # ntp_auth: None + # snmp_v2c_trap_port: None + # snmpv3_priv_proto: None + # admin_enable_fortiguard: None + # dns_primary_ipv4: 8.8.8.8 + # admin_language: None + # smtp_conn_sec: None + # snmpv3_auth_pwd: None + # smtp_source_ipv4: None + # snmpv3_status: None + # delete_provisioning_template: None + # smtp_replyto: None + # admin_https_redirect: None + ################################################## + + # Test using fixture 1 # + output = fmgr_device_provision_template.set_devprof_dns(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_address.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_address.py new file mode 100644 index 000000000..97d4a3f00 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_address.py @@ -0,0 +1,156 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwobj_address +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwobj_address.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_fwobj_ipv4(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 2 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 5 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 6 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[5]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 7 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[6]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 8 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[7]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 9 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[8]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 10 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[9]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 11 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[10]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 12 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[11]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 13 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[12]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 14 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[13]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 15 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[14]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 16 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[15]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 17 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[16]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 18 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv4(fmg_instance, fixture_data[17]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_fmgr_fwobj_ipv6(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv6(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 2 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv6(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 3 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv6(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv6(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 5 # + output = fmgr_fwobj_address.fmgr_fwobj_ipv6(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == -10131 + + +def test_fmgr_fwobj_multicast(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_address.fmgr_fwobj_multicast(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwobj_address.fmgr_fwobj_multicast(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwobj_address.fmgr_fwobj_multicast(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool.py new file mode 100644 index 000000000..399fc4c8d --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool.py @@ -0,0 +1,90 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwobj_ippool +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwobj_ippool.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_fwobj_ippool_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 5 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 6 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[5]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 7 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[6]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 8 # + output = fmgr_fwobj_ippool.fmgr_fwobj_ippool_modify(fmg_instance, fixture_data[7]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool6.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool6.py new file mode 100644 index 000000000..04877ff5d --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_ippool6.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwobj_ippool6 +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwobj_ippool6.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_fwobj_ippool6_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_ippool6.fmgr_fwobj_ippool6_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwobj_ippool6.fmgr_fwobj_ippool6_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_service.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_service.py new file mode 100644 index 000000000..57edff901 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_service.py @@ -0,0 +1,123 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwobj_service +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwobj_service.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_fwobj_service_custom(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 5 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 6 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[5]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 7 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[6]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 8 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[7]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 9 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[8]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 10 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[9]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 11 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[10]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 12 # + output = fmgr_fwobj_service.fmgr_fwobj_service_custom(fmg_instance, fixture_data[11]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_fmgr_fwobj_service_group(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_service.fmgr_fwobj_service_group(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 2 # + output = fmgr_fwobj_service.fmgr_fwobj_service_group(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == -10131 + + +def test_fmgr_fwobj_service_category(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwobj_service.fmgr_fwobj_service_category(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -2 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_vip.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_vip.py new file mode 100644 index 000000000..c8dbfc775 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwobj_vip.py @@ -0,0 +1,785 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwobj_vip +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwobj_vip.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_firewall_vip_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # comment: Created by Ansible + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # mapped-addr: None + # ssl-client-session-state-timeout: None + # src-filter: None + # server-type: None + # ssl-hpkp-include-subdomains: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: 10.7.220.25 + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: tcp + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # ssl-client-renegotiation: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # weblogic-server: None + # http-cookie-share: None + # color: 17 + # ssl-mode: None + # portforward: enable + # http-multiplex: None + # http-cookie-generation: None + # ssl-client-fallback: None + # extip: 82.72.192.185 + # extintf: any + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + + # adom: ansible + # ssl-client-session-state-max: None + # http-ip-header: None + # http-ip-header-name: None + # ssl-certificate: None + # ssl-hsts: None + # arp-reply: None + # ssl-hsts-include-subdomains: None + # ssl-min-version: None + # ldb-method: None + # ssl-server-session-state-timeout: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: 443 + # name: Basic PNAT Map Port 10443 + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # outlook-web-access: None + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-server-max-version: None + # ssl-hpkp-report-uri: None + # http-cookie-domain-from-host: None + # ssl-algorithm: None + # gratuitous-arp-interval: None + # extport: 10443 + # max-embryonic-connections: None + # mode: set + # http-cookie-path: None + # ssl-pfs: None + # ssl-server-algorithm: None + ################################################## + ################################################## + # comment: Created by Ansible + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # ssl-hsts-include-subdomains: None + # mapped-addr: None + # src-filter: None + # server-type: None + # mode: set + # ssl-hpkp-include-subdomains: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: 3.3.3.0/24, 4.0.0.0/24 + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # ssl-client-renegotiation: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # adom: ansible + # http-cookie-share: None + # ssl-server-session-state-timeout: None + # color: 12 + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # max-embryonic-connections: None + # ssl-client-fallback: None + # ssl-hpkp-report-uri: None + # extip: 192.168.0.1-192.168.0.100 + # extintf: dmz + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + # http-ip-header-name: None + # weblogic-server: None + # ssl-client-session-state-max: None + # http-ip-header: None + + # ssl-hsts: None + # arp-reply: None + # extaddr: None + # ssl-min-version: None + # ldb-method: None + # ssl-certificate: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # outlook-web-access: None + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # name: Basic DNS Translation + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-pfs: None + # ssl-server-max-version: None + # ssl-client-session-state-timeout: None + # http-cookie-domain-from-host: None + # extport: None + # ssl-server-algorithm: None + # gratuitous-arp-interval: None + # http-cookie-path: None + # ssl-algorithm: None + # http-multiplex: None + ################################################## + ################################################## + # comment: Created by Ansible + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # mapped-addr: google-play + # ssl-client-session-state-timeout: None + # src-filter: None + # ldb-method: None + # server-type: None + # ssl-hpkp-include-subdomains: None + # ssl-client-renegotiation: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: None + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # weblogic-server: None + # http-cookie-share: None + # color: 5 + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # ssl-client-fallback: None + # extip: None + # extintf: None + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + + # adom: ansible + # ssl-client-session-state-max: None + # http-ip-header: None + # http-ip-header-name: None + # ssl-certificate: None + # ssl-hsts: None + # arp-reply: None + # extport: None + # ssl-min-version: None + # ssl-server-algorithm: None + # ssl-server-session-state-timeout: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # name: Basic FQDN Translation + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # outlook-web-access: None + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-server-max-version: None + # ssl-hpkp-report-uri: None + # http-cookie-domain-from-host: None + # ssl-algorithm: None + # gratuitous-arp-interval: None + # ssl-hsts-include-subdomains: None + # max-embryonic-connections: None + # mode: set + # http-cookie-path: None + # ssl-pfs: None + # http-multiplex: None + ################################################## + ################################################## + # comment: Created by Ansible + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # mapped-addr: None + # src-filter: None + # server-type: None + # mode: set + # ssl-hpkp-include-subdomains: None + # extport: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: 10.7.220.25 + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # ssl-server-algorithm: None + # extaddr: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # adom: ansible + # http-cookie-share: None + # ssl-server-session-state-timeout: None + # color: 17 + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # max-embryonic-connections: None + # ssl-client-fallback: None + # ssl-hpkp-report-uri: None + # extip: 82.72.192.185 + # extintf: any + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + # http-ip-header-name: None + # weblogic-server: None + # ssl-client-session-state-max: None + # http-ip-header: None + + # ssl-hsts: None + # arp-reply: None + # ssl-client-renegotiation: None + # ssl-min-version: None + # ldb-method: None + # ssl-certificate: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # outlook-web-access: None + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # name: Basic StaticNAT Map + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-pfs: None + # ssl-client-session-state-timeout: None + # http-cookie-domain-from-host: None + # ssl-hsts-include-subdomains: None + # ssl-server-max-version: None + # gratuitous-arp-interval: None + # http-cookie-path: None + # ssl-algorithm: None + # http-multiplex: None + ################################################## + ################################################## + # comment: Created by Ansible + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # mapped-addr: None + # ssl-client-session-state-timeout: None + # src-filter: None + # server-type: None + # ssl-hpkp-include-subdomains: None + # ssl-client-renegotiation: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: 10.7.220.25 + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: tcp + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # weblogic-server: None + # http-cookie-share: None + # color: 17 + # ssl-mode: None + # portforward: enable + # http-cookie-generation: None + # ssl-client-fallback: None + # extip: 82.72.192.185 + # extintf: any + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + + # adom: ansible + # ssl-client-session-state-max: None + # http-ip-header: None + # http-ip-header-name: None + # ssl-min-version: None + # ssl-certificate: None + # ssl-hsts: None + # arp-reply: None + # ssl-hsts-include-subdomains: None + # http-multiplex: None + # ldb-method: None + # ssl-server-session-state-timeout: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: 443 + # name: Basic PNAT Map Port 10443 + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # outlook-web-access: None + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-server-max-version: None + # ssl-hpkp-report-uri: None + # http-cookie-domain-from-host: None + # ssl-algorithm: None + # gratuitous-arp-interval: None + # extport: 10443 + # max-embryonic-connections: None + # mode: set + # http-cookie-path: None + # ssl-pfs: None + # ssl-server-algorithm: None + ################################################## + ################################################## + # comment: None + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # ssl-hpkp: None + # ssl-hsts-include-subdomains: None + # mapped-addr: None + # src-filter: None + # server-type: None + # mode: delete + # ssl-hpkp-include-subdomains: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # mappedip: None + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # adom: ansible + # http-cookie-share: None + # ssl-server-session-state-timeout: None + # color: None + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # max-embryonic-connections: None + # ssl-client-fallback: None + # ssl-hpkp-report-uri: None + # extip: None + # extintf: None + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + # http-ip-header-name: None + # weblogic-server: None + # ssl-client-session-state-max: None + # http-ip-header: None + + # ssl-hsts: None + # arp-reply: None + # ssl-client-renegotiation: None + # http-multiplex: None + # ldb-method: None + # ssl-certificate: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # outlook-web-access: None + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # name: Basic PNAT Map Port 10443 + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-pfs: None + # ssl-server-max-version: None + # ssl-client-session-state-timeout: None + # http-cookie-domain-from-host: None + # extport: None + # ssl-server-algorithm: None + # gratuitous-arp-interval: None + # http-cookie-path: None + # ssl-algorithm: None + # ssl-min-version: None + ################################################## + ################################################## + # comment: None + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # mappedip: None + # mapped-addr: None + # ssl-client-session-state-timeout: None + # src-filter: None + # ldb-method: None + # server-type: None + # ssl-hpkp-include-subdomains: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # ssl-hpkp: None + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # ssl-client-renegotiation: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # weblogic-server: None + # http-cookie-share: None + # color: None + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # ssl-client-fallback: None + # extip: None + # extintf: None + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + + # adom: ansible + # ssl-client-session-state-max: None + # http-ip-header: None + # http-ip-header-name: None + # ssl-certificate: None + # ssl-hsts: None + # arp-reply: None + # extport: None + # http-multiplex: None + # ssl-server-algorithm: None + # ssl-server-session-state-timeout: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # name: Basic StaticNAT Map + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-hpkp-primary: None + # outlook-web-access: None + # ssl-server-session-state-type: None + # ssl-client-session-state-type: None + + # ssl-http-match-host: None + + # ssl-server-max-version: None + # ssl-hpkp-report-uri: None + # http-cookie-domain-from-host: None + # ssl-algorithm: None + # gratuitous-arp-interval: None + # ssl-hsts-include-subdomains: None + # max-embryonic-connections: None + # mode: delete + # http-cookie-path: None + # ssl-pfs: None + # ssl-min-version: None + ################################################## + ################################################## + # comment: None + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # mappedip: None + # mapped-addr: None + # src-filter: None + # server-type: None + # mode: delete + # ssl-hpkp-include-subdomains: None + # extport: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # ssl-hpkp: None + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # ssl-server-algorithm: None + # ssl-client-renegotiation: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # adom: ansible + # http-cookie-share: None + # ssl-server-session-state-timeout: None + # color: None + # ssl-mode: None + # portforward: None + # http-multiplex: None + # http-cookie-generation: None + # max-embryonic-connections: None + # ssl-client-fallback: None + # ssl-hpkp-report-uri: None + # extip: None + # extintf: None + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + # http-ip-header-name: None + # weblogic-server: None + # ssl-client-session-state-max: None + # http-ip-header: None + # ssl-hsts: None + # arp-reply: None + # extaddr: None + # ssl-hpkp-primary: None + # ldb-method: None + # ssl-certificate: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # outlook-web-access: None + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-client-session-state-type: None + # name: Basic DNS Translation + # ssl-server-session-state-type: None + + # ssl-http-match-host: None + # ssl-pfs: None + # ssl-client-session-state-timeout: None + # http-cookie-domain-from-host: None + # ssl-hsts-include-subdomains: None + # ssl-server-max-version: None + # gratuitous-arp-interval: None + # http-cookie-path: None + # ssl-algorithm: None + # ssl-min-version: None + ################################################## + ################################################## + # ldb-method: None + # ssl-send-empty-frags: None + # srcintf-filter: None + # ssl-max-version: None + # ssl-server-session-state-max: None + # mappedip: None + # ssl-hsts: None + # mapped-addr: None + # src-filter: None + # server-type: None + # ssl-hpkp-include-subdomains: None + # ssl-client-renegotiation: None + # ssl-http-location-conversion: None + # https-cookie-secure: None + # extip: None + # ssl-hpkp: None + # ssl-server-cipher-suites: {'priority': None, 'cipher': None, 'versions': None} + # protocol: None + # ssl-hpkp-backup: None + # ssl-dh-bits: None + # dns-mapping-ttl: None + # ssl-hsts-age: None + # extaddr: None + # ssl-hpkp-primary: None + # monitor: None + # service: None + # ssl-hpkp-age: None + # http-cookie-age: None + # weblogic-server: None + # http-cookie-share: None + # name: Basic FQDN Translation + # color: None + # ssl-mode: None + # portforward: None + # http-cookie-generation: None + # ssl-client-fallback: None + + # http-ip-header: None + # persistence: None + # websphere-server: None + # nat-source-vip: None + # portmapping-type: None + # adom: ansible + # ssl-client-session-state-max: None + # extintf: None + # ssl-server-max-version: None + # http-ip-header-name: None + # ssl-certificate: None + # ssl-server-session-state-type: None + # arp-reply: None + # ssl-hsts-include-subdomains: None + # ssl-min-version: None + # ssl-server-algorithm: None + # ssl-server-session-state-timeout: None + # ssl-server-min-version: None + # http-cookie-domain: None + # mappedport: None + # outlook-web-access: None + # ssl-cipher-suites: {'cipher': None, 'versions': None} + # ssl-client-session-state-type: None + # ssl-http-match-host: None + + # ssl-client-session-state-timeout: None + # comment: None + # ssl-hpkp-report-uri: None + # http-cookie-domain-from-host: None + # ssl-algorithm: None + # gratuitous-arp-interval: None + # extport: None + # max-embryonic-connections: None + # mode: delete + # http-cookie-path: None + # ssl-pfs: None + # http-multiplex: None + ################################################## + + # Test using fixture 1 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == -10131 + # Test using fixture 3 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 5 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[4]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 6 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[5]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 7 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[6]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 8 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[7]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 9 # + output = fmgr_fwobj_vip.fmgr_firewall_vip_modify(fmg_instance, fixture_data[8]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_ipv4.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_ipv4.py new file mode 100644 index 000000000..767573e22 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_ipv4.py @@ -0,0 +1,596 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwpol_ipv4 +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwpol_ipv4.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_firewall_policy_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # wanopt-passive-opt: None + # package_name: default + # wanopt-detection: None + # scan-botnet-connections: None + # profile-group: None + # wanopt-peer: None + # dscp-match: None + # replacemsg-override-group: None + # internet-service-negate: None + # np-acceleration: None + # learning-mode: None + # session-ttl: None + # ntlm-guest: None + # ips-sensor: None + # diffservcode-rev: None + # match-vip: None + # natip: None + # dlp-sensor: None + # traffic-shaper: None + # groups: None + # schedule-timeout: None + # name: Basic_IPv4_Policy + # tcp-session-without-syn: None + # ntlm: None + # permit-stun-host: None + # diffservcode-forward: None + # internet-service-src-custom: None + # mode: set + # disclaimer: None + # rtp-nat: None + # auth-cert: None + # timeout-send-rst: None + # auth-redirect-addr: None + # ssl-mirror-intf: None + # identity-based-route: None + # natoutbound: None + # wanopt-profile: None + # per-ip-shaper: None + # profile-protocol-options: None + # diffserv-forward: None + # poolname: None + # comments: Created by Ansible + # label: None + # global-label: None + # firewall-session-dirty: None + # wanopt: None + # schedule: always + # internet-service-id: None + # auth-path: None + # vlan-cos-fwd: None + # custom-log-fields: None + # dstintf: any + # srcintf: any + # block-notification: None + # internet-service-src-id: None + # redirect-url: None + # waf-profile: None + # ntlm-enabled-browsers: None + # dscp-negate: None + # action: accept + # fsso-agent-for-ntlm: None + # logtraffic: utm + # vlan-filter: None + # policyid: None + # logtraffic-start: None + # webcache-https: None + # webfilter-profile: None + # internet-service-src: None + # webcache: None + # utm-status: None + # vpn_src_node: {'subnet': None, 'host': None, 'seq': None} + # ippool: None + # service: ALL + # wccp: None + # auto-asic-offload: None + # dscp-value: None + # url-category: None + # capture-packet: None + # adom: ansible + # inbound: None + # internet-service: None + # profile-type: None + # ssl-mirror: None + # srcaddr-negate: None + # gtp-profile: None + # mms-profile: None + # send-deny-packet: None + # devices: None + # permit-any-host: None + # av-profile: None + # internet-service-src-negate: None + # service-negate: None + # rsso: None + # app-group: None + # tcp-mss-sender: None + # natinbound: None + # fixedport: None + # ssl-ssh-profile: None + # outbound: None + # spamfilter-profile: None + # application-list: None + # application: None + # dnsfilter-profile: None + # nat: None + # fsso: None + # vlan-cos-rev: None + # status: None + # dsri: None + # users: None + # voip-profile: None + # dstaddr-negate: None + # traffic-shaper-reverse: None + # internet-service-custom: None + # diffserv-reverse: None + # srcaddr: all + # ssh-filter-profile: None + # delay-tcp-npu-session: None + # icap-profile: None + # captive-portal-exempt: None + # vpn_dst_node: {'subnet': None, 'host': None, 'seq': None} + # app-category: None + # rtp-addr: None + # wsso: None + # tcp-mss-receiver: None + # dstaddr: all + # radius-mac-auth-bypass: None + # vpntunnel: None + ################################################## + ################################################## + # package_name: default + # wanopt-detection: None + # scan-botnet-connections: None + # profile-group: None + # dlp-sensor: None + # dscp-match: None + # replacemsg-override-group: None + # internet-service-negate: None + # np-acceleration: None + # learning-mode: None + # session-ttl: None + # ntlm-guest: None + # ips-sensor: None + # diffservcode-rev: None + # match-vip: None + # natip: None + # wanopt-peer: None + # traffic-shaper: None + # groups: None + # schedule-timeout: None + # name: Basic_IPv4_Policy_2 + # tcp-session-without-syn: None + # rtp-nat: None + # permit-stun-host: None + # natoutbound: None + # internet-service-src-custom: None + # mode: set + # logtraffic: utm + # ntlm: None + # auth-cert: None + # timeout-send-rst: None + # auth-redirect-addr: None + # ssl-mirror-intf: None + # identity-based-route: None + # diffservcode-forward: None + # wanopt-profile: None + # per-ip-shaper: None + # users: None + # diffserv-forward: None + # poolname: None + # comments: Created by Ansible + # label: None + # global-label: None + # firewall-session-dirty: None + # wanopt: None + # schedule: always + # internet-service-id: None + # auth-path: None + # vlan-cos-fwd: None + # custom-log-fields: None + # dstintf: any + # srcintf: any + # block-notification: None + # internet-service-src-id: None + # redirect-url: None + # waf-profile: None + # ntlm-enabled-browsers: None + # dscp-negate: None + # action: accept + # fsso-agent-for-ntlm: None + # disclaimer: None + # vlan-filter: None + # dstaddr-negate: None + # logtraffic-start: None + # webcache-https: None + # webfilter-profile: None + # internet-service-src: None + # webcache: None + # utm-status: None + # vpn_src_node: {'subnet': None, 'host': None, 'seq': None} + # ippool: None + # service: HTTP, HTTPS + # wccp: None + # auto-asic-offload: None + # dscp-value: None + # url-category: None + # capture-packet: None + # adom: ansible + # inbound: None + # internet-service: None + # profile-type: None + # ssl-mirror: None + # srcaddr-negate: None + # gtp-profile: None + # mms-profile: None + # send-deny-packet: None + # devices: None + # permit-any-host: None + # av-profile: None + # internet-service-src-negate: None + # service-negate: None + # rsso: None + # application-list: None + # app-group: None + # tcp-mss-sender: None + # natinbound: None + # fixedport: None + # ssl-ssh-profile: None + # outbound: None + # spamfilter-profile: None + # wanopt-passive-opt: None + # application: None + # dnsfilter-profile: None + # nat: enable + # fsso: None + # vlan-cos-rev: None + # status: None + # dsri: None + # profile-protocol-options: None + # voip-profile: None + # policyid: None + # traffic-shaper-reverse: None + # internet-service-custom: None + # diffserv-reverse: None + # srcaddr: all + # dstaddr: google-play + # delay-tcp-npu-session: None + # icap-profile: None + # captive-portal-exempt: None + # vpn_dst_node: {'subnet': None, 'host': None, 'seq': None} + # app-category: None + # rtp-addr: None + # wsso: None + # tcp-mss-receiver: None + # ssh-filter-profile: None + # radius-mac-auth-bypass: None + # vpntunnel: None + ################################################## + ################################################## + # wanopt-passive-opt: None + # package_name: default + # wanopt-detection: None + # scan-botnet-connections: None + # profile-group: None + # wanopt-peer: None + # dscp-match: None + # replacemsg-override-group: None + # internet-service-negate: None + # np-acceleration: None + # learning-mode: None + # session-ttl: None + # ntlm-guest: None + # ips-sensor: None + # diffservcode-rev: None + # match-vip: None + # natip: None + # dlp-sensor: None + # traffic-shaper: None + # groups: None + # schedule-timeout: None + # name: Basic_IPv4_Policy + # tcp-session-without-syn: None + # ntlm: None + # permit-stun-host: None + # diffservcode-forward: None + # internet-service-src-custom: None + # mode: delete + # disclaimer: None + # rtp-nat: None + # auth-cert: None + # timeout-send-rst: None + # auth-redirect-addr: None + # ssl-mirror-intf: None + # identity-based-route: None + # natoutbound: None + # wanopt-profile: None + # per-ip-shaper: None + # profile-protocol-options: None + # diffserv-forward: None + # poolname: None + # comments: None + # label: None + # global-label: None + # firewall-session-dirty: None + # wanopt: None + # schedule: None + # internet-service-id: None + # auth-path: None + # vlan-cos-fwd: None + # custom-log-fields: None + # dstintf: None + # srcintf: None + # block-notification: None + # internet-service-src-id: None + # redirect-url: None + # waf-profile: None + # ntlm-enabled-browsers: None + # dscp-negate: None + # action: None + # fsso-agent-for-ntlm: None + # logtraffic: None + # vlan-filter: None + # policyid: 36 + # logtraffic-start: None + # webcache-https: None + # webfilter-profile: None + # internet-service-src: None + # webcache: None + # utm-status: None + # vpn_src_node: {'subnet': None, 'host': None, 'seq': None} + # ippool: None + # service: None + # wccp: None + # auto-asic-offload: None + # dscp-value: None + # url-category: None + # capture-packet: None + # adom: ansible + # inbound: None + # internet-service: None + # profile-type: None + # ssl-mirror: None + # srcaddr-negate: None + # gtp-profile: None + # mms-profile: None + # send-deny-packet: None + # devices: None + # permit-any-host: None + # av-profile: None + # internet-service-src-negate: None + # service-negate: None + # rsso: None + # app-group: None + # tcp-mss-sender: None + # natinbound: None + # fixedport: None + # ssl-ssh-profile: None + # outbound: None + # spamfilter-profile: None + # application-list: None + # application: None + # dnsfilter-profile: None + # nat: None + # fsso: None + # vlan-cos-rev: None + # status: None + # dsri: None + # users: None + # voip-profile: None + # dstaddr-negate: None + # traffic-shaper-reverse: None + # internet-service-custom: None + # diffserv-reverse: None + # srcaddr: None + # ssh-filter-profile: None + # delay-tcp-npu-session: None + # icap-profile: None + # captive-portal-exempt: None + # vpn_dst_node: {'subnet': None, 'host': None, 'seq': None} + # app-category: None + # rtp-addr: None + # wsso: None + # tcp-mss-receiver: None + # dstaddr: None + # radius-mac-auth-bypass: None + # vpntunnel: None + ################################################## + ################################################## + # package_name: default + # wanopt-detection: None + # scan-botnet-connections: None + # profile-group: None + # dlp-sensor: None + # dscp-match: None + # replacemsg-override-group: None + # internet-service-negate: None + # np-acceleration: None + # learning-mode: None + # session-ttl: None + # ntlm-guest: None + # ips-sensor: None + # diffservcode-rev: None + # match-vip: None + # natip: None + # wanopt-peer: None + # traffic-shaper: None + # groups: None + # schedule-timeout: None + # name: Basic_IPv4_Policy_2 + # tcp-session-without-syn: None + # rtp-nat: None + # permit-stun-host: None + # natoutbound: None + # internet-service-src-custom: None + # mode: delete + # logtraffic: None + # ntlm: None + # auth-cert: None + # timeout-send-rst: None + # auth-redirect-addr: None + # ssl-mirror-intf: None + # identity-based-route: None + # diffservcode-forward: None + # wanopt-profile: None + # per-ip-shaper: None + # users: None + # diffserv-forward: None + # poolname: None + # comments: None + # label: None + # global-label: None + # firewall-session-dirty: None + # wanopt: None + # schedule: None + # internet-service-id: None + # auth-path: None + # vlan-cos-fwd: None + # custom-log-fields: None + # dstintf: None + # srcintf: None + # block-notification: None + # internet-service-src-id: None + # redirect-url: None + # waf-profile: None + # ntlm-enabled-browsers: None + # dscp-negate: None + # action: None + # fsso-agent-for-ntlm: None + # disclaimer: None + # vlan-filter: None + # dstaddr-negate: None + # logtraffic-start: None + # webcache-https: None + # webfilter-profile: None + # internet-service-src: None + # webcache: None + # utm-status: None + # vpn_src_node: {'subnet': None, 'host': None, 'seq': None} + # ippool: None + # service: None + # wccp: None + # auto-asic-offload: None + # dscp-value: None + # url-category: None + # capture-packet: None + # adom: ansible + # internet-service: None + # inbound: None + # profile-type: None + # ssl-mirror: None + # srcaddr-negate: None + # gtp-profile: None + # mms-profile: None + # send-deny-packet: None + # devices: None + # permit-any-host: None + # av-profile: None + # internet-service-src-negate: None + # service-negate: None + # rsso: None + # application-list: None + # app-group: None + # tcp-mss-sender: None + # natinbound: None + # fixedport: None + # ssl-ssh-profile: None + # outbound: None + # spamfilter-profile: None + # wanopt-passive-opt: None + # application: None + # dnsfilter-profile: None + # nat: None + # fsso: None + # vlan-cos-rev: None + # status: None + # dsri: None + # profile-protocol-options: None + # voip-profile: None + # policyid: 37 + # traffic-shaper-reverse: None + # internet-service-custom: None + # diffserv-reverse: None + # srcaddr: None + # dstaddr: None + # delay-tcp-npu-session: None + # icap-profile: None + # captive-portal-exempt: None + # vpn_dst_node: {'subnet': None, 'host': None, 'seq': None} + # app-category: None + # rtp-addr: None + # wsso: None + # tcp-mss-receiver: None + # ssh-filter-profile: None + # radius-mac-auth-bypass: None + # vpntunnel: None + ################################################## + + # Test using fixture 1 # + output = fmgr_fwpol_ipv4.fmgr_firewall_policy_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 2 # + output = fmgr_fwpol_ipv4.fmgr_firewall_policy_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True + # Test using fixture 3 # + output = fmgr_fwpol_ipv4.fmgr_firewall_policy_modify(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwpol_ipv4.fmgr_firewall_policy_modify(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_package.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_package.py new file mode 100644 index 000000000..f6bc82b71 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_fwpol_package.py @@ -0,0 +1,97 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_fwpol_package +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_fwpol_package.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_fwpol_package(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwpol_package.fmgr_fwpol_package(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_fmgr_fwpol_package_folder(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_fwpol_package.fmgr_fwpol_package_folder(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_ha.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_ha.py new file mode 100644 index 000000000..6620275cc --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_ha.py @@ -0,0 +1,216 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_ha +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_ha.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_set_ha_mode(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # fmgr_ha_peer_sn: None + # fmgr_ha_hb_threshold: 10 + # fmgr_ha_cluster_pw: fortinet + # fmgr_ha_peer_ipv6: None + # fmgr_ha_peer_status: None + # fmgr_ha_file_quota: 2048 + # fmgr_ha_cluster_id: 2 + # fmgr_ha_peer_ipv4: None + # fmgr_ha_hb_interval: 15 + # fmgr_ha_mode: master + # mode: set + ################################################## + ################################################## + # fmgr_ha_peer_sn: None + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: fortinet + # fmgr_ha_hb_interval: 5 + # fmgr_ha_cluster_id: 2 + # fmgr_ha_file_quota: 4096 + # fmgr_ha_peer_status: None + # fmgr_ha_peer_ipv4: None + # fmgr_ha_peer_ipv6: None + # fmgr_ha_mode: slave + # mode: set + ################################################## + ################################################## + # fmgr_ha_peer_sn: FMG-VMTM18001881 + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: fortinet + # fmgr_ha_peer_ipv6: None + # fmgr_ha_peer_status: enable + # fmgr_ha_file_quota: 4096 + # fmgr_ha_cluster_id: 2 + # fmgr_ha_peer_ipv4: 10.7.220.35 + # fmgr_ha_hb_interval: 5 + # fmgr_ha_mode: slave + # mode: set + ################################################## + ################################################## + # fmgr_ha_file_quota: 4096 + # fmgr_ha_cluster_pw: None + # fmgr_ha_peer_sn: None + # fmgr_ha_hb_interval: 5 + # fmgr_ha_cluster_id: 1 + # fmgr_ha_mode: standalone + # fmgr_ha_peer_status: None + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_peer_ipv4: None + # fmgr_ha_peer_ipv6: None + # mode: set + ################################################## + + # Test using fixture 1 # + output = fmgr_ha.fmgr_set_ha_mode(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_ha.fmgr_set_ha_mode(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_ha.fmgr_set_ha_mode(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_ha.fmgr_set_ha_mode(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_fmgr_get_ha_peer_list(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # fmgr_ha_peer_sn: FMG-VMTM18001882 + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: None + # fmgr_ha_peer_ipv6: None + # fmgr_ha_peer_status: enable + # fmgr_ha_file_quota: 4096 + # fmgr_ha_cluster_id: 1 + # fmgr_ha_peer_ipv4: 10.7.220.36 + # fmgr_ha_hb_interval: 5 + # fmgr_ha_mode: None + # mode: get + ################################################## + ################################################## + # fmgr_ha_peer_sn: FMG-VMTM18001881 + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: fortinet + # fmgr_ha_hb_interval: 5 + # fmgr_ha_cluster_id: 2 + # fmgr_ha_file_quota: 4096 + # fmgr_ha_peer_status: enable + # fmgr_ha_peer_ipv4: 10.7.220.35 + # fmgr_ha_peer_ipv6: None + # fmgr_ha_mode: slave + # mode: get + ################################################## + + # Test using fixture 1 # + output = fmgr_ha.fmgr_get_ha_peer_list(fmg_instance) + assert isinstance(output['raw_response'], list) is True + # Test using fixture 2 # + output = fmgr_ha.fmgr_get_ha_peer_list(fmg_instance) + assert isinstance(output['raw_response'], list) is True + + +def test_fmgr_set_ha_peer(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # fmgr_ha_peer_sn: FMG-VMTM18001882 + # next_peer_id: 2 + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: None + # fmgr_ha_peer_ipv6: None + # fmgr_ha_peer_status: enable + # fmgr_ha_file_quota: 4096 + # fmgr_ha_cluster_id: 1 + # peer_id: 1 + # fmgr_ha_peer_ipv4: 10.7.220.36 + # fmgr_ha_hb_interval: 5 + # fmgr_ha_mode: None + # mode: set + ################################################## + ################################################## + # fmgr_ha_peer_sn: FMG-VMTM18001881 + # next_peer_id: 1 + # fmgr_ha_hb_threshold: 3 + # fmgr_ha_cluster_pw: fortinet + # fmgr_ha_hb_interval: 5 + # fmgr_ha_cluster_id: 2 + # fmgr_ha_file_quota: 4096 + # fmgr_ha_peer_status: enable + # peer_id: 1 + # fmgr_ha_peer_ipv4: 10.7.220.35 + # fmgr_ha_peer_ipv6: None + # fmgr_ha_mode: slave + # mode: set + ################################################## + + # Test using fixture 1 # + output = fmgr_ha.fmgr_set_ha_peer(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_ha.fmgr_set_ha_peer(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_provisioning.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_provisioning.py new file mode 100644 index 000000000..96325db1b --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_provisioning.py @@ -0,0 +1,64 @@ +# (c) 2016 Red Hat Inc. +# +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import pytest + +pytestmark = [] +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_provisioning + from .fortimanager_module import TestFortimanagerModule + from ansible_collections.community.fortios.tests.unit.plugins.modules.utils import set_module_args +except ImportError: + pytestmark.append(pytest.mark.skip("Could not load required modules for testing")) + +try: + from pyFMG.fortimgr import FortiManager +except ImportError: + pytestmark.append(pytest.mark.skip("FortiManager tests require pyFMG package")) + + +class TestFmgrProvisioningModule(TestFortimanagerModule): + + module = fmgr_provisioning + + def test_fmg_script_fail_connect(self): + set_module_args(dict(host='1.1.1.1', username='admin', password='admin', adom='root', + vdom='root', policy_package='root', name='FGT1', serial='FGVM000000117992', + platform='FortiGate-VM64', os_version='5.0', minor_release='6', + patch_release='0', os_type='fos')) + result = self.execute_module(failed=True) + self.assertEqual(result['msg'], 'Connection to FortiManager Failed') + + def test_fmg_script_login_fail_host(self): + set_module_args(dict(username='admin', password='admin', adom='root', + vdom='root', policy_package='root', name='FGT1', serial='FGVM000000117992', + platform='FortiGate-VM64', os_version='5.0', minor_release='6', + patch_release='0', os_type='fos')) + result = self.execute_module(failed=True) + self.assertEqual(result['msg'], 'missing required arguments: host') + + def test_fmg_script_login_fail_username(self): + set_module_args(dict(host='1.1.1.1', password='admin', adom='root', + vdom='root', policy_package='root', name='FGT1', serial='FGVM000000117992', + platform='FortiGate-VM64', os_version='5.0', minor_release='6', + patch_release='0', os_type='fos')) + result = self.execute_module(failed=True) + self.assertEqual(result['msg'], 'Host and username are required for connection') diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_query.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_query.py new file mode 100644 index 000000000..a5470b680 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_query.py @@ -0,0 +1,106 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_query +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_query.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_get_custom(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # custom_endpoint: /dvmdb/adom/ansible/script + # device_ip: None + # device_unique_name: None + # task_id: None + # adom: ansible + # nodes: None + # object: custom + # device_serial: None + # custom_dict: {'type': 'cli'} + # mode: get + ################################################## + + # Test using fixture 1 # + output = fmgr_query.fmgr_get_custom(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], list) is True + + +def test_fmgr_get_task_status(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # custom_endpoint: None + # object: task + # task_id: 247 + # adom: ansible + # device_ip: None + # custom_dict: None + # device_unique_name: None + # nodes: None + # device_serial: None + # mode: get + ################################################## + + # Test using fixture 1 # + output = fmgr_query.fmgr_get_task_status(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_script.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_script.py new file mode 100644 index 000000000..c834414aa --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_script.py @@ -0,0 +1,129 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_script +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_script.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_set_script(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # script_content: get system status + # adom: ansible + # script_scope: None + # script_name: TestScript + # script_target: remote_device + # mode: set + # script_description: Create by Ansible + # script_package: None + # vdom: root + # script_type: cli + ################################################## + + # Test using fixture 1 # + output = fmgr_script.set_script(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_delete_script(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # vdom: root + # script_target: None + # script_content: None + # adom: ansible + # script_description: None + # script_package: None + # mode: delete + # script_scope: None + # script_name: TestScript + # script_type: None + ################################################## + + # Test using fixture 1 # + output = fmgr_script.delete_script(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + + +def test_execute_script(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # script_content: None + # adom: ansible + # script_scope: FGT1 + # script_name: TestScript + # script_target: None + # mode: exec + # script_description: None + # script_package: None + # vdom: root + # script_type: None + ################################################## + + # Test using fixture 1 # + output = fmgr_script.execute_script(fmg_instance, fixture_data[0]['paramgram_used']) + assert isinstance(output['raw_response'], dict) is True diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_appctrl.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_appctrl.py new file mode 100644 index 000000000..0af21b25c --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_appctrl.py @@ -0,0 +1,78 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_appctrl +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_appctrl.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_application_list_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_appctrl.fmgr_application_list_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_appctrl.fmgr_application_list_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 3 # + output = fmgr_secprof_appctrl.fmgr_application_list_modify(fmg_instance, fixture_data[2]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 4 # + output = fmgr_secprof_appctrl.fmgr_application_list_modify(fmg_instance, fixture_data[3]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_av.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_av.py new file mode 100644 index 000000000..f3e0d5aec --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_av.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_av +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_av.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_antivirus_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_av.fmgr_antivirus_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_av.fmgr_antivirus_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_dns.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_dns.py new file mode 100644 index 000000000..6e429fd24 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_dns.py @@ -0,0 +1,88 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_dns +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_dns.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_dnsfilter_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # comment: Created by Ansible Module TEST + # ftgd-dns: {'options': None, 'filters': {'action': None, 'category': None, 'log': None}} + # adom: root + # youtube-restrict: None + # sdns-domain-log: None + # block-botnet: None + # external-ip-blocklist: None + # block-action: block + # name: Ansible_DNS_Profile + # redirect-portal: None + # sdns-ftgd-err-log: None + # safe-search: None + # domain-filter: {'domain-filter-table': None} + # log-all-domain: None + # mode: set + ################################################## + + # Test using fixture 1 # + output = fmgr_secprof_dns.fmgr_dnsfilter_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ips.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ips.py new file mode 100644 index 000000000..487807523 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ips.py @@ -0,0 +1,69 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_ips +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_ips.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_ips_sensor_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_ips.fmgr_ips_sensor_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_profile_group.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_profile_group.py new file mode 100644 index 000000000..5c8fadde8 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_profile_group.py @@ -0,0 +1,112 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_profile_group +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_profile_group.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_firewall_profile_group_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + # Fixture sets used:########################### + + ################################################## + # ssl-ssh-profile: None + # waf-profile: None + # adom: root + # webfilter-profile: None + # profile-protocol-options: None + # application-list: None + # icap-profile: None + # voip-profile: None + # ips-sensor: None + # dnsfilter-profile: None + # av-profile: None + # spamfilter-profile: None + # dlp-sensor: None + # mode: delete + # ssh-filter-profile: None + # mms-profile: None + # name: Ansible_TEST_Profile_Group + ################################################## + ################################################## + # ssl-ssh-profile: None + # application-list: None + # waf-profile: None + # adom: root + # webfilter-profile: None + # ips-sensor: None + # spamfilter-profile: None + # icap-profile: None + # dnsfilter-profile: None + # name: Ansible_TEST_Profile_Group + # voip-profile: None + # av-profile: Ansible_AV_Profile + # mode: set + # dlp-sensor: None + # mms-profile: None + # ssh-filter-profile: None + # profile-protocol-options: default + ################################################## + + # Test using fixture 1 # + output = fmgr_secprof_profile_group.fmgr_firewall_profile_group_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == -3 + # Test using fixture 2 # + output = fmgr_secprof_profile_group.fmgr_firewall_profile_group_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == -10131 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_proxy.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_proxy.py new file mode 100644 index 000000000..61579327c --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_proxy.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_proxy +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_proxy.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_web_proxy_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_proxy.fmgr_web_proxy_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_proxy.fmgr_web_proxy_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_spam.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_spam.py new file mode 100644 index 000000000..08e382b87 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_spam.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_spam +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_spam.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_spamfilter_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_spam.fmgr_spamfilter_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_spam.fmgr_spamfilter_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ssl_ssh.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ssl_ssh.py new file mode 100644 index 000000000..0a0fa7bd2 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_ssl_ssh.py @@ -0,0 +1,69 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_ssl_ssh +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_ssl_ssh.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_firewall_ssl_ssh_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + output = fmgr_secprof_ssl_ssh.fmgr_firewall_ssl_ssh_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + output = fmgr_secprof_ssl_ssh.fmgr_firewall_ssl_ssh_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_voip.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_voip.py new file mode 100644 index 000000000..a13c654e5 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_voip.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_voip +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_voip.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_voip_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_voip.fmgr_voip_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_voip.fmgr_voip_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_waf.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_waf.py new file mode 100644 index 000000000..10b21a4c5 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_waf.py @@ -0,0 +1,69 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_waf +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_waf.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_waf_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + output = fmgr_secprof_waf.fmgr_waf_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + output = fmgr_secprof_waf.fmgr_waf_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_wanopt.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_wanopt.py new file mode 100644 index 000000000..f6e2785b2 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_wanopt.py @@ -0,0 +1,72 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_wanopt +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_wanopt.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_wanopt_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + + # Test using fixture 1 # + output = fmgr_secprof_wanopt.fmgr_wanopt_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 + # Test using fixture 2 # + output = fmgr_secprof_wanopt.fmgr_wanopt_profile_modify(fmg_instance, fixture_data[1]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_web.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_web.py new file mode 100644 index 000000000..56bdd9a4a --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/test_fmgr_secprof_web.py @@ -0,0 +1,67 @@ +# Copyright 2018 Fortinet, Inc. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <https://www.gnu.org/licenses/>. + +# Make coding more python3-ish +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os +import json +from ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager import FortiManagerHandler +import pytest + +try: + from ansible_collections.community.fortios.plugins.modules import fmgr_secprof_web +except ImportError: + pytest.skip("Could not load required modules for testing", allow_module_level=True) + + +def load_fixtures(): + fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format( + filename=os.path.splitext(os.path.basename(__file__))[0]) + try: + with open(fixture_path, "r") as fixture_file: + fixture_data = json.load(fixture_file) + except IOError: + return [] + return [fixture_data] + + +@pytest.fixture(autouse=True) +def module_mock(mocker): + connection_class_mock = mocker.patch('ansible.module_utils.basic.AnsibleModule') + return connection_class_mock + + +@pytest.fixture(autouse=True) +def connection_mock(mocker): + connection_class_mock = mocker.patch('ansible_collections.community.fortios.plugins.modules.fmgr_secprof_web.Connection') + return connection_class_mock + + +@pytest.fixture(scope="function", params=load_fixtures()) +def fixture_data(request): + func_name = request.function.__name__.replace("test_", "") + return request.param.get(func_name, None) + + +fmg_instance = FortiManagerHandler(connection_mock, module_mock) + + +def test_fmgr_webfilter_profile_modify(fixture_data, mocker): + mocker.patch('ansible_collections.fortinet.fortios.plugins.module_utils.fortimanager.fortimanager.FortiManagerHandler.process_request', + side_effect=fixture_data) + output = fmgr_secprof_web.fmgr_webfilter_profile_modify(fmg_instance, fixture_data[0]['paramgram_used']) + assert output['raw_response']['status']['code'] == 0 diff --git a/ansible_collections/community/fortios/tests/unit/plugins/modules/utils.py b/ansible_collections/community/fortios/tests/unit/plugins/modules/utils.py new file mode 100644 index 000000000..66d2bcd2f --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/plugins/modules/utils.py @@ -0,0 +1,50 @@ +from __future__ import absolute_import, division, print_function +__metaclass__ = type + +import json + +from ansible_collections.community.fortios.tests.unit.compat import unittest +from ansible_collections.community.fortios.tests.unit.compat.mock import patch +from ansible.module_utils import basic +from ansible.module_utils._text import to_bytes + + +def set_module_args(args): + if '_ansible_remote_tmp' not in args: + args['_ansible_remote_tmp'] = '/tmp' + if '_ansible_keep_remote_files' not in args: + args['_ansible_keep_remote_files'] = False + + args = json.dumps({'ANSIBLE_MODULE_ARGS': args}) + basic._ANSIBLE_ARGS = to_bytes(args) + + +class AnsibleExitJson(Exception): + pass + + +class AnsibleFailJson(Exception): + pass + + +def exit_json(*args, **kwargs): + if 'changed' not in kwargs: + kwargs['changed'] = False + raise AnsibleExitJson(kwargs) + + +def fail_json(*args, **kwargs): + kwargs['failed'] = True + raise AnsibleFailJson(kwargs) + + +class ModuleTestCase(unittest.TestCase): + + def setUp(self): + self.mock_module = patch.multiple(basic.AnsibleModule, exit_json=exit_json, fail_json=fail_json) + self.mock_module.start() + self.mock_sleep = patch('time.sleep') + self.mock_sleep.start() + set_module_args({}) + self.addCleanup(self.mock_module.stop) + self.addCleanup(self.mock_sleep.stop) diff --git a/ansible_collections/community/fortios/tests/unit/requirements.txt b/ansible_collections/community/fortios/tests/unit/requirements.txt new file mode 100644 index 000000000..9c9a11414 --- /dev/null +++ b/ansible_collections/community/fortios/tests/unit/requirements.txt @@ -0,0 +1,4 @@ +unittest2 ; python_version <= '2.6' + +# requirements for FortiManager modules +pyFMG |