Skip to content

Commit

Permalink
Test delete of referenced alias
Browse files Browse the repository at this point in the history
  • Loading branch information
opoplawski committed Dec 21, 2023
1 parent 5e0ea2a commit ba7f66f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/plugins/modules/test_pfsense_alias.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright: (c) 2018, Frederic Bor <frederic.bor@wanadoo.fr>
# Copyright: (c) 2023, Orion Poplawski <orion@nwra.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import (absolute_import, division, print_function)
Expand Down Expand Up @@ -55,6 +56,14 @@ def do_alias_deletion_test(self, alias, command=None):
self.assert_has_xml_tag('aliases', dict(name=alias['name'], type=alias['type']), absent=True)
self.assertEqual(result['commands'], [command])

def do_alias_deletion_referenced_test(self, alias, command=None):
""" test deletion of a referenced alias """
set_module_args(self.args_from_var(alias, 'absent'))
result = self.execute_module(changed=False)

self.assert_has_xml_tag('aliases', dict(name=alias['name'], type=alias['type']), absent=True)
self.assertEqual(result['commands'], [command])

def do_alias_update_noop_test(self, alias):
""" test not updating an alias """
set_module_args(self.args_from_var(alias))
Expand Down Expand Up @@ -94,6 +103,11 @@ def test_host_delete(self):
command = "delete alias 'ad_poc1'"
self.do_alias_deletion_test(alias, command=command)

def test_host_delete_referenced(self):
""" test deletion of a referenced host alias """
alias = dict(name='srv_admin', state='absent')
self.do_module_test(alias, failed=True, msg="Alias 'srv_admin' is referenced by rule")

def test_host_update_noop(self):
""" test not updating an host alias """
alias = dict(name='ad_poc1', address='192.168.1.3', descr='', type='host', detail='')
Expand Down

0 comments on commit ba7f66f

Please sign in to comment.