mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
docstring cleanups for ssh tests
This commit is contained in:
parent
a0d7c4ac9e
commit
5c6b8aea28
1 changed files with 29 additions and 8 deletions
|
@ -22,11 +22,17 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
Test the ssh module
|
||||
'''
|
||||
def setUp(self):
|
||||
'''
|
||||
Set up the ssh module tests
|
||||
'''
|
||||
super(SSHModuleTest, self).setUp()
|
||||
with open(os.path.join(integration.FILES, 'ssh', 'raw')) as fd:
|
||||
self.key = fd.read().strip()
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Tear down the ssh module tests
|
||||
'''
|
||||
if os.path.isfile(AUTHORIZED_KEYS):
|
||||
os.remove(AUTHORIZED_KEYS)
|
||||
if os.path.isfile(KNOWN_HOSTS):
|
||||
|
@ -34,11 +40,14 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
super(SSHModuleTest, self).tearDown()
|
||||
|
||||
def test_auth_keys(self):
|
||||
'''
|
||||
test ssh.auth_keys
|
||||
'''
|
||||
shutil.copyfile(
|
||||
os.path.join(integration.FILES, 'ssh', 'authorized_keys'),
|
||||
AUTHORIZED_KEYS)
|
||||
ret = self.run_function('ssh.auth_keys', ['root', AUTHORIZED_KEYS])
|
||||
self.assertEqual(len(list(ret.items())), 1) # exactply one key is found
|
||||
self.assertEqual(len(list(ret.items())), 1) # exactly one key is found
|
||||
key_data = list(ret.items())[0][1]
|
||||
self.assertEqual(key_data['comment'], 'github.com')
|
||||
self.assertEqual(key_data['enc'], 'ssh-rsa')
|
||||
|
@ -46,9 +55,9 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(key_data['fingerprint'], GITHUB_FINGERPRINT)
|
||||
|
||||
def test_get_known_host(self):
|
||||
"""
|
||||
'''
|
||||
Check that known host information is returned from ~/.ssh/config
|
||||
"""
|
||||
'''
|
||||
shutil.copyfile(
|
||||
os.path.join(integration.FILES, 'ssh', 'known_hosts'),
|
||||
KNOWN_HOSTS)
|
||||
|
@ -60,24 +69,27 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(ret['fingerprint'], GITHUB_FINGERPRINT)
|
||||
|
||||
def test_recv_known_host(self):
|
||||
"""
|
||||
'''
|
||||
Check that known host information is returned from remote host
|
||||
"""
|
||||
'''
|
||||
ret = self.run_function('ssh.recv_known_host', ['root', 'github.com'])
|
||||
self.assertEqual(ret['enc'], 'ssh-rsa')
|
||||
self.assertEqual(ret['key'], self.key)
|
||||
self.assertEqual(ret['fingerprint'], GITHUB_FINGERPRINT)
|
||||
|
||||
def test_check_known_host_add(self):
|
||||
"""
|
||||
'''
|
||||
Check known hosts by its fingerprint. File needs to be updated
|
||||
"""
|
||||
'''
|
||||
arg = ['root', 'github.com']
|
||||
kwargs = {'fingerprint': GITHUB_FINGERPRINT, 'config': KNOWN_HOSTS}
|
||||
ret = self.run_function('ssh.check_known_host', arg, **kwargs)
|
||||
self.assertEqual(ret, 'add')
|
||||
|
||||
def test_check_known_host_update(self):
|
||||
'''
|
||||
ssh.check_known_host update verification
|
||||
'''
|
||||
shutil.copyfile(
|
||||
os.path.join(integration.FILES, 'ssh', 'known_hosts'),
|
||||
KNOWN_HOSTS)
|
||||
|
@ -93,6 +105,9 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(ret, 'update')
|
||||
|
||||
def test_check_known_host_exists(self):
|
||||
'''
|
||||
Verify check_known_host_exists
|
||||
'''
|
||||
shutil.copyfile(
|
||||
os.path.join(integration.FILES, 'ssh', 'known_hosts'),
|
||||
KNOWN_HOSTS)
|
||||
|
@ -108,6 +123,9 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(ret, 'exists')
|
||||
|
||||
def test_rm_known_host(self):
|
||||
'''
|
||||
ssh.rm_known_host
|
||||
'''
|
||||
shutil.copyfile(
|
||||
os.path.join(integration.FILES, 'ssh', 'known_hosts'),
|
||||
KNOWN_HOSTS)
|
||||
|
@ -123,6 +141,9 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
self.assertEqual(ret, 'add')
|
||||
|
||||
def test_set_known_host(self):
|
||||
'''
|
||||
ssh.set_known_host
|
||||
'''
|
||||
# add item
|
||||
ret = self.run_function('ssh.set_known_host', ['root', 'github.com'],
|
||||
config=KNOWN_HOSTS)
|
||||
|
@ -138,7 +159,7 @@ class SSHModuleTest(integration.ModuleCase):
|
|||
config=KNOWN_HOSTS)
|
||||
self.assertEqual(ret['status'], 'exists')
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
loader = TestLoader()
|
||||
tests = loader.loadTestsFromTestCase(SSHModuleTest)
|
||||
print('Setting up Salt daemons to execute tests')
|
||||
|
|
Loading…
Add table
Reference in a new issue