mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #44625 from Ch3LL/delete_key_test
Add salt-key -d integration test
This commit is contained in:
commit
2cd618f99b
@ -5,6 +5,7 @@ from __future__ import absolute_import
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
|
import textwrap
|
||||||
|
|
||||||
# Import Salt Testing libs
|
# Import Salt Testing libs
|
||||||
from tests.support.case import ShellCase
|
from tests.support.case import ShellCase
|
||||||
@ -56,6 +57,36 @@ class KeyTest(ShellCase, ShellCaseCommonTestsMixin):
|
|||||||
if USERA in user:
|
if USERA in user:
|
||||||
self.run_call('user.delete {0} remove=True'.format(USERA))
|
self.run_call('user.delete {0} remove=True'.format(USERA))
|
||||||
|
|
||||||
|
def test_remove_key(self):
|
||||||
|
'''
|
||||||
|
test salt-key -d usage
|
||||||
|
'''
|
||||||
|
min_name = 'minibar'
|
||||||
|
pki_dir = self.master_opts['pki_dir']
|
||||||
|
key = os.path.join(pki_dir, 'minions', min_name)
|
||||||
|
|
||||||
|
with salt.utils.fopen(key, 'w') as fp:
|
||||||
|
fp.write(textwrap.dedent('''\
|
||||||
|
-----BEGIN PUBLIC KEY-----
|
||||||
|
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoqIZDtcQtqUNs0wC7qQz
|
||||||
|
JwFhXAVNT5C8M8zhI+pFtF/63KoN5k1WwAqP2j3LquTG68WpxcBwLtKfd7FVA/Kr
|
||||||
|
OF3kXDWFnDi+HDchW2lJObgfzLckWNRFaF8SBvFM2dys3CGSgCV0S/qxnRAjrJQb
|
||||||
|
B3uQwtZ64ncJAlkYpArv3GwsfRJ5UUQnYPDEJwGzMskZ0pHd60WwM1gMlfYmNX5O
|
||||||
|
RBEjybyNpYDzpda6e6Ypsn6ePGLkP/tuwUf+q9wpbRE3ZwqERC2XRPux+HX2rGP+
|
||||||
|
mkzpmuHkyi2wV33A9pDfMgRHdln2CLX0KgfRGixUQhW1o+Kmfv2rq4sGwpCgLbTh
|
||||||
|
NwIDAQAB
|
||||||
|
-----END PUBLIC KEY-----
|
||||||
|
'''))
|
||||||
|
|
||||||
|
check_key = self.run_key('-p {0}'.format(min_name))
|
||||||
|
self.assertIn('Accepted Keys:', check_key)
|
||||||
|
self.assertIn('minibar: -----BEGIN PUBLIC KEY-----', check_key)
|
||||||
|
|
||||||
|
remove_key = self.run_key('-d {0} -y'.format(min_name))
|
||||||
|
|
||||||
|
check_key = self.run_key('-p {0}'.format(min_name))
|
||||||
|
self.assertEqual([], check_key)
|
||||||
|
|
||||||
def test_list_accepted_args(self):
|
def test_list_accepted_args(self):
|
||||||
'''
|
'''
|
||||||
test salt-key -l for accepted arguments
|
test salt-key -l for accepted arguments
|
||||||
|
Loading…
Reference in New Issue
Block a user