diff --git a/salt/modules/debian_ip.py b/salt/modules/debian_ip.py index 8017c9497170..1e46fbcf4034 100644 --- a/salt/modules/debian_ip.py +++ b/salt/modules/debian_ip.py @@ -158,7 +158,7 @@ def _error_msg_iface(iface, option, expected): a list of expected values. ''' msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]' - return msg.format(iface, option, '|'.join(expected)) + return msg.format(iface, option, '|'.join(str(e) for e in expected)) def _error_msg_routes(iface, option, expected): @@ -181,7 +181,7 @@ def _error_msg_network(option, expected): a list of expected values. ''' msg = 'Invalid network setting -- Setting: {0}, Expected: [{1}]' - return msg.format(option, '|'.join(expected)) + return msg.format(option, '|'.join(str(e) for e in expected)) def _log_default_network(opt, value): diff --git a/salt/modules/rh_ip.py b/salt/modules/rh_ip.py index 800a9d573876..1f09d0f7905b 100644 --- a/salt/modules/rh_ip.py +++ b/salt/modules/rh_ip.py @@ -81,7 +81,7 @@ def _error_msg_iface(iface, option, expected): a list of expected values. ''' msg = 'Invalid option -- Interface: {0}, Option: {1}, Expected: [{2}]' - return msg.format(iface, option, '|'.join(expected)) + return msg.format(iface, option, '|'.join(str(e) for e in expected)) def _error_msg_routes(iface, option, expected): @@ -104,7 +104,7 @@ def _error_msg_network(option, expected): a list of expected values. ''' msg = 'Invalid network setting -- Setting: {0}, Expected: [{1}]' - return msg.format(option, '|'.join(expected)) + return msg.format(option, '|'.join(str(e) for e in expected)) def _log_default_network(opt, value): diff --git a/tests/unit/modules/test_debian_ip.py b/tests/unit/modules/test_debian_ip.py index f21ca4101995..e22329343a76 100644 --- a/tests/unit/modules/test_debian_ip.py +++ b/tests/unit/modules/test_debian_ip.py @@ -52,6 +52,18 @@ def test_build_bond(self): 'pkg.install': mock}): self.assertEqual(debian_ip.build_bond('bond0'), '') + def test_error_message_iface_should_process_non_str_expected(self): + values = [1, True, False, 'no-kaboom'] + iface = 'ethtest' + option = 'test' + msg = debian_ip._error_msg_iface(iface, option, values) + self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg) + + def test_error_message_network_should_process_non_str_expected(self): + values = [1, True, False, 'no-kaboom'] + msg = debian_ip._error_msg_network('fnord', values) + self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg) + def test_build_bond_exception(self): ''' Test if it create a bond script in /etc/modprobe.d with the passed diff --git a/tests/unit/modules/test_rh_ip.py b/tests/unit/modules/test_rh_ip.py index 78694de51c19..8664c067e7d3 100644 --- a/tests/unit/modules/test_rh_ip.py +++ b/tests/unit/modules/test_rh_ip.py @@ -32,6 +32,18 @@ class RhipTestCase(TestCase, LoaderModuleMockMixin): def setup_loader_modules(self): return {rh_ip: {}} + def test_error_message_iface_should_process_non_str_expected(self): + values = [1, True, False, 'no-kaboom'] + iface = 'ethtest' + option = 'test' + msg = rh_ip._error_msg_iface(iface, option, values) + self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg) + + def test_error_message_network_should_process_non_str_expected(self): + values = [1, True, False, 'no-kaboom'] + msg = rh_ip._error_msg_network('fnord', values) + self.assertTrue(msg.endswith('[1|True|False|no-kaboom]'), msg) + def test_build_bond(self): ''' Test to create a bond script in /etc/modprobe.d with the passed