|
1 | 1 | # Copyright: (c) 2018, Frederic Bor <[email protected]>
|
| 2 | +# Copyright: (c) 2023, Orion Poplawski <[email protected]> |
2 | 3 | # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
3 | 4 |
|
4 | 5 | from __future__ import (absolute_import, division, print_function)
|
@@ -55,6 +56,14 @@ def do_alias_deletion_test(self, alias, command=None):
|
55 | 56 | self.assert_has_xml_tag('aliases', dict(name=alias['name'], type=alias['type']), absent=True)
|
56 | 57 | self.assertEqual(result['commands'], [command])
|
57 | 58 |
|
| 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 | + |
58 | 67 | def do_alias_update_noop_test(self, alias):
|
59 | 68 | """ test not updating an alias """
|
60 | 69 | set_module_args(self.args_from_var(alias))
|
@@ -94,6 +103,11 @@ def test_host_delete(self):
|
94 | 103 | command = "delete alias 'ad_poc1'"
|
95 | 104 | self.do_alias_deletion_test(alias, command=command)
|
96 | 105 |
|
| 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 | + |
97 | 111 | def test_host_update_noop(self):
|
98 | 112 | """ test not updating an host alias """
|
99 | 113 | alias = dict(name='ad_poc1', address='192.168.1.3', descr='', type='host', detail='')
|
|
0 commit comments