Reverted back the `--key-logfile` deprecation.
On the parsers cleanup branch, I though about making the available options as equal as possible. Since the log_file setting for the master and the minion could be separately set, I made the logfile option for the key also log_file. Yet, since there's no key specific config file, it shares master, one could only specify the log_file settings from the cli, it could not be hardcoded on the config file, unless, we made a separate config file just for key.
So, in order to reduce required changes, and keep it all as backwards compatible as possible, the key log file options is now, once again, `--key-logfile` which will allow us to hardcode it in the masters config file as `key_logfile`.
This will also, hopefully make travis behave better too.
2012-08-08 00:08:38 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
tests.unit.config
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
:copyright: © 2012 UfSoft.org - :email:`Pedro Algarvio (pedro@algarvio.me)`
|
|
|
|
:license: Apache 2.0, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
2012-09-07 17:04:14 +00:00
|
|
|
import shutil
|
Reverted back the `--key-logfile` deprecation.
On the parsers cleanup branch, I though about making the available options as equal as possible. Since the log_file setting for the master and the minion could be separately set, I made the logfile option for the key also log_file. Yet, since there's no key specific config file, it shares master, one could only specify the log_file settings from the cli, it could not be hardcoded on the config file, unless, we made a separate config file just for key.
So, in order to reduce required changes, and keep it all as backwards compatible as possible, the key log file options is now, once again, `--key-logfile` which will allow us to hardcode it in the masters config file as `key_logfile`.
This will also, hopefully make travis behave better too.
2012-08-08 00:08:38 +00:00
|
|
|
import tempfile
|
|
|
|
from saltunittest import TestCase, TestLoader, TextTestRunner
|
|
|
|
from salt import config as sconfig
|
|
|
|
|
2012-09-07 17:04:14 +00:00
|
|
|
|
Reverted back the `--key-logfile` deprecation.
On the parsers cleanup branch, I though about making the available options as equal as possible. Since the log_file setting for the master and the minion could be separately set, I made the logfile option for the key also log_file. Yet, since there's no key specific config file, it shares master, one could only specify the log_file settings from the cli, it could not be hardcoded on the config file, unless, we made a separate config file just for key.
So, in order to reduce required changes, and keep it all as backwards compatible as possible, the key log file options is now, once again, `--key-logfile` which will allow us to hardcode it in the masters config file as `key_logfile`.
This will also, hopefully make travis behave better too.
2012-08-08 00:08:38 +00:00
|
|
|
class ConfigTestCase(TestCase):
|
|
|
|
def test_proper_path_joining(self):
|
|
|
|
fpath = tempfile.mktemp()
|
|
|
|
open(fpath, 'w').write(
|
|
|
|
"root_dir: /\n"
|
|
|
|
"key_logfile: key\n"
|
|
|
|
)
|
|
|
|
config = sconfig.master_config(fpath)
|
|
|
|
# os.path.join behaviour
|
|
|
|
self.assertEqual(config['key_logfile'], os.path.join('/', 'key'))
|
|
|
|
# os.sep.join behaviour
|
|
|
|
self.assertNotEqual(config['key_logfile'], '//key')
|
|
|
|
|
2012-09-07 17:04:14 +00:00
|
|
|
def test_common_prefix_stripping(self):
|
|
|
|
tempdir = tempfile.mkdtemp()
|
|
|
|
root_dir = os.path.join(tempdir, 'foo', 'bar')
|
|
|
|
os.makedirs(root_dir)
|
|
|
|
fpath = os.path.join(root_dir, 'config')
|
|
|
|
open(fpath, 'w').write(
|
|
|
|
'root_dir: {0}\n'
|
|
|
|
'log_file: {1}\n'.format(root_dir, fpath)
|
|
|
|
)
|
|
|
|
config = sconfig.master_config(fpath)
|
|
|
|
self.assertEqual(config['log_file'], fpath)
|
|
|
|
shutil.rmtree(tempdir)
|
|
|
|
|
Reverted back the `--key-logfile` deprecation.
On the parsers cleanup branch, I though about making the available options as equal as possible. Since the log_file setting for the master and the minion could be separately set, I made the logfile option for the key also log_file. Yet, since there's no key specific config file, it shares master, one could only specify the log_file settings from the cli, it could not be hardcoded on the config file, unless, we made a separate config file just for key.
So, in order to reduce required changes, and keep it all as backwards compatible as possible, the key log file options is now, once again, `--key-logfile` which will allow us to hardcode it in the masters config file as `key_logfile`.
This will also, hopefully make travis behave better too.
2012-08-08 00:08:38 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
loader = TestLoader()
|
|
|
|
tests = loader.loadTestsFromTestCase(ConfigTestCase)
|
2012-09-07 17:04:14 +00:00
|
|
|
TextTestRunner(verbosity=1).run(tests)
|