salt/tests/integration/wheel/key.py

33 lines
1.0 KiB
Python
Raw Normal View History

# coding: utf-8
# Import Salt Testing libs
from __future__ import absolute_import
import integration
# Import Salt libs
import salt.wheel
2013-12-13 23:32:08 +00:00
class KeyWheelModuleTest(integration.TestCase, integration.AdaptedConfigurationTestCaseMixIn):
def setUp(self):
2015-01-27 21:11:01 +00:00
self.wheel = salt.wheel.Wheel(dict(self.get_config('client_config')))
def test_list_all(self):
ret = self.wheel.cmd('key.list_all', print_event=False)
2016-07-21 19:54:32 +00:00
for host in ['minion', 'sub_minion']:
self.assertIn(host, ret['minions'])
def test_gen(self):
2016-08-22 04:31:23 +00:00
ret = self.wheel.cmd('key.gen', kwarg={'id_': 'soundtechniciansrock'}, print_event=False)
self.assertIn('pub', ret)
self.assertIn('priv', ret)
self.assertTrue(
ret.get('pub', '').startswith('-----BEGIN PUBLIC KEY-----'))
self.assertTrue(
ret.get('priv', '').startswith('-----BEGIN RSA PRIVATE KEY-----'))
if __name__ == '__main__':
from integration import run_tests
run_tests(KeyWheelModuleTest, needs_daemon=True)