Skip to content

Commit ba7f66f

Browse files
committed
Test delete of referenced alias
1 parent 5e0ea2a commit ba7f66f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/unit/plugins/modules/test_pfsense_alias.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright: (c) 2018, Frederic Bor <[email protected]>
2+
# Copyright: (c) 2023, Orion Poplawski <[email protected]>
23
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
34

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

59+
def do_alias_deletion_referenced_test(self, alias, command=None):
60+
""" test deletion of a referenced alias """
61+
set_module_args(self.args_from_var(alias, 'absent'))
62+
result = self.execute_module(changed=False)
63+
64+
self.assert_has_xml_tag('aliases', dict(name=alias['name'], type=alias['type']), absent=True)
65+
self.assertEqual(result['commands'], [command])
66+
5867
def do_alias_update_noop_test(self, alias):
5968
""" test not updating an alias """
6069
set_module_args(self.args_from_var(alias))
@@ -94,6 +103,11 @@ def test_host_delete(self):
94103
command = "delete alias 'ad_poc1'"
95104
self.do_alias_deletion_test(alias, command=command)
96105

106+
def test_host_delete_referenced(self):
107+
""" test deletion of a referenced host alias """
108+
alias = dict(name='srv_admin', state='absent')
109+
self.do_module_test(alias, failed=True, msg="Alias 'srv_admin' is referenced by rule")
110+
97111
def test_host_update_noop(self):
98112
""" test not updating an host alias """
99113
alias = dict(name='ad_poc1', address='192.168.1.3', descr='', type='host', detail='')

0 commit comments

Comments
 (0)