diff --git a/tests/test_backup.py b/tests/test_backup.py index 579c551d8dfee899b1bd30b072ba819248c4cabb..bf45f087c6cb237a73ae70d12d4a620e9a197f96 100755 --- a/tests/test_backup.py +++ b/tests/test_backup.py @@ -11,11 +11,22 @@ import subprocess import imp from datetime import datetime +GREEN = '\033[92m' +RED = '\033[91m' +DEF = '\033[0m' + os.chdir(os.path.dirname(__file__)) -def test_ssh(server): - status, out = subprocess.getstatusoutput('ssh -o StrictHostKeyChecking=no %s ls /tmp' % server) - return status == 0 +def test_ssh(ip): + cmd = 'ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no %s ls /tmp' % ip + print('Connecting to MediaVault: %s' % cmd) + try: + subprocess.check_output(cmd, shell=True, timeout=2) + print('%sLogged in successfully%s' % (GREEN, DEF)) + except subprocess.CalledProcessError: + print('%sFailed to login using SSH, run ssh-copy-id %s %s' % (RED, ip, DEF)) + return False + return True def test_last_backup_is_recent(server, client): path = '/backup/%s/current' % client @@ -50,4 +61,5 @@ if os.path.isfile('../utils.py'): else: sys.exit(2) else: + print('No BURP_SERVER defined in config, untestable') sys.exit(2)