mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
FortiManager Plugin Module Conversion: fmgr_secprof_profile_group (#52772)
* Auto Commit for: fmgr_secprof_profile_group * Auto Commit for: fmgr_secprof_profile_group
This commit is contained in:
committed by
Nilashish Chakraborty
parent
c37f6bed1c
commit
e8c983155c
@@ -1,62 +1,68 @@
|
||||
{
|
||||
"fmgr_firewall_profile_group_addsetdelete": [
|
||||
{
|
||||
"paramgram_used": {
|
||||
"ssl-ssh-profile": null,
|
||||
"waf-profile": null,
|
||||
"adom": "root",
|
||||
"webfilter-profile": null,
|
||||
"profile-protocol-options": null,
|
||||
"application-list": null,
|
||||
"icap-profile": null,
|
||||
"voip-profile": null,
|
||||
"ips-sensor": null,
|
||||
"dnsfilter-profile": null,
|
||||
"av-profile": null,
|
||||
"spamfilter-profile": null,
|
||||
"dlp-sensor": null,
|
||||
"mode": "delete",
|
||||
"ssh-filter-profile": null,
|
||||
"mms-profile": null,
|
||||
"name": "Ansible_TEST_Profile_Group"
|
||||
},
|
||||
"raw_response": {
|
||||
"status": {
|
||||
"message": "OK",
|
||||
"code": 0
|
||||
},
|
||||
"url": "/pm/config/adom/root/obj/firewall/profile-group/Ansible_TEST_Profile_Group"
|
||||
},
|
||||
"post_method": "delete"
|
||||
},
|
||||
{
|
||||
"raw_response": {
|
||||
"status": {
|
||||
"message": "OK",
|
||||
"code": 0
|
||||
},
|
||||
"url": "/pm/config/adom/root/obj/firewall/profile-group"
|
||||
},
|
||||
"paramgram_used": {
|
||||
"ssl-ssh-profile": null,
|
||||
"application-list": null,
|
||||
"waf-profile": null,
|
||||
"adom": "root",
|
||||
"webfilter-profile": null,
|
||||
"ips-sensor": null,
|
||||
"spamfilter-profile": null,
|
||||
"icap-profile": null,
|
||||
"dnsfilter-profile": null,
|
||||
"name": "Ansible_TEST_Profile_Group",
|
||||
"voip-profile": null,
|
||||
"av-profile": "Ansible_AV_Profile",
|
||||
"mode": "set",
|
||||
"dlp-sensor": null,
|
||||
"mms-profile": null,
|
||||
"ssh-filter-profile": null,
|
||||
"profile-protocol-options": "default"
|
||||
},
|
||||
"post_method": "set"
|
||||
}
|
||||
]
|
||||
"fmgr_firewall_profile_group_modify": [
|
||||
{
|
||||
"paramgram_used": {
|
||||
"ssl-ssh-profile": null,
|
||||
"waf-profile": null,
|
||||
"adom": "root",
|
||||
"webfilter-profile": null,
|
||||
"profile-protocol-options": null,
|
||||
"application-list": null,
|
||||
"icap-profile": null,
|
||||
"voip-profile": null,
|
||||
"ips-sensor": null,
|
||||
"dnsfilter-profile": null,
|
||||
"av-profile": null,
|
||||
"spamfilter-profile": null,
|
||||
"dlp-sensor": null,
|
||||
"mode": "delete",
|
||||
"ssh-filter-profile": null,
|
||||
"mms-profile": null,
|
||||
"name": "Ansible_TEST_Profile_Group"
|
||||
},
|
||||
"datagram_sent": {},
|
||||
"raw_response": {
|
||||
"status": {
|
||||
"message": "Object does not exist",
|
||||
"code": -3
|
||||
},
|
||||
"url": "/pm/config/adom/root/obj/firewall/profile-group/Ansible_TEST_Profile_Group"
|
||||
},
|
||||
"post_method": "delete"
|
||||
},
|
||||
{
|
||||
"raw_response": {
|
||||
"status": {
|
||||
"message": "datasrc invalid. object: firewall profile-group av-profile Ansible_TEST_Profile_Group. detail: Ansible_AV_Profile. solution: data not exist",
|
||||
"code": -10131
|
||||
},
|
||||
"url": "/pm/config/adom/root/obj/firewall/profile-group"
|
||||
},
|
||||
"datagram_sent": {
|
||||
"av-profile": "Ansible_AV_Profile",
|
||||
"profile-protocol-options": "default",
|
||||
"name": "Ansible_TEST_Profile_Group"
|
||||
},
|
||||
"paramgram_used": {
|
||||
"ssl-ssh-profile": null,
|
||||
"application-list": null,
|
||||
"waf-profile": null,
|
||||
"adom": "root",
|
||||
"webfilter-profile": null,
|
||||
"ips-sensor": null,
|
||||
"spamfilter-profile": null,
|
||||
"icap-profile": null,
|
||||
"dnsfilter-profile": null,
|
||||
"name": "Ansible_TEST_Profile_Group",
|
||||
"voip-profile": null,
|
||||
"av-profile": "Ansible_AV_Profile",
|
||||
"mode": "set",
|
||||
"dlp-sensor": null,
|
||||
"mms-profile": null,
|
||||
"ssh-filter-profile": null,
|
||||
"profile-protocol-options": "default"
|
||||
},
|
||||
"post_method": "set"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ __metaclass__ = type
|
||||
|
||||
import os
|
||||
import json
|
||||
from pyFMG.fortimgr import FortiManager
|
||||
from ansible.module_utils.network.fortimanager.fortimanager import FortiManagerHandler
|
||||
import pytest
|
||||
|
||||
try:
|
||||
@@ -27,8 +27,6 @@ try:
|
||||
except ImportError:
|
||||
pytest.skip("Could not load required modules for testing", allow_module_level=True)
|
||||
|
||||
fmg_instance = FortiManager("1.1.1.1", "admin", "")
|
||||
|
||||
|
||||
def load_fixtures():
|
||||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') + "/{filename}.json".format(
|
||||
@@ -41,14 +39,30 @@ def load_fixtures():
|
||||
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.modules.network.fortimanager.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)
|
||||
|
||||
|
||||
def test_fmgr_firewall_profile_group_addsetdelete(fixture_data, mocker):
|
||||
mocker.patch("pyFMG.fortimgr.FortiManager._post_request", side_effect=fixture_data)
|
||||
fmg_instance = FortiManagerHandler(connection_mock, module_mock)
|
||||
|
||||
|
||||
def test_fmgr_firewall_profile_group_modify(fixture_data, mocker):
|
||||
mocker.patch("ansible.module_utils.network.fortimanager.fortimanager.FortiManagerHandler.process_request",
|
||||
side_effect=fixture_data)
|
||||
# Fixture sets used:###########################
|
||||
|
||||
##################################################
|
||||
@@ -91,10 +105,8 @@ def test_fmgr_firewall_profile_group_addsetdelete(fixture_data, mocker):
|
||||
##################################################
|
||||
|
||||
# Test using fixture 1 #
|
||||
output = fmgr_secprof_profile_group.fmgr_firewall_profile_group_addsetdelete(fmg_instance,
|
||||
fixture_data[0]['paramgram_used'])
|
||||
assert output['raw_response']['status']['code'] == 0
|
||||
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_addsetdelete(fmg_instance,
|
||||
fixture_data[1]['paramgram_used'])
|
||||
assert output['raw_response']['status']['code'] == 0
|
||||
output = fmgr_secprof_profile_group.fmgr_firewall_profile_group_modify(fmg_instance, fixture_data[1]['paramgram_used'])
|
||||
assert output['raw_response']['status']['code'] == -10131
|
||||
|
||||
Reference in New Issue
Block a user