2013-11-27 11:19:24 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2013-05-26 06:32:57 +00:00
|
|
|
'''
|
|
|
|
Validate the config system
|
|
|
|
'''
|
2014-11-21 19:05:13 +00:00
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2013-06-27 10:52:46 +00:00
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
2013-06-25 08:11:23 +00:00
|
|
|
# Import salt libs
|
2013-06-27 10:52:46 +00:00
|
|
|
import integration
|
2013-05-26 06:32:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ConfigTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Test config routines
|
|
|
|
'''
|
|
|
|
def test_valid_file_proto(self):
|
|
|
|
'''
|
|
|
|
test config.valid_file_proto
|
|
|
|
'''
|
2013-06-25 08:11:23 +00:00
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('config.valid_fileproto', ['salt://']))
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('config.valid_fileproto', ['http://']))
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('config.valid_fileproto', ['https://']))
|
|
|
|
self.assertTrue(
|
|
|
|
self.run_function('config.valid_fileproto', ['ftp://']))
|
|
|
|
self.assertFalse(
|
|
|
|
self.run_function('config.valid_fileproto', ['cheese://']))
|
2013-05-26 06:32:57 +00:00
|
|
|
|
|
|
|
def test_backup_mode(self):
|
|
|
|
'''
|
|
|
|
test config.backup_mode
|
|
|
|
'''
|
2013-06-25 08:11:23 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.backup_mode', ['minion']), 'minion')
|
2013-05-26 06:32:57 +00:00
|
|
|
|
|
|
|
def test_manage_mode(self):
|
|
|
|
'''
|
|
|
|
test config.manage_mode
|
|
|
|
'''
|
|
|
|
# This function is generally only used with cross calls, the yaml
|
2013-06-25 08:11:23 +00:00
|
|
|
# interpreter is breaking it for remote calls
|
2014-01-17 21:03:44 +00:00
|
|
|
# The correct standard is the four digit form.
|
2013-06-25 08:11:23 +00:00
|
|
|
self.assertEqual(
|
2014-01-17 22:49:36 +00:00
|
|
|
self.run_function('config.manage_mode', ['"775"']), '0775')
|
2013-06-25 08:11:23 +00:00
|
|
|
self.assertEqual(
|
2014-01-29 15:47:49 +00:00
|
|
|
self.run_function('config.manage_mode', ['"1775"']), '01775')
|
2014-01-17 21:03:44 +00:00
|
|
|
self.assertEqual(
|
2014-01-17 22:49:36 +00:00
|
|
|
self.run_function('config.manage_mode', ['"0775"']), '0775')
|
2014-01-29 15:47:49 +00:00
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.manage_mode', ['"01775"']), '01775')
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.manage_mode', ['"0"']), '0000')
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.manage_mode', ['775']), '0775')
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.manage_mode', ['1775']), '01775')
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function('config.manage_mode', ['0']), '0000')
|
2013-05-26 06:32:57 +00:00
|
|
|
|
|
|
|
def test_option(self):
|
|
|
|
'''
|
|
|
|
test config.option
|
|
|
|
'''
|
|
|
|
# Minion opt
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.option',
|
|
|
|
['master_port']),
|
|
|
|
64506)
|
|
|
|
# Master conf opt
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.option',
|
|
|
|
['syndic_master']),
|
|
|
|
'localhost')
|
|
|
|
# pillar conf opt
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.option',
|
|
|
|
['ext_spam']),
|
|
|
|
'eggs')
|
|
|
|
|
|
|
|
def test_get(self):
|
|
|
|
'''
|
|
|
|
Test option.get
|
|
|
|
'''
|
|
|
|
# Check pillar get
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.get',
|
|
|
|
['level1:level2']),
|
|
|
|
'foo')
|
|
|
|
# Check master config
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.get',
|
|
|
|
['config_opt:layer2']),
|
|
|
|
'kosher')
|
2013-05-26 09:42:41 +00:00
|
|
|
# Check minion config
|
|
|
|
self.assertEqual(
|
|
|
|
self.run_function(
|
|
|
|
'config.get',
|
|
|
|
['config_test:spam']),
|
|
|
|
'eggs')
|
2013-06-25 08:11:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(ConfigTest)
|