Adds fixes to bigip_asm_policy (#33440)
Integrates some upstream changes that were made and fixes several spacing and testing errors
This commit is contained in:
parent
7bd0af15d2
commit
5fa25a0288
3 changed files with 12193 additions and 4 deletions
|
@ -556,11 +556,19 @@ class BaseManager(object):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _file_is_missing(self):
|
||||||
|
if not os.path.exists(self.want.file):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
task = None
|
task = None
|
||||||
if self.want.active is None:
|
if self.want.active is None:
|
||||||
self.want.update(dict(active=False))
|
self.want.update(dict(active=False))
|
||||||
|
if self._file_is_missing():
|
||||||
|
raise F5ModuleError(
|
||||||
|
"The specified ASM policy file does not exist"
|
||||||
|
)
|
||||||
self._set_changed_options()
|
self._set_changed_options()
|
||||||
if self.client.check_mode:
|
if self.client.check_mode:
|
||||||
return True
|
return True
|
||||||
|
|
12174
test/units/modules/network/f5/fixtures/fake_policy.xml
Normal file
12174
test/units/modules/network/f5/fixtures/fake_policy.xml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -16,10 +16,10 @@ if sys.version_info < (2, 7):
|
||||||
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.compat.tests.mock import patch, Mock, PropertyMock
|
from ansible.compat.tests.mock import Mock
|
||||||
|
from ansible.compat.tests.mock import patch
|
||||||
from ansible.module_utils.f5_utils import AnsibleF5Client
|
from ansible.module_utils.f5_utils import AnsibleF5Client
|
||||||
from ansible.module_utils.f5_utils import F5ModuleError
|
from ansible.module_utils.f5_utils import F5ModuleError
|
||||||
from units.modules.utils import set_module_args
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.bigip_asm_policy import V1Parameters
|
from library.bigip_asm_policy import V1Parameters
|
||||||
|
@ -29,6 +29,7 @@ try:
|
||||||
from library.bigip_asm_policy import V2Manager
|
from library.bigip_asm_policy import V2Manager
|
||||||
from library.bigip_asm_policy import ArgumentSpec
|
from library.bigip_asm_policy import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from test.unit.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ansible.modules.network.f5.bigip_asm_policy import V1Parameters
|
from ansible.modules.network.f5.bigip_asm_policy import V1Parameters
|
||||||
|
@ -38,6 +39,7 @@ except ImportError:
|
||||||
from ansible.modules.network.f5.bigip_asm_policy import V2Manager
|
from ansible.modules.network.f5.bigip_asm_policy import V2Manager
|
||||||
from ansible.modules.network.f5.bigip_asm_policy import ArgumentSpec
|
from ansible.modules.network.f5.bigip_asm_policy import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from units.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
||||||
|
|
||||||
|
@ -151,6 +153,7 @@ class TestManager(unittest.TestCase):
|
||||||
v1.read_current_from_device = Mock(return_value=current)
|
v1.read_current_from_device = Mock(return_value=current)
|
||||||
v1.apply_on_device = Mock(return_value=True)
|
v1.apply_on_device = Mock(return_value=True)
|
||||||
v1.create_from_template_on_device = Mock(return_value=True)
|
v1.create_from_template_on_device = Mock(return_value=True)
|
||||||
|
v1._file_is_missing = Mock(return_value=False)
|
||||||
|
|
||||||
# Override methods to force specific logic in the module to happen
|
# Override methods to force specific logic in the module to happen
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
|
@ -189,6 +192,7 @@ class TestManager(unittest.TestCase):
|
||||||
v1.create_blank = Mock(return_value=True)
|
v1.create_blank = Mock(return_value=True)
|
||||||
v1.read_current_from_device = Mock(return_value=current)
|
v1.read_current_from_device = Mock(return_value=current)
|
||||||
v1.apply_on_device = Mock(return_value=True)
|
v1.apply_on_device = Mock(return_value=True)
|
||||||
|
v1._file_is_missing = Mock(return_value=False)
|
||||||
|
|
||||||
# Override methods to force specific logic in the module to happen
|
# Override methods to force specific logic in the module to happen
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
|
@ -389,6 +393,7 @@ class TestManager(unittest.TestCase):
|
||||||
v1.create_from_template_on_device = Mock(return_value=True)
|
v1.create_from_template_on_device = Mock(return_value=True)
|
||||||
v1.wait_for_task = Mock(side_effect=[True, True])
|
v1.wait_for_task = Mock(side_effect=[True, True])
|
||||||
v1.read_current_from_device = Mock(return_value=current)
|
v1.read_current_from_device = Mock(return_value=current)
|
||||||
|
v1._file_is_missing = Mock(return_value=False)
|
||||||
|
|
||||||
# Override methods to force specific logic in the module to happen
|
# Override methods to force specific logic in the module to happen
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
|
@ -426,6 +431,7 @@ class TestManager(unittest.TestCase):
|
||||||
v1.create_blank = Mock(return_value=True)
|
v1.create_blank = Mock(return_value=True)
|
||||||
v1.read_current_from_device = Mock(return_value=current)
|
v1.read_current_from_device = Mock(return_value=current)
|
||||||
v1.apply_on_device = Mock(return_value=True)
|
v1.apply_on_device = Mock(return_value=True)
|
||||||
|
v1._file_is_missing = Mock(return_value=False)
|
||||||
|
|
||||||
# Override methods to force specific logic in the module to happen
|
# Override methods to force specific logic in the module to happen
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
|
@ -554,6 +560,7 @@ class TestManager(unittest.TestCase):
|
||||||
v1 = V1Manager(client)
|
v1 = V1Manager(client)
|
||||||
v1.exists = Mock(return_value=False)
|
v1.exists = Mock(return_value=False)
|
||||||
v1.create_on_device = Mock(return_value=False)
|
v1.create_on_device = Mock(return_value=False)
|
||||||
|
v1._file_is_missing = Mock(return_value=False)
|
||||||
|
|
||||||
# Override methods to force specific logic in the module to happen
|
# Override methods to force specific logic in the module to happen
|
||||||
mm = ModuleManager(client)
|
mm = ModuleManager(client)
|
||||||
|
|
Loading…
Reference in a new issue