salt/tests/integration/wheel/test_key.py

40 lines
1.2 KiB
Python
Raw Normal View History

# coding: utf-8
# Import python libs
from __future__ import absolute_import
# Import Salt Testing libs
from tests.support.unit import TestCase
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
# Import Salt libs
import salt.wheel
2013-12-13 23:32:08 +00:00
class KeyWheelModuleTest(TestCase, AdaptedConfigurationTestCaseMixin):
def setUp(self):
2015-01-27 21:11:01 +00:00
self.wheel = salt.wheel.Wheel(dict(self.get_config('client_config')))
2017-03-06 16:45:59 +00:00
def tearDown(self):
del self.wheel
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)
2017-05-03 19:37:44 +00:00
try:
self.assertTrue(
ret.get('pub', '').startswith('-----BEGIN PUBLIC KEY-----'))
except AssertionError:
self.assertTrue(
ret.get('pub', '').startswith('-----BEGIN RSA PUBLIC KEY-----'))
self.assertTrue(
ret.get('priv', '').startswith('-----BEGIN RSA PRIVATE KEY-----'))