Skip to content

Commit

Permalink
Adding SSH test cases
Browse files Browse the repository at this point in the history
-tests for SSH connection
  • Loading branch information
whatarthurcodes committed Sep 19, 2014
1 parent 4d411bd commit 1f993dc
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/test_ssh_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import unittest
from tests.common import load_check
from checks import AgentCheck



class SshTestCase(unittest.TestCase):

def test_ssh(self):

config = {
'instances': [{
'host': 'sdf.org',
'username': 'datadog01',
'password': 'abcd',
'sftp_check': False,
'private_key_file': '',
'add_missing_keys': True
},
{
'host': 'sdf.org',
'username': 'wrongusername',
'password': 'wrongpassword',
'sftp_check': False,
'private_key_file': '',
'add_missing_keys': True
},
{
'host': 'wronghost',
'username': 'datadog01',
'password': 'abcd',
'sftp_check': False,
'private_key_file': '',
'add_missing_keys': True
},
]
}

agentConfig = {}
self.check = load_check('ssh_check', config, agentConfig)

#Testing that connection will work
self.check.check(config['instances'][0])
service = self.check.get_service_checks()
self.assertEqual(service[0].get('status'), AgentCheck.OK)
self.assertEqual(service[0].get('message'), None)

#Testing that bad authentication will raise exception
self.assertRaises(Exception, self.check.check, config['instances'][1])
#Testing that bad hostname will raise exception
self.assertRaises(Exception, self.check.check, config['instances'][2])



2 comments on commit 1f993dc

@whatarthurcodes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remh
Please Review

@whatarthurcodes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra blank lines were cleaned up in next commit

Please sign in to comment.