2016-05-23 21:11:16 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
|
|
|
Integration tests for the saltutil module.
|
|
|
|
'''
|
|
|
|
|
|
|
|
# Import Python libs
|
|
|
|
from __future__ import absolute_import
|
2016-08-22 08:13:16 +00:00
|
|
|
import time
|
2016-05-23 21:11:16 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from salttesting.helpers import ensure_in_syspath
|
|
|
|
|
|
|
|
ensure_in_syspath('../../')
|
|
|
|
|
|
|
|
# Import Salt libs
|
|
|
|
import integration
|
|
|
|
|
|
|
|
|
|
|
|
class SaltUtilModuleTest(integration.ModuleCase):
|
|
|
|
'''
|
|
|
|
Testcase for the saltutil execution module
|
|
|
|
'''
|
|
|
|
|
2016-08-22 08:13:16 +00:00
|
|
|
def setUp(self):
|
2016-08-22 10:00:19 +00:00
|
|
|
self.run_function('saltutil.refresh_pillar')
|
2016-08-22 08:13:16 +00:00
|
|
|
|
2016-05-23 21:11:16 +00:00
|
|
|
# Tests for the wheel function
|
|
|
|
|
|
|
|
def test_wheel_just_function(self):
|
|
|
|
'''
|
|
|
|
Tests using the saltutil.wheel function when passing only a function.
|
|
|
|
'''
|
2016-08-22 08:13:16 +00:00
|
|
|
# Wait for the pillar refresh to kick in, so that grains are ready to go
|
2016-08-22 10:00:19 +00:00
|
|
|
time.sleep(3)
|
2016-05-23 21:11:16 +00:00
|
|
|
ret = self.run_function('saltutil.wheel', ['minions.connected'])
|
2016-08-01 16:44:59 +00:00
|
|
|
self.assertIn('minion', ret['return'])
|
|
|
|
self.assertIn('sub_minion', ret['return'])
|
2016-05-23 21:11:16 +00:00
|
|
|
|
|
|
|
def test_wheel_with_arg(self):
|
|
|
|
'''
|
|
|
|
Tests using the saltutil.wheel function when passing a function and an arg.
|
|
|
|
'''
|
|
|
|
ret = self.run_function('saltutil.wheel', ['key.list', 'minion'])
|
2016-08-01 16:44:59 +00:00
|
|
|
self.assertEqual(ret['return'], {})
|
2016-05-23 21:11:16 +00:00
|
|
|
|
|
|
|
def test_wheel_no_arg_raise_error(self):
|
|
|
|
'''
|
|
|
|
Tests using the saltutil.wheel function when passing a function that requires
|
|
|
|
an arg, but one isn't supplied.
|
|
|
|
'''
|
|
|
|
self.assertRaises(TypeError, 'saltutil.wheel', ['key.list'])
|
|
|
|
|
|
|
|
def test_wheel_with_kwarg(self):
|
|
|
|
'''
|
|
|
|
Tests using the saltutil.wheel function when passing a function and a kwarg.
|
|
|
|
This function just generates a key pair, but doesn't do anything with it. We
|
|
|
|
just need this for testing purposes.
|
|
|
|
'''
|
|
|
|
ret = self.run_function('saltutil.wheel', ['key.gen'], keysize=1024)
|
2016-08-01 16:31:09 +00:00
|
|
|
self.assertIn('pub', ret['return'])
|
|
|
|
self.assertIn('priv', ret['return'])
|
2016-05-23 21:11:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
from integration import run_tests
|
|
|
|
run_tests(SaltUtilModuleTest)
|