def the_user_should_not_be_able_to_log_in_ssh_with_the_old_password_then_try_to_ssh_with_the_new_password_for_that_user( driver, nas_ip): """the user should not be able to log in ssh with the old password, then try to ssh with the new password for that user.""" time.sleep(1) ## check SSH global ssh_result1 ssh_result1 = ssh_cmd('ls /', 'ericbsd', 'testing', nas_ip) assert not ssh_result1['result'], ssh_result1['output'] assert 'home' not in ssh_result1['output'], ssh_result1['output'] time.sleep(1) ## check SSH global ssh_result2 ssh_result2 = ssh_cmd('ls /', 'ericbsd', 'testing1234', nas_ip) assert ssh_result2['result'], ssh_result2['output'] assert 'home' in ssh_result2['output'], ssh_result2['output']
def verify_that_the_is_on_nas_ip_with_root_and_password( driver, nas_ip, root_password): global results cmd = 'ls -la /mnt/system/my_acl_dataset/' results = ssh_cmd(cmd, 'root', root_password, nas_ip) assert results['result'], results['output'] assert 'testfile' in results['output'], results['output']
def ssh_to_a_nas_with_root_and_the_root_password_should_work( driver, root_password, nas_ip): """ssh to a NAS with root and the root password should work.""" global ssh_result ssh_result = ssh_cmd('ls', 'root', root_password, nas_ip) assert ssh_result['result'], ssh_result['output'] assert 'syslog' in ssh_result['output'], ssh_result['output']
def run_command_trough_ssh_the_ssh_result_should_pass_and_return_user_info( driver, command, root_password, nas_ip, user): """run {command} trough ssh, the ssh result should pass and return {user} info.""" global ssh_result ssh_result = ssh_cmd(command, 'root', root_password, nas_ip) assert ssh_result['result'], ssh_result['output'] assert "eturgeon" in ssh_result['output'], ssh_result['output']
def verify_that_you_can_ssh_with_the_sshkey(driver, nas_ip): """Verify that you can ssh with the sshkey.""" global results cmd = 'ls -al' results = ssh_cmd(cmd, 'root', None, nas_ip) assert results['result'], results['output'] assert 'ssh' in results['output'], results['output']
def kill_a_python_process_with_ssh_to_trigger_core_files_alert( driver, nas_ip, root_password): """kill a python process with ssh to trigger core files alert.""" cmd = 'python3 -c "import os; os.abort()"' results = ssh_cmd(cmd, 'root', root_password, nas_ip) # Command will failed since kills a process assert results['result'] is False, results['output']
def verify_that_the_file_is_on_the_nas_dataset(driver, nas_ip, root_password): """verify that the file is on the NAS dataset.""" global results cmd = 'ls -la /mnt/tank/my_ldap_dataset/' results = ssh_cmd(cmd, 'root', root_password, nas_ip) assert results['result'], results['output'] assert 'testfile' in results['output'], results['output']
def run_cmd1_and_verify_that_ad01administrator_is_in__output( driver, cmd1, root_password, nas_ip, ad_object1): """verify that "AD01\administrator" is in output..""" global ssh_result ssh_result = ssh_cmd(cmd1, 'root', root_password, nas_ip) assert ssh_result['result'], ssh_result['output'] assert ad_object1 in ssh_result['output'], ssh_result['output']
def verify_that_the_file_is_not_on_the_nas(driver, root_password, nas_ip): """verify that the file is not on the NAS.""" global results cmd = 'ls -la /mnt/tank/wheel_dataset/' results = ssh_cmd(cmd, 'root', root_password, nas_ip) assert results['result'], results['output'] assert 'testfile2' not in results['output'], results['output']
def try_login_with_ssh_the_user_should_not_be_able_to_login(driver, nas_ip): """try login with ssh, the user should not be able to login.""" time.sleep(1) ## check SSH global ssh_result ssh_result = ssh_cmd('ls', 'ericbsd', 'testing', nas_ip) assert not ssh_result['result'], ssh_result['output'] assert 'syslog' not in ssh_result['output'], ssh_result['output']
def verify_that_the_is_on_nas_ip_with_root_and_password( driver, root_password, nas_ip): """Verify that the is on nas_ip with root and password.""" global results cmd = 'ls -la /mnt/tank/wheel_dataset/' results = ssh_cmd(cmd, 'root', root_password, nas_ip) assert results['result'], results['output'] assert 'testfile' in results['output'], results['output']
def on_the_dashboard_get_the_ssh_host_key(driver, root_password, nas_ip): """on the Dashboard, get the ssh host key.""" global hostkey_before assert wait_on_element(driver, 10, '//h1[text()="Dashboard"]') results = ssh_cmd('ssh-keyscan 127.0.0.1', 'root', root_password, nas_ip) assert results['result'], results['output'] hostkey_before = results['output'] # refresh the page driver.refresh() assert wait_on_element(driver, 10, '//h1[text()="Dashboard"]') assert wait_on_element(driver, 5, '//span[contains(.,"System Information")]')
def after_remove_the_core_files_in_vardbsystemcores(driver, nas_ip, root_password): """after remove the core files in "/var/db/system/cores".""" cmd = 'rm -f /var/db/system/cores/*' results = ssh_cmd(cmd, 'root', root_password, nas_ip) assert results['result'] is True, results['output']
def run_cmd3(driver, cmd3, root_password, nas_ip): """run cmd3""" global ssh_result ssh_result = ssh_cmd(cmd3, 'root', root_password, nas_ip) assert ssh_result['result'], ssh_result['output'] assert "succeeded" in ssh_result['output'], ssh_result['output']
def run_cmd_on_the_nas_with_ssh(driver, cmd): """run "cmd" on the NAS with ssh.""" global results results = ssh_cmd(cmd, 'root', 'testing', host) assert results[ 'result'], f'STDOUT: {results["output"]}, STDERR: {results["stderr"]}'
def try_to_ssh_in_with_your_sshkey(driver): """Try to ssh in with your sshkey.""" cmd = 'ls -al' global results results = ssh_cmd(cmd, 'ericbsd', None, host) assert results['result'], results['output']
def run_ssh_root_host_with_root_password(driver, host, password): """run ssh root@"{host}" with root password "{password}".""" global ssh_result ssh_result = ssh_cmd('ls -la', 'root', password, host)
def try_to_ssh_in_with_root_and_your_sshkey(driver): """Try to ssh in with root and your sshkey.""" cmd = 'ls -al' global results results = ssh_cmd(cmd, 'root', None, host) assert results['result'], results['output']
def get_the_ssh_host_key_again(driver, root_password, nas_ip): """get the ssh host key again.""" global hostkey_after results = ssh_cmd('ssh-keyscan 127.0.0.1', 'root', root_password, nas_ip) assert results['result'], results['output'] hostkey_after = results['output']
def log_out_and_try_to_log_back_in_with_the_old_password_for_that_user(driver): """Log out and try to log back in with the old password for that user.""" global ssh_result ssh_result = ssh_cmd('ls -la', 'ericbsd', 'testing', host)
def try_login_with_ssh(driver): """Try login with ssh.""" global ssh_result ssh_result = ssh_cmd('ls -la', 'ericbsd', 'testing', host)
def try_to_log_back_in_ssh_with_the_new_password_for_that_user(driver): """Try to log back in ssh with the new password for that user.""" global ssh_result ssh_result = ssh_cmd('ls -la', 'ericbsd', 'testing1', host)