def test_32_store_AD_credentials_in_a_file_for_mount_smbfs(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = f'echo "[{ip}:{ADUSERNAME.upper()}]" > ~/.nsmbrc && ' cmd += f'echo "password={ADPASSWORD}" >> ~/.nsmbrc' results = SSH_TEST(cmd, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_17_Deleting_SMB_file_2_2(): results = SSH_TEST('rm "%s/testfile2"' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_19_Mounting_SMB(): cmd = 'mount_smbfs -N -I %s -W AD01 ' % ip cmd += '"//aduser@testnas/%s" "%s"' % (SMB_NAME, MOUNTPOINT) results = SSH_TEST(cmd, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
if testName is not None and testName != i: continue call([ f"py.test-{version}", "-v", "--junitxml", f"{results_xml}{i}_tests_result.xml" ] + (["-k", testexpr] if testexpr else []) + [f"api2/{i}.py"]) # get useful logs artifacts = f"{workdir}/artifacts/" logs_list = [ "/var/log/middlewared.log", "/var/log/messages", "/var/log/debug.log", "/var/log/console.log" ] if not path.exists(artifacts): makedirs(artifacts) for log in logs_list: get_file(log, artifacts, 'root', 'testing', ip) # get dmesg and put it in artifacs results = SSH_TEST('dmesg -a', 'root', 'testing', ip) dmsg = open(f'{artifacts}/dmesg', 'w') dmsg.writelines(results['output']) dmsg.close() # get core.get_jobs and put it in artifacs results = SSH_TEST('midclt call core.get_jobs | jq .', 'root', 'testing', ip) dmsg = open(f'{artifacts}/core_get_job', 'w') dmsg.writelines(results['output']) dmsg.close()
def test_10_Store_AD_credentials_in_a_file_for_mount_smbfs(): cmd = 'echo "[TESTNAS:ADUSER]" > ~/.nsmbrc && ' cmd += 'echo "password=12345678" >> ~/.nsmbrc' results = SSH_TEST(cmd, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_08_verify_activedirectory_do_not_leak_password_in_middleware_log( request): depends(request, ["ad_setup", "ssh_password"], scope="session") cmd = f"""grep -R "{ADPASSWORD}" /var/log/middlewared.log""" results = SSH_TEST(cmd, user, password, ip) assert results['result'] is False, str(results['output'])
def test_27_restort_sharesec_with_flush_share_info(request): depends(request, ["pool_04"], scope="session") cmd = 'midclt call smb.sharesec._flush_share_info' results = SSH_TEST(cmd, user, password, ip) assert results['result'] is True, results['output']
def test_54_Create_file_on_SMB_share_via_OSX_to_test_permissions(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('touch "%s/testfile.txt"' % MOUNTPOINT, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_56_Deleting_test_file_and_directory_from_SMB_share(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = 'rm -f "%s/tmp/testfile.txt" && ' % MOUNTPOINT cmd += 'rmdir "%s/tmp"' % MOUNTPOINT results = SSH_TEST(cmd, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_52_Create_mount_point_for_SMB_on_OSX_system(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('mkdir -p "%s"' % MOUNTPOINT, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_53_Mount_SMB_share_on_OSX_system(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = 'mount -t smbfs "smb://%s:' % ADUSERNAME cmd += '%s@%s/%s" "%s"' % (ADPASSWORD, ip, SMB_NAME, MOUNTPOINT) results = SSH_TEST(cmd, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_39_unmounting_SMB(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('umount "%s"' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_38_deleting_SMB_file_2_2(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('rm "%s/testfile2"' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_36_copying_SMB_file(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = 'cp "%s/testfile2" "%s/testfile"' % (MOUNTPOINT, MOUNTPOINT) results = SSH_TEST(cmd, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_03_Checking_ntpserver_configured_using_ssh(): cmd = f'fgrep "{ntpServer}" /etc/ntp.conf' results = SSH_TEST(cmd, user, password, ip) assert results['result'] is True, results
def test_57_Verifying_that_test_file_directory_successfully_removed(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = 'find -- "%s/" -prune -type d -empty | grep -q .' % MOUNTPOINT results = SSH_TEST(cmd, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_06_Checking_ntpservers_num_configured_using_ssh(ntp_dict): results = SSH_TEST(f'fgrep -E ^server /etc/ntp.conf', user, password, ip) assert results['result'] is True, results assert len(results['output'].strip().split('\n')) == \ len(ntp_dict['servers']), results['output']
def test_58_Unmount_SMB_share(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('umount -f "%s"' % MOUNTPOINT, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_24_delete_share_info_tdb(request): depends(request, ["pool_04"], scope="session") cmd = 'rm /var/db/system/samba4/share_info.tdb' results = SSH_TEST(cmd, user, password, ip) assert results['result'] is True, results['output']
def test_59_Removing_SMB_mountpoint(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") cmd = 'test -d "%s" && rmdir "%s" || exit 0' % (MOUNTPOINT, MOUNTPOINT) results = SSH_TEST(cmd, OSX_USERNAME, OSX_PASSWORD, OSX_HOST) assert results['result'] is True, results['output']
def test_29_verify_share_info_tdb_is_created(request): depends(request, ["pool_04"], scope="session") cmd = 'test -f /var/db/system/samba4/share_info.tdb' results = SSH_TEST(cmd, user, password, ip) assert results['result'] is True, results['output']
def test_01_Create_an_alert_on_the_remote_system(): cmd = 'echo "[%s] %s" > %s' % (alert_status, alert_msg, alert_file) results = SSH_TEST(cmd, user, password, ip) assert results['result'] is True, results['output']
def test_09_creating_smb_mountpoint(): results = SSH_TEST('mkdir -p "%s" && sync' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_02_Touch_initshutdownscript_script_file(): results = SSH_TEST(f'touch "{TESTSCRIPT}"', user, password, ip) assert results['result'] is True, results['output']
def test_15_Copying_SMB_file(): cmd = 'cp "%s/testfile2" "%s/testfile"' % (MOUNTPOINT, MOUNTPOINT) results = SSH_TEST(cmd, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_08_Delete_script_file(): results = SSH_TEST(f'rm "{TESTSCRIPT}"', user, password, ip) assert results['result'] is True, results['output']
def test_18_Unmounting_SMB(): results = SSH_TEST('umount "%s"' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_03_verify_vmware_get_datastore_do_not_leak_password_in_middleware_log( request): depends(request, ["ssh_password"], scope="session") cmd = f"""grep -R "{os.environ['VMWARE_PASSWORD']}" /var/log/middlewared.log""" results = SSH_TEST(cmd, user, password, ip) assert results['result'] is False, str(results['output'])
def test_20_Creating_SMB_file(): results = SSH_TEST('touch "%s/testfile"' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']
def test_31_creating_smb_mountpoint(request): depends(request, ["pool_04", "ad_01", "ad_02", "ad_10"], scope="session") results = SSH_TEST('mkdir -p "%s" && sync' % MOUNTPOINT, BSD_USERNAME, BSD_PASSWORD, BSD_HOST) assert results['result'] is True, results['output']