New FortiManager Module: fmgr_secprof_voip (#53030)

* Auto Commit for: fmgr_secprof_voip

* Auto Commit for: fmgr_secprof_voip
pull/53267/head
ftntcorecse 5 years ago committed by Nilashish Chakraborty
parent 8888faf716
commit 421a5c4c91

@ -0,0 +1,257 @@
{
"fmgr_voip_profile_modify": [
{
"paramgram_used": {
"comment": null,
"sip": {
"block-publish": null,
"ssl-max-version": null,
"malformed-header-rack": null,
"rtp": null,
"publish-rate": null,
"ssl-client-renegotiation": null,
"malformed-header-from": null,
"open-contact-pinhole": null,
"ssl-client-certificate": null,
"malformed-header-p-asserted-identity": null,
"rfc2543-branch": null,
"malformed-header-via": null,
"notify-rate": null,
"preserve-override": null,
"block-info": null,
"options-rate": null,
"block-update": null,
"max-body-length": null,
"block-subscribe": null,
"ssl-pfs": null,
"ssl-send-empty-frags": null,
"ssl-auth-client": null,
"malformed-header-record-route": null,
"refer-rate": null,
"info-rate": null,
"open-record-route-pinhole": null,
"register-rate": null,
"unknown-header": null,
"block-unknown": null,
"ssl-server-certificate": null,
"block-invite": null,
"strict-register": null,
"max-dialogs": null,
"block-cancel": null,
"no-sdp-fixup": null,
"open-register-pinhole": null,
"block-notify": null,
"max-idle-dialogs": null,
"malformed-request-line": null,
"block-long-lines": null,
"log-violations": null,
"ssl-min-version": null,
"provisional-invite-expiry-time": null,
"block-prack": null,
"malformed-header-max-forwards": null,
"block-message": null,
"malformed-header-call-id": null,
"invite-rate": null,
"cancel-rate": null,
"register-contact-trace": null,
"block-register": null,
"ssl-mode": null,
"prack-rate": null,
"block-bye": null,
"ssl-algorithm": null,
"malformed-header-to": null,
"block-geo-red-options": null,
"call-keepalive": null,
"message-rate": null,
"malformed-header-expires": null,
"block-options": null,
"log-call-summary": null,
"hnt-restrict-source-ip": null,
"ssl-auth-server": null,
"contact-fixup": null,
"ack-rate": null,
"malformed-header-allow": null,
"malformed-header-sdp-v": null,
"malformed-header-sdp-t": null,
"malformed-header-contact": null,
"malformed-header-sdp-s": null,
"hosted-nat-traversal": null,
"subscribe-rate": null,
"malformed-header-content-length": null,
"malformed-header-sdp-z": null,
"malformed-header-route": null,
"malformed-header-sdp-b": null,
"malformed-header-sdp-c": null,
"malformed-header-sdp-a": null,
"malformed-header-sdp-o": null,
"malformed-header-sdp-m": null,
"malformed-header-sdp-k": null,
"malformed-header-sdp-i": null,
"status": null,
"open-via-pinhole": null,
"bye-rate": null,
"block-ack": null,
"malformed-header-sdp-r": null,
"block-refer": null,
"ips-rtp": null,
"malformed-header-content-type": null,
"nat-trace": null,
"malformed-header-rseq": null,
"max-line-length": null,
"update-rate": null,
"malformed-header-cseq": null
},
"name": "Ansible_VOIP_Profile",
"adom": "root",
"sccp": {
"status": null,
"log-call-summary": null,
"block-mcast": null,
"max-calls": null,
"verify-header": null,
"log-violations": null
},
"mode": "delete"
},
"datagram_sent": {},
"raw_response": {
"status": {
"message": "OK",
"code": 0
},
"url": "/pm/config/adom/root/obj/voip/profile/Ansible_VOIP_Profile"
},
"post_method": "delete"
},
{
"raw_response": {
"status": {
"message": "OK",
"code": 0
},
"url": "/pm/config/adom/root/obj/voip/profile"
},
"datagram_sent": {
"comment": "Created by Ansible",
"sccp": {
"status": "enable",
"log-call-summary": "enable",
"log-violations": "enable",
"block-mcast": "enable"
},
"name": "Ansible_VOIP_Profile"
},
"paramgram_used": {
"comment": "Created by Ansible",
"sip": {
"block-publish": null,
"ssl-max-version": null,
"malformed-header-rack": null,
"rtp": null,
"publish-rate": null,
"ssl-client-renegotiation": null,
"malformed-header-from": null,
"ssl-client-certificate": null,
"malformed-header-p-asserted-identity": null,
"info-rate": null,
"malformed-header-via": null,
"notify-rate": null,
"preserve-override": null,
"block-info": null,
"options-rate": null,
"block-update": null,
"max-body-length": null,
"block-subscribe": null,
"ssl-pfs": null,
"ssl-send-empty-frags": null,
"ssl-auth-client": null,
"malformed-header-record-route": null,
"refer-rate": null,
"open-record-route-pinhole": null,
"register-rate": null,
"unknown-header": null,
"block-unknown": null,
"ssl-server-certificate": null,
"block-invite": null,
"malformed-request-line": null,
"max-dialogs": null,
"block-cancel": null,
"no-sdp-fixup": null,
"open-register-pinhole": null,
"block-options": null,
"max-idle-dialogs": null,
"strict-register": null,
"block-long-lines": null,
"log-violations": null,
"ssl-min-version": null,
"provisional-invite-expiry-time": null,
"rfc2543-branch": null,
"block-ack": null,
"malformed-header-max-forwards": null,
"block-message": null,
"malformed-header-call-id": null,
"invite-rate": null,
"cancel-rate": null,
"register-contact-trace": null,
"block-refer": null,
"block-register": null,
"ssl-mode": null,
"prack-rate": null,
"block-bye": null,
"ssl-algorithm": null,
"malformed-header-to": null,
"block-geo-red-options": null,
"call-keepalive": null,
"message-rate": null,
"malformed-header-expires": null,
"log-call-summary": null,
"hnt-restrict-source-ip": null,
"ssl-auth-server": null,
"contact-fixup": null,
"ack-rate": null,
"malformed-header-allow": null,
"malformed-header-sdp-v": null,
"malformed-header-sdp-t": null,
"malformed-header-contact": null,
"malformed-header-sdp-s": null,
"hosted-nat-traversal": null,
"subscribe-rate": null,
"malformed-header-content-length": null,
"malformed-header-sdp-z": null,
"malformed-header-route": null,
"block-notify": null,
"malformed-header-sdp-b": null,
"malformed-header-sdp-c": null,
"malformed-header-sdp-a": null,
"malformed-header-sdp-o": null,
"malformed-header-sdp-m": null,
"malformed-header-sdp-k": null,
"malformed-header-sdp-i": null,
"status": null,
"open-via-pinhole": null,
"bye-rate": null,
"block-prack": null,
"malformed-header-sdp-r": null,
"open-contact-pinhole": null,
"ips-rtp": null,
"malformed-header-content-type": null,
"nat-trace": null,
"malformed-header-rseq": null,
"max-line-length": null,
"update-rate": null,
"malformed-header-cseq": null
},
"name": "Ansible_VOIP_Profile",
"adom": "root",
"sccp": {
"status": "enable",
"log-call-summary": "enable",
"log-violations": "enable",
"block-mcast": "enable"
},
"mode": "set"
},
"post_method": "set"
}
]
}

@ -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.module_utils.network.fortimanager.fortimanager import FortiManagerHandler
import pytest
try:
from ansible.modules.network.fortimanager 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.modules.network.fortimanager.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.module_utils.network.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
Loading…
Cancel
Save