-
Notifications
You must be signed in to change notification settings - Fork 813
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) | ||
|
||
|
||
|
1f993dc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@remh
Please Review
1f993dc
There was a problem hiding this comment.
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