Merge branch '2017.7' into merge-2017.7

Conflicts:
	salt/utils/minions.py
This commit is contained in:
Gareth J. Greenaway 2018-12-20 11:18:38 -08:00
commit 6a65bf94bc
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41
5 changed files with 17 additions and 27 deletions

View file

@ -98,7 +98,7 @@ pipeline {
stage('linting all') {
// perform a full linit if this is a merge forward and the change only lint passed.
when {
expression { return params.CHANGE_BRANCH =~ /(?i)^merge[._-]/ }
expression { return env.CHANGE_BRANCH =~ /(?i)^merge[._-]/ }
}
parallel {
stage('setup full') {

View file

@ -2047,7 +2047,7 @@ def managed(name,
contents_pillar
.. versionadded:: 0.17.0
.. versionchanged: 2016.11.0
.. versionchanged:: 2016.11.0
contents_pillar can also be a list, and the pillars will be
concatinated together to form one file.

View file

@ -702,27 +702,6 @@ class CkMinions(object):
_res = {'minions': [], 'missing': []}
return _res
def _expand_matching(self, auth_entry):
ref = {'G': 'grain',
'P': 'grain_pcre',
'I': 'pillar',
'J': 'pillar_pcre',
'L': 'list',
'S': 'ipcidr',
'E': 'pcre',
'N': 'node',
None: 'compound'}
target_info = parse_target(auth_entry)
if not target_info:
log.error('Failed to parse valid target "%s"', auth_entry)
v_matcher = ref.get(target_info['engine'])
v_expr = target_info['pattern']
_res = self.check_minions(v_expr, v_matcher)
return set(_res['minions'])
def validate_tgt(self, valid, expr, tgt_type, minions=None, expr_form=None):
'''
Return a Bool. This function returns if the expression sent in is
@ -739,7 +718,7 @@ class CkMinions(object):
)
tgt_type = expr_form
v_minions = self._expand_matching(valid)
v_minions = set(self.check_minions(valid, 'compound'))
if minions is None:
_res = self.check_minions(expr, tgt_type)
minions = set(_res['minions'])
@ -879,7 +858,7 @@ class CkMinions(object):
continue
allowed_minions.update(set(auth_list_entry.keys()))
for key in auth_list_entry:
for match in self._expand_matching(key):
for match in set(self.check_minions(key, 'compound')):
if match in auth_dictionary:
auth_dictionary[match].extend(auth_list_entry[key])
else:
@ -887,7 +866,7 @@ class CkMinions(object):
allowed_minions_from_auth_list = set()
for next_entry in allowed_minions:
allowed_minions_from_auth_list.update(self._expand_matching(next_entry))
allowed_minions_from_auth_list.update(set(self.check_minions(next_entry, 'compound')))
# 'minions' here are all the names of minions matched by the target
# if we take out all the allowed minions, and there are any left, then
# the target includes minions that are not allowed by eauth

View file

@ -500,7 +500,7 @@ def valid_id(opts, id_):
if any(x in id_ for x in ('/', '\\', str('\0'))):
return False
return bool(clean_path(opts['pki_dir'], id_))
except (AttributeError, KeyError, TypeError):
except (AttributeError, KeyError, TypeError, UnicodeDecodeError):
return False

View file

@ -335,6 +335,17 @@ class MySQLTestCase(TestCase, LoaderModuleMockMixin):
def test_query(self):
self._test_call(mysql.query, 'SELECT * FROM testdb', 'testdb', 'SELECT * FROM testdb')
def test_query_error(self):
connect_mock = MagicMock()
with patch.object(mysql, '_connect', connect_mock):
with patch.dict(mysql.__salt__, {'config.option': MagicMock()}):
side_effect = MySQLdb.OperationalError(9999, 'Something Went Wrong')
with patch.object(mysql, '_execute', MagicMock(side_effect=side_effect)):
mysql.query('testdb', 'SELECT * FROM testdb')
self.assertIn('mysql.error', mysql.__context__)
expected = 'MySQL Error 9999: Something Went Wrong'
self.assertEqual(mysql.__context__['mysql.error'], expected)
def _test_call(self, function, expected_sql, *args, **kwargs):
connect_mock = MagicMock()
with patch.object(mysql, '_connect', connect_mock):