2012-10-06 00:05:04 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2012-12-11 10:23:37 +00:00
|
|
|
'''
|
2018-05-28 21:13:12 +00:00
|
|
|
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
|
2013-09-16 16:24:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
tests.integration.states.match
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-12-11 10:23:37 +00:00
|
|
|
'''
|
2012-10-06 00:05:04 +00:00
|
|
|
|
2012-11-18 18:57:10 +00:00
|
|
|
# Import python libs
|
2018-01-21 20:04:00 +00:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2012-10-06 00:05:04 +00:00
|
|
|
import os
|
2012-11-18 18:57:10 +00:00
|
|
|
|
2013-06-24 22:53:59 +00:00
|
|
|
# Import Salt Testing libs
|
2017-04-03 16:04:09 +00:00
|
|
|
from tests.support.case import ModuleCase
|
|
|
|
from tests.support.paths import FILES
|
2017-04-04 17:57:27 +00:00
|
|
|
from tests.support.helpers import skip_if_not_root
|
2013-06-27 12:43:26 +00:00
|
|
|
|
|
|
|
# Import salt libs
|
2017-07-18 16:31:01 +00:00
|
|
|
import salt.utils.files
|
2018-01-21 20:04:00 +00:00
|
|
|
import salt.utils.stringutils
|
2012-12-19 01:39:16 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
STATE_DIR = os.path.join(FILES, 'file', 'base')
|
2012-10-06 00:05:04 +00:00
|
|
|
|
2012-11-18 18:57:10 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
class StateMatchTest(ModuleCase):
|
2012-10-06 00:05:04 +00:00
|
|
|
'''
|
|
|
|
Validate the file state
|
|
|
|
'''
|
|
|
|
|
2017-04-04 17:57:27 +00:00
|
|
|
@skip_if_not_root
|
2012-10-06 00:05:04 +00:00
|
|
|
def test_issue_2167_ipcidr_no_AttributeError(self):
|
|
|
|
subnets = self.run_function('network.subnets')
|
2012-12-19 01:39:16 +00:00
|
|
|
self.assertTrue(len(subnets) > 0)
|
2012-10-06 00:05:04 +00:00
|
|
|
top_filename = 'issue-2167-ipcidr-match.sls'
|
|
|
|
top_file = os.path.join(STATE_DIR, top_filename)
|
|
|
|
try:
|
2017-07-18 16:31:01 +00:00
|
|
|
with salt.utils.files.fopen(top_file, 'w') as fp_:
|
2016-08-11 16:45:24 +00:00
|
|
|
fp_.write(
|
2018-01-21 20:04:00 +00:00
|
|
|
salt.utils.stringutils.to_str(
|
|
|
|
'base:\n'
|
|
|
|
' {0}:\n'
|
|
|
|
' - match: ipcidr\n'
|
|
|
|
' - test\n'.format(subnets[0])
|
|
|
|
)
|
2016-08-11 16:45:24 +00:00
|
|
|
)
|
2012-10-06 00:05:04 +00:00
|
|
|
ret = self.run_function('state.top', [top_filename])
|
|
|
|
self.assertNotIn(
|
2012-11-18 18:57:10 +00:00
|
|
|
'AttributeError: \'Matcher\' object has no attribute '
|
|
|
|
'\'functions\'',
|
2012-10-06 00:05:04 +00:00
|
|
|
ret
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
os.remove(top_file)
|