mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Changed integration tests to use autosign_file to authenticate minions
This commit is contained in:
parent
6db9143f08
commit
64e30ac0b2
@ -848,6 +848,12 @@ class TestDaemon(object):
|
|||||||
)
|
)
|
||||||
opts_dict['extension_modules'] = os.path.join(opts_dict['root_dir'], 'extension_modules')
|
opts_dict['extension_modules'] = os.path.join(opts_dict['root_dir'], 'extension_modules')
|
||||||
|
|
||||||
|
# Copy the autosign_file to the new master root_dir
|
||||||
|
shutil.copyfile(
|
||||||
|
os.path.join(INTEGRATION_TEST_DIR, 'files', 'autosign_file'),
|
||||||
|
os.path.join(opts_dict['root_dir'], 'autosign_file')
|
||||||
|
)
|
||||||
|
|
||||||
# Point the config values to the correct temporary paths
|
# Point the config values to the correct temporary paths
|
||||||
for name in ('hosts', 'aliases'):
|
for name in ('hosts', 'aliases'):
|
||||||
optname = '{0}.file'.format(name)
|
optname = '{0}.file'.format(name)
|
||||||
|
@ -7,6 +7,7 @@ import shutil
|
|||||||
|
|
||||||
# Import Salt Testing libs
|
# Import Salt Testing libs
|
||||||
from tests.support.case import ShellCase
|
from tests.support.case import ShellCase
|
||||||
|
from tests.support.paths import TMP, INTEGRATION_TEST_DIR
|
||||||
|
|
||||||
# Import 3rd-party libs
|
# Import 3rd-party libs
|
||||||
|
|
||||||
@ -19,53 +20,45 @@ class AutosignGrainsTest(ShellCase):
|
|||||||
Test autosigning minions based on grain values.
|
Test autosigning minions based on grain values.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def test_autosign_grains_accept(self):
|
def setUp(self):
|
||||||
|
shutil.copyfile(
|
||||||
|
os.path.join(INTEGRATION_TEST_DIR, 'files', 'autosign_grains', 'autosign_file'),
|
||||||
|
os.path.join(TMP, 'root_dir', 'autosign_file')
|
||||||
|
)
|
||||||
self.run_key('-d minion -y')
|
self.run_key('-d minion -y')
|
||||||
self.run_call('test.ping') # get minon to try to authenticate itself again
|
self.run_call('test.ping') # get minon to try to authenticate itself again
|
||||||
|
|
||||||
try:
|
if 'minion' in self.run_key('-l acc'):
|
||||||
self.assertEqual(self.run_key('-l acc'), ['Accepted Keys:', 'sub_minion'])
|
self.skipTest('Could not deauthorize minion')
|
||||||
self.assertEqual(self.run_key('-l un'), ['Unaccepted Keys:', 'minion'])
|
if 'minion' not in self.run_key('-l un'):
|
||||||
except AssertionError:
|
self.skipTest('minion did not try to authenticate itself')
|
||||||
self.run_key('-a minion -y')
|
|
||||||
raise
|
|
||||||
|
|
||||||
autosign_grains_dir = os.path.join(self.master_opts['autosign_grains_dir'])
|
self.autosign_grains_dir = os.path.join(self.master_opts['autosign_grains_dir'])
|
||||||
if not os.path.isdir(autosign_grains_dir):
|
if not os.path.isdir(self.autosign_grains_dir):
|
||||||
os.makedirs(autosign_grains_dir)
|
os.makedirs(self.autosign_grains_dir)
|
||||||
with salt.utils.files.fopen(os.path.join(autosign_grains_dir, 'test_grain'), 'w') as f:
|
|
||||||
|
def tearDown(self):
|
||||||
|
shutil.copyfile(
|
||||||
|
os.path.join(INTEGRATION_TEST_DIR, 'files', 'autosign_file'),
|
||||||
|
os.path.join(TMP, 'root_dir', 'autosign_file')
|
||||||
|
)
|
||||||
|
self.run_call('test.ping') # get minon to try to authenticate itself again
|
||||||
|
self.run_key('-a minion -y')
|
||||||
|
|
||||||
|
if os.path.isdir(self.autosign_grains_dir):
|
||||||
|
shutil.rmtree(self.autosign_grains_dir)
|
||||||
|
|
||||||
|
def test_autosign_grains_accept(self):
|
||||||
|
with salt.utils.files.fopen(os.path.join(self.autosign_grains_dir, 'test_grain'), 'w') as f:
|
||||||
f.write('#invalid_value\ncheese')
|
f.write('#invalid_value\ncheese')
|
||||||
|
|
||||||
self.run_call('test.ping') # get minon to try to authenticate itself again
|
self.run_call('test.ping') # get minon to try to authenticate itself again
|
||||||
try:
|
self.assertIn('minion', self.run_key('-l acc'))
|
||||||
self.assertEqual(self.run_key('-l acc'), ['Accepted Keys:', 'minion', 'sub_minion'])
|
|
||||||
finally:
|
|
||||||
self.run_key('-a minion -y')
|
|
||||||
if os.path.isdir(autosign_grains_dir):
|
|
||||||
shutil.rmtree(autosign_grains_dir)
|
|
||||||
|
|
||||||
def test_autosign_grains_fail(self):
|
def test_autosign_grains_fail(self):
|
||||||
self.run_key('-d minion -y')
|
with salt.utils.files.fopen(os.path.join(self.autosign_grains_dir, 'test_grain'), 'w') as f:
|
||||||
self.run_call('test.ping') # get minon to try to authenticate itself again
|
|
||||||
|
|
||||||
try:
|
|
||||||
self.assertEqual(self.run_key('-l acc'), ['Accepted Keys:', 'sub_minion'])
|
|
||||||
self.assertEqual(self.run_key('-l un'), ['Unaccepted Keys:', 'minion'])
|
|
||||||
except AssertionError:
|
|
||||||
self.run_key('-a minion -y')
|
|
||||||
raise
|
|
||||||
|
|
||||||
autosign_grains_dir = os.path.join(self.master_opts['autosign_grains_dir'])
|
|
||||||
if not os.path.isdir(autosign_grains_dir):
|
|
||||||
os.makedirs(autosign_grains_dir)
|
|
||||||
with salt.utils.files.fopen(os.path.join(autosign_grains_dir, 'test_grain'), 'w') as f:
|
|
||||||
f.write('#cheese\ninvalid_value')
|
f.write('#cheese\ninvalid_value')
|
||||||
|
|
||||||
self.run_call('test.ping') # get minon to try to authenticate itself again
|
self.run_call('test.ping') # get minon to try to authenticate itself again
|
||||||
try:
|
self.assertNotIn('minion', self.run_key('-l acc'))
|
||||||
self.assertEqual(self.run_key('-l acc'), ['Accepted Keys:', 'sub_minion'])
|
self.assertIn('minion', self.run_key('-l un'))
|
||||||
self.assertEqual(self.run_key('-l un'), ['Unaccepted Keys:', 'minion'])
|
|
||||||
finally:
|
|
||||||
self.run_key('-a minion -y')
|
|
||||||
if os.path.isdir(autosign_grains_dir):
|
|
||||||
shutil.rmtree(autosign_grains_dir)
|
|
||||||
|
3
tests/integration/files/autosign_file
Normal file
3
tests/integration/files/autosign_file
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
minion
|
||||||
|
sub_minion
|
||||||
|
syndic
|
2
tests/integration/files/autosign_grains/autosign_file
Normal file
2
tests/integration/files/autosign_grains/autosign_file
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
sub_minion
|
||||||
|
syndic
|
@ -8,7 +8,6 @@ worker_threads: 3
|
|||||||
pidfile: master.pid
|
pidfile: master.pid
|
||||||
sock_dir: master_sock
|
sock_dir: master_sock
|
||||||
timeout: 12
|
timeout: 12
|
||||||
open_mode: True
|
|
||||||
fileserver_list_cache_time: 0
|
fileserver_list_cache_time: 0
|
||||||
file_buffer_size: 8192
|
file_buffer_size: 8192
|
||||||
file_recv: True
|
file_recv: True
|
||||||
@ -99,3 +98,4 @@ libcloud_dns:
|
|||||||
shopper_id: 12345
|
shopper_id: 12345
|
||||||
|
|
||||||
autosign_grains_dir: autosign_grains
|
autosign_grains_dir: autosign_grains
|
||||||
|
autosign_file: autosign_file
|
||||||
|
Loading…
Reference in New Issue
Block a user