Auto Commit for: fmgr_secprof_av (#53022)

pull/53316/head
ftntcorecse 6 years ago committed by Nilashish Chakraborty
parent 73e6f15d64
commit 55e431de54

File diff suppressed because it is too large Load Diff

@ -1,26 +1,27 @@
{
"fmgr_antivirus_profile_addSetDelete": [
"fmgr_antivirus_profile_modify": [
{
"raw_response": {
"status": {
"message": "Object does not exist",
"code": -3
},
"url": "/pm/config/adom/root/obj/antivirus/profile/Ansible_AV_Profile"
},
"paramgram_used": {
"comment": null,
"av-block-log": null,
"smtp": {
"executables": null,
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
},
"extended-log": null,
"analytics-db": null,
"analytics-wl-filetype": null,
"av-virus-log": null,
"content-disarm": {
"pdf-act-movie": null,
"office-hylink": null,
"pdf-act-gotor": null,
"pdf-act-java": null,
"original-file-destination": null,
"office-hylink": null,
"cover-page": null,
"pdf-act-sound": null,
"detect-only": null,
"office-embed": null,
@ -31,14 +32,14 @@
"office-macro": null,
"pdf-act-form": null,
"pdf-act-launch": null,
"cover-page": null
"pdf-act-movie": null
},
"ftp": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"archive-block": null,
"emulator": null,
"archive-block": null
"archive-log": null,
"outbreak-prevention": null,
"options": null
},
"mapi": {
"executables": null,
@ -50,31 +51,21 @@
},
"analytics-max-upload": null,
"nntp": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"archive-block": null,
"emulator": null,
"archive-block": null
"archive-log": null,
"outbreak-prevention": null,
"options": null
},
"smb": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"archive-block": null,
"emulator": null,
"archive-block": null
},
"analytics-bl-filetype": null,
"http": {
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
},
"adom": "root",
"smtp": {
"executables": null,
"analytics-bl-filetype": null,
"http": {
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
@ -82,6 +73,8 @@
"content-disarm": null,
"options": null
},
"adom": "ansible",
"av-block-log": null,
"pop3": {
"executables": null,
"archive-log": null,
@ -102,8 +95,8 @@
"content-disarm": null,
"options": null
},
"name": "Ansible_AV_Profile",
"replacemsg-group": null,
"name": "Ansible_AV_Profile",
"scan-mode": null,
"nac-quar": {
"infected": null,
@ -113,29 +106,15 @@
"mode": "delete",
"mobile-malware-db": null
},
"post_method": "delete"
},
{
"paramgram_used": {
"comment": "Created by Ansible Module TEST",
"name": "Ansible_AV_Profile",
"scan-mode": "full",
"av-block-log": "enable",
"inspection-mode": "proxy",
"av-virus-log": "enable",
"ftgd-analytics": "everything",
"mobile-malware-db": "enable",
"mode": "delete",
"adom": "root"
},
"datagram_sent": {},
"raw_response": {
"status": {
"message": "OK",
"code": 0
},
"url": "/pm/config/adom/root/obj/antivirus/profile"
"url": "/pm/config/adom/ansible/obj/antivirus/profile/Ansible_AV_Profile"
},
"post_method": "set"
"post_method": "delete"
},
{
"raw_response": {
@ -143,130 +122,32 @@
"message": "OK",
"code": 0
},
"url": "/pm/config/adom/root/obj/antivirus/profile/Ansible_AV_Profile"
"url": "/pm/config/adom/ansible/obj/antivirus/profile"
},
"paramgram_used": {
"comment": null,
"av-block-log": null,
"extended-log": null,
"analytics-db": null,
"analytics-wl-filetype": null,
"av-virus-log": null,
"content-disarm": {
"pdf-act-movie": null,
"pdf-act-gotor": null,
"office-macro": null,
"pdf-act-java": null,
"original-file-destination": null,
"office-hylink": null,
"pdf-act-sound": null,
"detect-only": null,
"office-embed": null,
"office-linked": null,
"pdf-javacode": null,
"pdf-hyperlink": null,
"cover-page": null,
"pdf-embedfile": null,
"pdf-act-form": null,
"pdf-act-launch": null
},
"datagram_sent": {
"comment": "Created by Ansible Module TEST",
"ftp": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"emulator": null,
"archive-block": null
},
"mapi": {
"executables": null,
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"options": null
},
"analytics-max-upload": null,
"nntp": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"emulator": null,
"archive-block": null
},
"smb": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"emulator": null,
"archive-block": null
},
"analytics-bl-filetype": null,
"http": {
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
},
"adom": "root",
"smtp": {
"executables": null,
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
},
"pop3": {
"executables": null,
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
},
"inspection-mode": null,
"ftgd-analytics": null,
"imap": {
"executables": null,
"archive-log": null,
"outbreak-prevention": null,
"emulator": null,
"archive-block": null,
"content-disarm": null,
"options": null
"outbreak-prevention": "files",
"options": "scan",
"archive-log": "timeout",
"emulator": "disable",
"archive-block": "encrypted"
},
"name": "Ansible_AV_Profile",
"replacemsg-group": null,
"scan-mode": null,
"nac-quar": {
"infected": null,
"log": null,
"expiry": null
},
"mode": "delete",
"mobile-malware-db": null
},
"post_method": "delete"
},
{
"raw_response": {
"status": {
"message": "used",
"code": -10015
},
"url": "/pm/config/adom/root/obj/antivirus/profile/Ansible_AV_Profile"
"scan-mode": "full",
"av-block-log": "enable",
"inspection-mode": "proxy",
"av-virus-log": "enable",
"ftgd-analytics": "everything",
"mobile-malware-db": "enable"
},
"paramgram_used": {
"comment": null,
"av-block-log": null,
"comment": "Created by Ansible Module TEST",
"av-block-log": "enable",
"extended-log": null,
"analytics-db": null,
"analytics-wl-filetype": null,
"av-virus-log": null,
"av-virus-log": "enable",
"content-disarm": {
"pdf-act-movie": null,
"pdf-act-gotor": null,
@ -286,11 +167,11 @@
"pdf-act-launch": null
},
"ftp": {
"outbreak-prevention": null,
"options": null,
"archive-log": null,
"emulator": null,
"archive-block": null
"outbreak-prevention": "files",
"options": "scan",
"archive-log": "timeout",
"emulator": "disable",
"archive-block": "encrypted"
},
"smtp": {
"executables": null,
@ -333,8 +214,8 @@
"content-disarm": null,
"options": null
},
"adom": "root",
"scan-mode": null,
"adom": "ansible",
"scan-mode": "full",
"pop3": {
"executables": null,
"archive-log": null,
@ -344,8 +225,8 @@
"content-disarm": null,
"options": null
},
"inspection-mode": null,
"ftgd-analytics": null,
"inspection-mode": "proxy",
"ftgd-analytics": "everything",
"imap": {
"executables": null,
"archive-log": null,
@ -362,10 +243,10 @@
"log": null,
"expiry": null
},
"mode": "delete",
"mobile-malware-db": null
"mode": "set",
"mobile-malware-db": "enable"
},
"post_method": "delete"
"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_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.modules.network.fortimanager.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.module_utils.network.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
Loading…
Cancel
Save