2013-12-13 22:26:33 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
# Import python libs
|
2014-11-21 19:05:13 +00:00
|
|
|
from __future__ import absolute_import
|
2017-04-03 16:04:09 +00:00
|
|
|
|
|
|
|
# Import Salt Testing libs
|
|
|
|
from tests.support.unit import TestCase
|
|
|
|
from tests.support.mixins import AdaptedConfigurationTestCaseMixin
|
2013-12-13 22:26:33 +00:00
|
|
|
|
|
|
|
# Import Salt libs
|
|
|
|
import salt.wheel
|
|
|
|
|
2013-12-13 23:32:08 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
class KeyWheelModuleTest(TestCase, AdaptedConfigurationTestCaseMixin):
|
2013-12-13 22:26:33 +00:00
|
|
|
def setUp(self):
|
2015-01-27 21:11:01 +00:00
|
|
|
self.wheel = salt.wheel.Wheel(dict(self.get_config('client_config')))
|
2013-12-13 22:26:33 +00:00
|
|
|
|
2017-03-06 16:45:59 +00:00
|
|
|
def tearDown(self):
|
|
|
|
del self.wheel
|
|
|
|
|
2013-12-13 22:26:33 +00:00
|
|
|
def test_list_all(self):
|
2016-08-22 04:11:38 +00:00
|
|
|
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'])
|
2013-12-13 22:26:33 +00:00
|
|
|
|
|
|
|
def test_gen(self):
|
2016-08-22 04:31:23 +00:00
|
|
|
ret = self.wheel.cmd('key.gen', kwarg={'id_': 'soundtechniciansrock'}, print_event=False)
|
2013-12-13 22:26:33 +00:00
|
|
|
|
|
|
|
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-----'))
|
|
|
|
|
2013-12-13 22:26:33 +00:00
|
|
|
self.assertTrue(
|
|
|
|
ret.get('priv', '').startswith('-----BEGIN RSA PRIVATE KEY-----'))
|