diff --git a/atest/__init__.robot b/atest/__init__.robot index 436dc2aef..97ff6c017 100644 --- a/atest/__init__.robot +++ b/atest/__init__.robot @@ -1,3 +1,2 @@ *** Settings *** -Force Tags Regression - +Force Tags regression diff --git a/atest/connections.robot b/atest/connections.robot index a3fedf0e8..59256852d 100644 --- a/atest/connections.robot +++ b/atest/connections.robot @@ -1,132 +1,139 @@ *** Settings *** -Resource resources/common.robot -Test Teardown Close All Connections +Resource resources/common.robot + +Test Teardown Close All Connections + *** Test Cases *** Open Connection - Open Connection ${HOST} + Open Connection ${HOST} Close Connection - [Setup] Login As Valid User + [Setup] Login As Valid User Close Connection Connection Should Be Closed Close Connection Fails If No Connection - Run Keyword And Expect Error No open connection. Close Connection + Run Keyword And Expect Error No open connection. Close Connection Switch Connection - ${conn1_id} = Open Connection ${HOST} alias=one prompt=${PROMPT} - Login ${USERNAME} ${PASSWORD} - Write cd /tmp + ${conn1_id} = Open Connection ${HOST} alias=one prompt=${PROMPT} + Login ${USERNAME} ${PASSWORD} + Write cd /tmp Read Until Prompt - ${conn_id2} = Open Connection ${HOST} alias=second prompt=${PROMPT} - Login ${USERNAME} ${PASSWORD} - ${prev id} = Switch Connection ${conn1_id} - Should Be Equal ${prev id} ${conn_id2} - Write pwd - ${output} = Read Until Prompt - Should Contain ${output} /tmp - ${prev id} = Switch Connection second - Write pwd - ${result} = Read Until Prompt - Should Contain ${result} ~ + ${conn_id2} = Open Connection ${HOST} alias=second prompt=${PROMPT} + Login ${USERNAME} ${PASSWORD} + ${prev id} = Switch Connection ${conn1_id} + Should Be Equal ${prev id} ${conn_id2} + Write pwd + ${output} = Read Until Prompt + Should Contain ${output} /tmp + ${prev id} = Switch Connection second + Write pwd + ${result} = Read Until Prompt + Should Contain ${result} ~ Switch Connection To None - [Setup] Login As Valid User - Switch Connection ${NONE} + [Setup] Login As Valid User + Switch Connection ${NONE} Connection Should Be Closed Switch to closed connection - Open Connection ${HOST} alias=SUT - Login ${USERNAME} ${PASSWORD} - Execute command ls + Open Connection ${HOST} alias=SUT + Login ${USERNAME} ${PASSWORD} + Execute command ls close connection - Run keyword and expect error Non-existing index or alias 'SUT'. switch connection SUT + Run keyword and expect error Non-existing index or alias 'SUT'. switch connection SUT Get pre-login banner without open connection - [Tags] no-gh-actions - ${banner} = Get Pre Login Banner ${HOST} - Should Be Equal ${banner} Testing pre-login banner\n + [Tags] no-gh-actions + ${banner} = Get Pre Login Banner ${HOST} + Should Be Equal ${banner} Testing pre-login banner\n Get pre-login banner from current connection - Open Connection ${HOST} prompt=${PROMPT} - Login ${USERNAME} ${PASSWORD} - ${banner} = Get Pre Login Banner - Should Be Equal ${banner} Testing pre-login banner\n + Open Connection ${HOST} prompt=${PROMPT} + Login ${USERNAME} ${PASSWORD} + ${banner} = Get Pre Login Banner + Should Be Equal ${banner} Testing pre-login banner\n Switch Connection When Previous Connection Was Closed - Open Connection ${HOST} alias=alias1 - Open Connection ${HOST} alias=alias2 - Switch Connection alias1 + Open Connection ${HOST} alias=alias1 + Open Connection ${HOST} alias=alias2 + Switch Connection alias1 Close Connection Connection Should Be Closed - ${old_index}= Switch Connection alias2 - Should Be Equal As Strings ${old_index} None - Run Keyword And Expect Error Non-existing index or alias 'alias1'. Switch Connection alias1 - ${conn}= Get Connection - Should Be Equal As Strings ${conn.index} 2 - Should Be Equal As Strings ${conn.alias} alias2 + ${old_index} = Switch Connection alias2 + Should Be Equal As Strings ${old_index} None + Run Keyword And Expect Error Non-existing index or alias 'alias1'. Switch Connection alias1 + ${conn} = Get Connection + Should Be Equal As Strings ${conn.index} 2 + Should Be Equal As Strings ${conn.alias} alias2 Switch Connection Using Index When Previous Connection Was Closed - Open Connection ${HOST} - Open Connection ${HOST} - Switch Connection 1 + Open Connection ${HOST} + Open Connection ${HOST} + Switch Connection 1 Close Connection Connection Should Be Closed - Switch Connection 2 - Run Keyword And Expect Error Non-existing index or alias '1'. Switch Connection 1 - ${conn}= Get Connection - Should Be Equal As Strings ${conn.index} 2 + Switch Connection 2 + Run Keyword And Expect Error Non-existing index or alias '1'. Switch Connection 1 + ${conn} = Get Connection + Should Be Equal As Strings ${conn.index} 2 Open Connection When Previous Connection Was Closed - Open Connection ${HOST} alias=alias1 + Open Connection ${HOST} alias=alias1 Close Connection Connection Should Be Closed - ${idx}= Open Connection ${HOST} alias=alias2 - Should Be Equal ${idx} ${2} - ${conn}= Get Connection 2 - Should Be Equal ${conn.index} ${2} - Should Be Equal ${conn.alias} alias2 - ${conn}= Get Connection alias2 - Should Be Equal ${conn.index} ${2} - Should Be Equal ${conn.alias} alias2 + ${idx} = Open Connection ${HOST} alias=alias2 + Should Be Equal ${idx} ${2} + ${conn} = Get Connection 2 + Should Be Equal ${conn.index} ${2} + Should Be Equal ${conn.alias} alias2 + ${conn} = Get Connection alias2 + Should Be Equal ${conn.index} ${2} + Should Be Equal ${conn.alias} alias2 Reuse Closed Connection Alias - Open Connection ${HOST} alias=alias1 + Open Connection ${HOST} alias=alias1 Close Connection Connection Should Be Closed - Open Connection ${HOST} alias=alias1 - ${conn}= Get Connection 2 - Should Be Equal ${conn.index} ${2} - Should Be Equal ${conn.alias} alias1 - ${conn}= Get Connection alias1 - Should Be Equal ${conn.index} ${2} - Should Be Equal ${conn.alias} alias1 + Open Connection ${HOST} alias=alias1 + ${conn} = Get Connection 2 + Should Be Equal ${conn.index} ${2} + Should Be Equal ${conn.alias} alias1 + ${conn} = Get Connection alias1 + Should Be Equal ${conn.index} ${2} + Should Be Equal ${conn.alias} alias1 Connection To Host Read From SSH Config File - Open Connection ${TEST_HOSTNAME} - Login ${USERNAME} ${PASSWORD} read_config=True + Open Connection ${TEST_HOSTNAME} + Login ${USERNAME} ${PASSWORD} read_config=True Connection To Host Ignoring SSH Config File - Open Connection ${TEST_HOSTNAME} - Run Keyword And Expect Error *Err* Login ${USERNAME} ${PASSWORD} read_config=False - Run Keyword And Expect Error *Err* Login With Public Key ${KEY USERNAME} ${KEY} read_config=False + Open Connection ${TEST_HOSTNAME} + Run Keyword And Expect Error *Err* Login ${USERNAME} ${PASSWORD} read_config=False + Run Keyword And Expect Error *Err* Login With Public Key ${KEY USERNAME} ${KEY} read_config=False Write In Teardown Should Not Hang If Auth Failed - Open Connection ${HOST} - Run Keyword And Expect Error Authentication failed* Login ${USERNAME} invalid - [Teardown] Run Keyword And Expect Error *Cannot open session, you need to establish a connection first. Write ls + Open Connection ${HOST} + Run Keyword And Expect Error Authentication failed* Login ${USERNAME} invalid + [Teardown] Run Keyword And Expect Error *Cannot open session, you need to establish a connection first. Write ls Write Bare In Teardown Should Not Hang If Auth Failed - Open Connection ${HOST} - Run Keyword And Expect Error Login with public key failed* Login With Public Key ${USERNAME} ${KEY}_invalid - [Teardown] Run Keyword And Expect Error *Cannot open session, you need to establish a connection first. Write Bare ls + Open Connection ${HOST} + Run Keyword And Expect Error + ... Login with public key failed* + ... Login With Public Key + ... ${USERNAME} + ... ${KEY}_invalid + [Teardown] Run Keyword And Expect Error *Cannot open session, you need to establish a connection first. Write Bare ls Login With Agent - [Tags] no-gh-actions - Open Connection ${HOST} - Login ${KEY USERNAME} allow_agent=True + [Tags] no-gh-actions + Open Connection ${HOST} + Login ${KEY USERNAME} allow_agent=True + *** Keywords *** Connection Should Be Closed - Run Keyword And Expect Error No open connection. Write pwd + Run Keyword And Expect Error No open connection. Write pwd diff --git a/atest/execute_command.robot b/atest/execute_command.robot index d5a6a515b..1ab8fff11 100644 --- a/atest/execute_command.robot +++ b/atest/execute_command.robot @@ -1,19 +1,24 @@ *** Settings *** -Resource resources/shell.robot -Suite Setup Login And Upload Test Scripts -Suite Teardown Remove Test Files And Close Connections -Library OperatingSystem WITH NAME OS -Library DateTime +Resource resources/shell.robot +Library OperatingSystem WITH NAME OS +Library DateTime + +Suite Setup Login And Upload Test Scripts +Suite Teardown Remove Test Files And Close Connections + +Test Tags shell execute_command -Test Tags shell execute_command *** Test Cases *** Execute Timeout - [Documentation] FAIL SSHClientException: Timed out in 3 seconds - ... LOG 1:2 INFO GLOB: *Command no. 1*Command no. 2*Command no. 3* + [Documentation] FAIL SSHClientException: Timed out in 3 seconds + ... LOG 1:2 INFO GLOB: *Command no. 1*Command no. 2*Command no. 3* TRY - Execute Command for i in {1..5}; do echo "Command no. $i"; sleep 1; done timeout=3s output_if_timeout=True - EXCEPT SSHClientException: Timed out in 3 seconds + Execute Command + ... for i in {1..5}; do echo "Command no. $i"; sleep 1; done + ... timeout=3s + ... output_if_timeout=True + EXCEPT SSHClientException: Timed out in 3 seconds Pass Execution Test passed: Command successfully timed out after 3 seconds. EXCEPT AS ${exception} Fail Unexpected exception: ${exception} @@ -21,89 +26,89 @@ Execute Timeout Fail Expected timeout did not occur. Execute Command With Defaults - ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - Should Be Equal ${stdout} This is stdout + ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + Should Be Equal ${stdout} This is stdout Execute Command And Return Stderr - ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... return_stdout=false return_stderr=yes - Should Be Equal ${stderr} This is stderr + ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... return_stdout=false return_stderr=yes + Should Be Equal ${stderr} This is stderr Execute Command And Return Rc - ${rc} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... return_stdout=False return_rc=${true} - Should Be Equal As Integers ${rc} 0 + ${rc} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... return_stdout=False return_rc=${true} + Should Be Equal As Integers ${rc} 0 Execute Command And Return All Values - ${stdout} ${stderr} ${rc} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... foo bar baz - Should Be Equal ${stdout} This is stdout - Should Be Equal ${stderr} This is stderr - Should Be Equal As Integers ${rc} 0 + ${stdout} ${stderr} ${rc} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... foo bar baz + Should Be Equal ${stdout} This is stdout + Should Be Equal ${stderr} This is stderr + Should Be Equal As Integers ${rc} 0 Execute Command With Output Containing Newlines - ${result} = Execute Command echo -e "\n\nfoo" - Should Be Equal ${result} \n\nfoo + ${result} = Execute Command echo -e "\n\nfoo" + Should Be Equal ${result} \n\nfoo Execute Command With Multiple Statements - ${result} = Execute Command echo "foo\n"; echo RC=$? - Should Be Equal ${result} foo\n\nRC=0 + ${result} = Execute Command echo "foo\n"; echo RC=$? + Should Be Equal ${result} foo\n\nRC=0 Executing Command With Non-ASCII characters - ${result}= Execute Command echo 'aaääöö' - Should Contain ${result} aaääöö + ${result} = Execute Command echo 'aaääöö' + Should Contain ${result} aaääöö Execute Command With Legacy Stdout Config - ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... STDout - Should Be Equal ${stdout} This is stdout + ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... STDout + Should Be Equal ${stdout} This is stdout Execute Command With Legacy Stderr Config - ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... stderr - Should Be Equal ${stderr} This is stderr + ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... stderr + Should Be Equal ${stderr} This is stderr Execute Command With Timeout Argument - Run Keyword And Expect Error SSHClientException: Timed out in * seconds - ... Execute Command cat timeout=1s - Run Keyword And Expect Error SSHClientException: Timed out in * seconds - ... Execute Command sleep 5 timeout=2s + Run Keyword And Expect Error SSHClientException: Timed out in * seconds + ... Execute Command cat timeout=1s + Run Keyword And Expect Error SSHClientException: Timed out in * seconds + ... Execute Command sleep 5 timeout=2s Execute Command With Legacy Stdout And Stderr Config - ${stdout} ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ... Both - Should Be Equal ${stdout} This is stdout - Should Be Equal ${stderr} This is stderr + ${stdout} ${stderr} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ... Both + Should Be Equal ${stdout} This is stdout + Should Be Equal ${stderr} This is stderr Execute Command With Huge Output - [Timeout] 5 seconds - Execute Command echo 'foo\\nbar\\n' > file.txt - Execute Command for i in {1..20}; do cat file.txt file.txt > file2.txt && mv file2.txt file.txt; done - Execute Command cat file.txt - [Teardown] Execute Command rm file.txt + [Timeout] 5 seconds + Execute Command echo 'foo\\nbar\\n' > file.txt + Execute Command for i in {1..20}; do cat file.txt file.txt > file2.txt && mv file2.txt file.txt; done + Execute Command cat file.txt + [Teardown] Execute Command rm file.txt Execute Sudo Command With Correct Password - ${stdout} = Execute Command -k pwd sudo=True sudo_password=test - Should Be Equal ${stdout} ${REMOTE HOME TEST} + ${stdout} = Execute Command -k pwd sudo=True sudo_password=test + Should Be Equal ${stdout} ${REMOTE HOME TEST} Execute Sudo Command With Incorrect Password - ${stdout} = Execute Command -k pwd sudo=True sudo_password=test123 - Should Not Contain ${stdout} ${REMOTE HOME TEST} + ${stdout} = Execute Command -k pwd sudo=True sudo_password=test123 + Should Not Contain ${stdout} ${REMOTE HOME TEST} Execute Time Consuming Sudo Command - ${stdout} = Execute Command -k sleep 5; echo cat sudo=True sudo_password=test - Should Contain ${stdout} cat + ${stdout} = Execute Command -k sleep 5; echo cat sudo=True sudo_password=test + Should Contain ${stdout} cat Execute Command With Invoke Subsystem - ${stdout} = Execute Command subsys invoke_subsystem=yes - Should Be Equal ${stdout} Subsystem invoked. + ${stdout} = Execute Command subsys invoke_subsystem=yes + Should Be Equal ${stdout} Subsystem invoked. Execute Command With Timeout - Run Keyword and Expect Error *Timed out in 5 seconds Execute Command sleep 10 timeout=5s + Run Keyword and Expect Error *Timed out in 5 seconds Execute Command sleep 10 timeout=5s Execute Command In Certain Amount Of Time - ${start_time}= Get Current Date result_format=epoch exclude_millis=True - Execute Command for i in {1..3}; do echo "Command no. $i"; sleep 1; done timeout=5s - ${end_time}= Get Current Date result_format=epoch exclude_millis=True - ${execution_time}= Subtract Time From Time ${end_time} ${start_time} - Should Be True ${execution_time} < 5 + ${start_time} = Get Current Date result_format=epoch exclude_millis=True + Execute Command for i in {1..3}; do echo "Command no. $i"; sleep 1; done timeout=5s + ${end_time} = Get Current Date result_format=epoch exclude_millis=True + ${execution_time} = Subtract Time From Time ${end_time} ${start_time} + Should Be True ${execution_time} < 5 diff --git a/atest/file_and_dir_exists.robot b/atest/file_and_dir_exists.robot index 4d6a63d25..1b185caaa 100644 --- a/atest/file_and_dir_exists.robot +++ b/atest/file_and_dir_exists.robot @@ -1,75 +1,77 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login And Upload Test Files -Suite Teardown Remove Test Files and Close Connections +Resource resources/sftp.robot + +Suite Setup Login And Upload Test Files +Suite Teardown Remove Test Files and Close Connections + *** Test Cases *** Directory Should Exist Using Absolute Path - ${target} = Set Variable ${REMOTE TEST ROOT} - SSH.Directory Should Exist ${target} - Run Keyword And Expect Error Directory '${target}' exists. - ... SSH.Directory Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT} + SSH.Directory Should Exist ${target} + Run Keyword And Expect Error Directory '${target}' exists. + ... SSH.Directory Should Not Exist ${target} Directory Should Not Exist Using Absolute Path - ${target} = Set Variable ${REMOTE TEST ROOT}/not_exists - SSH.Directory Should Not Exist ${target} - Run Keyword And Expect Error Directory '${target}' does not exist. - ... SSH.Directory Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT}/not_exists + SSH.Directory Should Not Exist ${target} + Run Keyword And Expect Error Directory '${target}' does not exist. + ... SSH.Directory Should Exist ${target} Directory Should Exist Using Relative Path - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME} - SSH.Directory Should Exist ${target} - Run Keyword And Expect Error Directory '${target}' exists. - ... SSH.Directory Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME} + SSH.Directory Should Exist ${target} + Run Keyword And Expect Error Directory '${target}' exists. + ... SSH.Directory Should Not Exist ${target} Directory Should Not Exist Using Relative Path - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/not_exists - SSH.Directory Should Not Exist ${target} - Run Keyword And Expect Error Directory '${target}' does not exist. - ... SSH.Directory Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/not_exists + SSH.Directory Should Not Exist ${target} + Run Keyword And Expect Error Directory '${target}' does not exist. + ... SSH.Directory Should Exist ${target} Directory Should Exist Using Current Path - ${target} = Set Variable . - SSH.Directory Should Exist ${target} - Run Keyword And Expect Error Directory '${target}' exists. - ... SSH.Directory Should Not Exist ${target} + ${target} = Set Variable . + SSH.Directory Should Exist ${target} + Run Keyword And Expect Error Directory '${target}' exists. + ... SSH.Directory Should Not Exist ${target} File Should Exist Using Absolute Path - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} - SSH.File Should Exist ${target} - Run Keyword And Expect Error File '${target}' exists. - ... SSH.File Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} + SSH.File Should Exist ${target} + Run Keyword And Expect Error File '${target}' exists. + ... SSH.File Should Not Exist ${target} File Should Not Exist Using Absolute Path - ${target} = Set Variable ${REMOTE TEST ROOT}/not_exists - SSH.File Should Not Exist ${target} - Run Keyword And Expect Error File '${target}' does not exist. - ... SSH.File Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT}/not_exists + SSH.File Should Not Exist ${target} + Run Keyword And Expect Error File '${target}' does not exist. + ... SSH.File Should Exist ${target} File Should Exist Using Relative Path - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} - SSH.File Should Exist ${target} - Run Keyword And Expect Error File '${target}' exists. - ... SSH.File Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} + SSH.File Should Exist ${target} + Run Keyword And Expect Error File '${target}' exists. + ... SSH.File Should Not Exist ${target} File Should Not Exist Using Relative Path - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/not_exists - SSH.File Should Not Exist ${target} - Run Keyword And Expect Error File '${target}' does not exist. - ... SSH.File Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/not_exists + SSH.File Should Not Exist ${target} + Run Keyword And Expect Error File '${target}' does not exist. + ... SSH.File Should Exist ${target} File Should Exist Using GLOB Patterns - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/?[a][!b]*.txt - SSH.File Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/?[a][!b]*.txt + SSH.File Should Exist ${target} File Should Not Exist Using GLOB Patterns - ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/?[a]z[!b]*.txt - SSH.File Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/?[a]z[!b]*.txt + SSH.File Should Not Exist ${target} Directory Should Exist Using GLOB Patterns - ${target} = Set Variable ${REMOTE TEST ROOT}/[abcDAWF][!b]?* - SSH.Directory Should Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT}/[abcDAWF][!b]?* + SSH.Directory Should Exist ${target} Directory Should Not Exist Using GLOB Patterns - ${target} = Set Variable ${REMOTE TEST ROOT}/z* - SSH.Directory Should Not Exist ${target} + ${target} = Set Variable ${REMOTE TEST ROOT}/z* + SSH.Directory Should Not Exist ${target} diff --git a/atest/get_connection.robot b/atest/get_connection.robot index ecda2078b..860cecb15 100644 --- a/atest/get_connection.robot +++ b/atest/get_connection.robot @@ -1,99 +1,101 @@ *** Settings *** -Resource resources/common.robot -Test Teardown Close All Connections -Library OperatingSystem +Resource resources/common.robot +Library OperatingSystem + +Test Teardown Close All Connections + *** Test Cases *** Get Connection - ${conn1_index} = Open Connection ${HOST} alias=one - ${conn2_index} = Open Connection ${HOST} - ${conn} = Get Connection - Should Be Equal ${conn.index} ${conn2_index} - ${conn} = Get Connection one - Should Be Equal ${conn.index} ${conn1_index} - ${conn} = Get Connection 2 - Should Be Equal ${conn.index} ${conn2_index} + ${conn1_index} = Open Connection ${HOST} alias=one + ${conn2_index} = Open Connection ${HOST} + ${conn} = Get Connection + Should Be Equal ${conn.index} ${conn2_index} + ${conn} = Get Connection one + Should Be Equal ${conn.index} ${conn1_index} + ${conn} = Get Connection 2 + Should Be Equal ${conn.index} ${conn2_index} Get Connection When No Connection Is Open - ${conn}= Get Connection 1 - Should Be Equal ${conn.host} ${None} - Should Be Equal ${conn.index} ${None} - Should Be Equal ${conn.alias} ${None} - Should Be Equal ${conn.prompt} ${None} - Should Be Equal As Integers ${conn.port} 22 - Should Be Equal As Strings ${conn.newline} \n - Should Be Equal ${conn.encoding} utf8 - Should Be Equal ${conn.term_type} vt100 - Should Be Equal As Integers ${conn.width} 80 - Should Be Equal As Integers ${conn.height} 24 + ${conn} = Get Connection 1 + Should Be Equal ${conn.host} ${None} + Should Be Equal ${conn.index} ${None} + Should Be Equal ${conn.alias} ${None} + Should Be Equal ${conn.prompt} ${None} + Should Be Equal As Integers ${conn.port} 22 + Should Be Equal As Strings ${conn.newline} \n + Should Be Equal ${conn.encoding} utf8 + Should Be Equal ${conn.term_type} vt100 + Should Be Equal As Integers ${conn.width} 80 + Should Be Equal As Integers ${conn.height} 24 Get Connection Closed - Open Connection ${HOST} alias=alias1 + Open Connection ${HOST} alias=alias1 Close Connection - ${conn}= Get Connection 1 - Should Be Equal ${conn.host} ${None} - Should Be Equal ${conn.index} ${None} - Should Be Equal ${conn.alias} ${None} - Should Be Equal ${conn.prompt} ${None} - Should Be Equal As Integers ${conn.port} 22 - Should Be Equal As Strings ${conn.newline} \n - Should Be Equal ${conn.encoding} utf8 - Should Be Equal ${conn.term_type} vt100 - Should Be Equal As Integers ${conn.width} 80 - Should Be Equal As Integers ${conn.height} 24 + ${conn} = Get Connection 1 + Should Be Equal ${conn.host} ${None} + Should Be Equal ${conn.index} ${None} + Should Be Equal ${conn.alias} ${None} + Should Be Equal ${conn.prompt} ${None} + Should Be Equal As Integers ${conn.port} 22 + Should Be Equal As Strings ${conn.newline} \n + Should Be Equal ${conn.encoding} utf8 + Should Be Equal ${conn.term_type} vt100 + Should Be Equal As Integers ${conn.width} 80 + Should Be Equal As Integers ${conn.height} 24 Get Connection Index Only - Open Connection ${HOST} - ${index}= Get Connection index=True - Should Be Equal As Integers ${index} 1 + Open Connection ${HOST} + ${index} = Get Connection index=True + Should Be Equal As Integers ${index} 1 Get Connection Host And Timeout Only - Open Connection ${HOST} timeout=3 seconds - ${rhost} ${timeout}= Get Connection host=Yes timeout=True port=false - Should Be Equal ${rhost} ${HOST} - Should Be Equal As Integers ${timeout} 3 + Open Connection ${HOST} timeout=3 seconds + ${rhost} ${timeout} = Get Connection host=Yes timeout=True port=false + Should Be Equal ${rhost} ${HOST} + Should Be Equal As Integers ${timeout} 3 Get Connections - Open Connection ${HOST} prompt=>> escape_ansi=True - Open Connection ${HOST} alias=another - ${conns} = Get Connections - Length Should Be ${conns} 2 - Should Be Equal As Integers ${conns[0].index} 1 - Should Be Equal As Integers ${conns[1].index} 2 - Should Be Equal ${conns[0].host} ${HOST} - Should Be Equal ${conns[1].host} ${HOST} - Should Be Equal ${conns[0].prompt} >> - Should Be Equal ${conns[1].alias} another - Should Be Equal ${conns[0].term_type} vt100 - Should Be Equal ${conns[0].escape_ansi} True - Should Be Equal ${conns[1].escape_ansi} False + Open Connection ${HOST} prompt=>> escape_ansi=True + Open Connection ${HOST} alias=another + ${conns} = Get Connections + Length Should Be ${conns} 2 + Should Be Equal As Integers ${conns[0].index} 1 + Should Be Equal As Integers ${conns[1].index} 2 + Should Be Equal ${conns[0].host} ${HOST} + Should Be Equal ${conns[1].host} ${HOST} + Should Be Equal ${conns[0].prompt} >> + Should Be Equal ${conns[1].alias} another + Should Be Equal ${conns[0].term_type} vt100 + Should Be Equal ${conns[0].escape_ansi} True + Should Be Equal ${conns[1].escape_ansi} False Get Connections Returns Only Open Connections - Open Connection ${HOST} prompt=>> - Open Connection ${HOST} alias=to_be_closed - Open Connection ${HOST} alias=another - Switch Connection to_be_closed + Open Connection ${HOST} prompt=>> + Open Connection ${HOST} alias=to_be_closed + Open Connection ${HOST} alias=another + Switch Connection to_be_closed Close Connection - ${conns} = Get Connections - Length Should Be ${conns} 2 - Should Be Equal As Integers ${conns[0].index} 1 - Should Be Equal As Integers ${conns[1].index} 3 - Should Be Equal ${conns[0].host} ${HOST} - Should Be Equal ${conns[1].host} ${HOST} - Should Be Equal ${conns[0].prompt} >> - Should Be Equal ${conns[1].alias} another - Should Be Equal ${conns[0].term_type} vt100 + ${conns} = Get Connections + Length Should Be ${conns} 2 + Should Be Equal As Integers ${conns[0].index} 1 + Should Be Equal As Integers ${conns[1].index} 3 + Should Be Equal ${conns[0].host} ${HOST} + Should Be Equal ${conns[1].host} ${HOST} + Should Be Equal ${conns[0].prompt} >> + Should Be Equal ${conns[1].alias} another + Should Be Equal ${conns[0].term_type} vt100 Get Connections Returns Empty List When No Connections - ${conns} = Get Connections - ${empty_list} = Create List - Should Be Equal ${conns} ${empty_list} + ${conns} = Get Connections + ${empty_list} = Create List + Should Be Equal ${conns} ${empty_list} Get Connections Returns Empty List When All Connections Are Closed - Open Connection ${HOST} + Open Connection ${HOST} Close Connection - Open Connection ${HOST} + Open Connection ${HOST} Close Connection - ${conns} = Get Connections - ${empty_list} = Create List - Should Be Equal ${conns} ${empty_list} + ${conns} = Get Connections + ${empty_list} = Create List + Should Be Equal ${conns} ${empty_list} diff --git a/atest/get_directory.robot b/atest/get_directory.robot index db124c180..eb015d4e5 100644 --- a/atest/get_directory.robot +++ b/atest/get_directory.robot @@ -1,138 +1,143 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login and Upload Test Files -Suite Teardown Remove Test Files And Close Connections -Library OperatingSystem WITH NAME OS -Library DateTime +Resource resources/sftp.robot +Library OperatingSystem WITH NAME OS +Library DateTime + +Suite Setup Login and Upload Test Files +Suite Teardown Remove Test Files And Close Connections + *** Test Cases *** Get Directory To Existing Local Path - [Setup] Create Directory ${LOCAL TMPDIR} - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} - Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} + Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory To Existing Local Path With SCP (transfer) - [Setup] Create Directory ${LOCAL TMPDIR} - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=TRANSFER - Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=TRANSFER + Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory To Existing Local Path With SCP (all) - [Setup] Create Directory ${LOCAL TMPDIR} - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=ALL - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=ALL + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory To Non-Existing Local Path - [Setup] OS.Directory Should Not Exist .${/}tmpdir - SSH.Get Directory ${REMOTE TEST ROOT}/ .${/}tmpdir - Directory Should Exist With Content .${/}tmpdir - [Teardown] Remove Directory .${/}tmpdir recursive=True + [Setup] OS.Directory Should Not Exist .${/}tmpdir + SSH.Get Directory ${REMOTE TEST ROOT}/ .${/}tmpdir + Directory Should Exist With Content .${/}tmpdir + [Teardown] Remove Directory .${/}tmpdir recursive=True Get Directory Including Subdirectories To Existing Local Path - [Setup] Create Directory ${LOCAL TMPDIR} - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory Including Subdirectories To Non-Existing Local Path - [Setup] OS.Directory Should Not Exist my - Get Directory ${REMOTE TEST ROOT} my${/}own${/}tmpdir recursive=True - Directory Should Exist Including Subdirectories my${/}own${/}tmpdir - [Teardown] Remove Directory my recursive=True + [Setup] OS.Directory Should Not Exist my + Get Directory ${REMOTE TEST ROOT} my${/}own${/}tmpdir recursive=True + Directory Should Exist Including Subdirectories my${/}own${/}tmpdir + [Teardown] Remove Directory my recursive=True Get Directory Including Empty Subdirectories - [Setup] Create Directory ${LOCAL TMPDIR} - Execute Command mkdir ${REMOTE TEST ROOT}/empty - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True - OS.Directory Should Exist ${LOCAL TMPDIR}/robot-testdir/empty - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Execute Command mkdir ${REMOTE TEST ROOT}/empty + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True + OS.Directory Should Exist ${LOCAL TMPDIR}/robot-testdir/empty + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory With Square Brackets In Name - [Setup] Create Directory ${LOCAL TMPDIR} - Execute Command mkdir ${REMOTE TEST ROOT}/directory[1] - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True - OS.Directory Should Exist ${LOCAL TMPDIR}${/}robot-testdir/directory[1] - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Execute Command mkdir ${REMOTE TEST ROOT}/directory[1] + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True + OS.Directory Should Exist ${LOCAL TMPDIR}${/}robot-testdir/directory[1] + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory Using Relative Source - [Setup] OS.Directory Should Not Exist my - Get Directory ${REMOTE TEST ROOT NAME} my - Directory Should Exist With Content my - [Teardown] Remove Directory my recursive=True + [Setup] OS.Directory Should Not Exist my + Get Directory ${REMOTE TEST ROOT NAME} my + Directory Should Exist With Content my + [Teardown] Remove Directory my recursive=True Get Directory Should Fail When Source Does Not Exists - Run Keyword And Expect Error There was no directory matching 'non-existing'. - ... SSH.Get Directory non-existing /tmp + Run Keyword And Expect Error There was no directory matching 'non-existing'. + ... SSH.Get Directory non-existing /tmp Get Directory overrrides existing files - [Setup] Create Directory ${LOCAL TMPDIR} - Create File ${LOCAL TMPDIR}${/}${TEST FILE NAME} foo - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - File content should be ${LOCAL TMPDIR}${/}robot-testdir${/}${TEST FILE NAME} This is a test file.\n - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Create File ${LOCAL TMPDIR}${/}${TEST FILE NAME} foo + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + File content should be ${LOCAL TMPDIR}${/}robot-testdir${/}${TEST FILE NAME} This is a test file.\n + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory works if there are existing local directories - [Setup] Create Directory ${LOCAL TMPDIR} - Create directory ${LOCAL TMPDIR}${/}${SUBDIRECTORY NAME}${/}${DIRECTORY WITH EMPTY SUBDIRECTORY}${/}${EMPTY SUB DIR} - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Create directory + ... ${LOCAL TMPDIR}${/}${SUBDIRECTORY NAME}${/}${DIRECTORY WITH EMPTY SUBDIRECTORY}${/}${EMPTY SUB DIR} + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} recursive=True + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory containing a symlink - [Setup] Create Directory ${LOCAL TMPDIR} - Execute Command mkdir ${REMOTE TEST ROOT}/symlink - Execute Command cd ${REMOTE TEST ROOT}/symlink; ln -s ../${TEST FILE NAME} ${SYMLINK TO TEST FILE} - Get Directory ${REMOTE TEST ROOT}/symlink ${LOCAL TMPDIR} - OS.File Should Exist ${LOCAL TMPDIR}${/}symlink${/}${SYMLINK TO TEST FILE} - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Execute Command mkdir ${REMOTE TEST ROOT}/symlink + Execute Command cd ${REMOTE TEST ROOT}/symlink; ln -s ../${TEST FILE NAME} ${SYMLINK TO TEST FILE} + Get Directory ${REMOTE TEST ROOT}/symlink ${LOCAL TMPDIR} + OS.File Should Exist ${LOCAL TMPDIR}${/}symlink${/}${SYMLINK TO TEST FILE} + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory With SCP (transfer) And Preserve Time - [Setup] Create Directory ${LOCAL TMPDIR} - Sleep 15s - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=TRANSFER scp_preserve_times=True - Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir - ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir/test_file.txt - ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir/test_file.txt - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Sleep 15s + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=TRANSFER scp_preserve_times=True + Directory Should Exist With Content ${LOCAL TMPDIR} ${/}robot-testdir + ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir/test_file.txt + ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir/test_file.txt + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True Get Directory With SCP (all) And Preserve Time - [Setup] Create Directory ${LOCAL TMPDIR} - Sleep 15s - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=ALL scp_preserve_times=True - Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir - ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir - ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + [Setup] Create Directory ${LOCAL TMPDIR} + Sleep 15s + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=ALL scp_preserve_times=True + Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir + ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir + ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}robot-testdir + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True + *** Keywords *** File content should be [Arguments] ${file} ${expected} - ${actual}= OS.Get file ${file} + ${actual} = OS.Get file ${file} Should be equal ${actual} ${expected} Directory Should Exist With Content - [Arguments] ${destination} ${parent_folder}=${EMPTY} - OS.File Should Exist ${destination}${parent_folder}${/}${TEST FILE NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH NEWLINES NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SPECIAL CHARS NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SQUARE BRACKETS NAME} - OS.File Should Not Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME} - OS.Directory Should Not Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME} + [Arguments] ${destination} ${parent_folder}=${EMPTY} + OS.File Should Exist ${destination}${parent_folder}${/}${TEST FILE NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH NEWLINES NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SPECIAL CHARS NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SQUARE BRACKETS NAME} + OS.File Should Not Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME} + OS.Directory Should Not Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME} Directory Should Exist Including Subdirectories - [Arguments] ${destination} ${parent_folder}=${EMPTY} - OS.File Should Exist ${destination}${parent_folder}${/}${TEST FILE NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH NEWLINES NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SPECIAL CHARS NAME} - OS.File Should Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME}${/}${FILE WITH NON-ASCII NAME} - OS.Directory Should Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME}${/}${DIRECTORY WITH EMPTY SUBDIRECTORY}${/}${EMPTY SUB DIR} + [Arguments] ${destination} ${parent_folder}=${EMPTY} + OS.File Should Exist ${destination}${parent_folder}${/}${TEST FILE NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH NEWLINES NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${FILE WITH SPECIAL CHARS NAME} + OS.File Should Exist ${destination}${parent_folder}${/}${SUBDIRECTORY NAME}${/}${FILE WITH NON-ASCII NAME} + OS.Directory Should Exist + ... ${destination}${parent_folder}${/}${SUBDIRECTORY NAME}${/}${DIRECTORY WITH EMPTY SUBDIRECTORY}${/}${EMPTY SUB DIR} diff --git a/atest/get_file.robot b/atest/get_file.robot index d7d27755a..d85ed77ed 100644 --- a/atest/get_file.robot +++ b/atest/get_file.robot @@ -1,129 +1,132 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login and Upload Test Files -Suite Teardown Remove Test Files And Close Connections -Test Teardown Remove Directory ${LOCAL TMPDIR} yes -Library OperatingSystem WITH NAME OS -Library DateTime +Resource resources/sftp.robot +Library OperatingSystem WITH NAME OS +Library DateTime + +Suite Setup Login and Upload Test Files +Suite Teardown Remove Test Files And Close Connections +Test Teardown Remove Directory ${LOCAL TMPDIR} yes + *** Test Cases *** Get File Using Absolute Source - SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${LOCAL TMPDIR}${/} - OS.File Should Exist ${LOCAL TMPDIR}${/}${FILE WITH NON-ASCII NAME} - [Teardown] OS.Remove File ${LOCAL TMPDIR}${/}${FILE WITH NON-ASCII NAME} + SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${LOCAL TMPDIR}${/} + OS.File Should Exist ${LOCAL TMPDIR}${/}${FILE WITH NON-ASCII NAME} + [Teardown] OS.Remove File ${LOCAL TMPDIR}${/}${FILE WITH NON-ASCII NAME} Get File Using Relative Source - SSH.Get File ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${TEST FILE NAME} - OS.File Should Exist ${TEST FILE NAME} - [Teardown] OS.Remove File ${TEST FILE NAME} + SSH.Get File ${REMOTE TEST ROOT NAME}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${TEST FILE NAME} + OS.File Should Exist ${TEST FILE NAME} + [Teardown] OS.Remove File ${TEST FILE NAME} Get File Using Pattern As Source - @{expected} = Create List ${TEST FILE NAME} - ... ${FILE WITH NEWLINES NAME} - ${destination} = Set Variable ${LOCAL TMPDIR}${/} - SSH.Get File ${REMOTE TEST ROOT}/*est*.txt ${destination} - FOR ${filename} IN @{expected} - OS.File Should Exist ${destination}${/}${filename} + @{expected} = Create List ${TEST FILE NAME} + ... ${FILE WITH NEWLINES NAME} + ${destination} = Set Variable ${LOCAL TMPDIR}${/} + SSH.Get File ${REMOTE TEST ROOT}/*est*.txt ${destination} + FOR ${filename} IN @{expected} + OS.File Should Exist ${destination}${/}${filename} END Get File From Path Not Under Remote Home - [Setup] Create Tmp Dir And Move File - SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - [Teardown] Remove Tmp Dir And Remote File + [Setup] Create Tmp Dir And Move File + SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + [Teardown] Remove Tmp Dir And Remote File Get File From Path Not Under Remote Home With SCP (transfer) - [Setup] Create Tmp Dir And Move File - SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=TRANSFER - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - [Teardown] Remove Tmp Dir And Remote File + [Setup] Create Tmp Dir And Move File + SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=TRANSFER + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + [Teardown] Remove Tmp Dir And Remote File Get File From Path Not Under Remote Home With SCP (all) - [Setup] Create Tmp Dir And Move File - SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=ALL - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - [Teardown] Remove Tmp Dir And Remote File + [Setup] Create Tmp Dir And Move File + SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=ALL + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + [Teardown] Remove Tmp Dir And Remote File Get File With SCP And Pattern Matching - [Setup] Create Tmp Dir And Move File - SSH.Get File ${REMOTE TEST ROOT}/*est*.txt ${LOCAL TMPDIR}${/} scp=ALL - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - OS.File Should Exist ${LOCAL TMPDIR}${/}Test_newlines.txt + [Setup] Create Tmp Dir And Move File + SSH.Get File ${REMOTE TEST ROOT}/*est*.txt ${LOCAL TMPDIR}${/} scp=ALL + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + OS.File Should Exist ${LOCAL TMPDIR}${/}Test_newlines.txt Get File With Multiple Sources To Single File Fails Run Keyword And Expect Error - ... Cannot copy multiple source files to one destination file. - ... SSH.Get File ${REMOTE TEST ROOT}/*.txt ${LOCAL TMPDIR}${/}foo + ... Cannot copy multiple source files to one destination file. + ... SSH.Get File ${REMOTE TEST ROOT}/*.txt ${LOCAL TMPDIR}${/}foo Get File To Different Name - ${new name} = Set Variable foo.txt - SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${new name} - OS.File Should Exist ${new name} - [Teardown] OS.Remove File ${new name} + ${new name} = Set Variable foo.txt + SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} ${new name} + OS.File Should Exist ${new name} + [Teardown] OS.Remove File ${new name} Get File To Current Working Directory - SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} . - OS.File Should Exist ${FILE WITH NON-ASCII NAME} - [Teardown] OS.Remove File ${FILE WITH NON-ASCII NAME} + SSH.Get File ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} . + OS.File Should Exist ${FILE WITH NON-ASCII NAME} + [Teardown] OS.Remove File ${FILE WITH NON-ASCII NAME} Get File With Square Brackets In Name - SSH.Get File ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} ${LOCAL TMPDIR}${/} - OS.File Should Exist ${LOCAL TMPDIR}${/}${FILE WITH SQUARE BRACKETS NAME} + SSH.Get File ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} ${LOCAL TMPDIR}${/} + OS.File Should Exist ${LOCAL TMPDIR}${/}${FILE WITH SQUARE BRACKETS NAME} Get File When Destination Path Does Not Exist - ${target} = Set Variable ${LOCAL TMPDIR}/new/none.txt - SSH.Get File ${REMOTE TEST ROOT}/${TEST FILE NAME} ${target} - OS.File Should Exist ${target} - [Teardown] OS.Remove File ${target} + ${target} = Set Variable ${LOCAL TMPDIR}/new/none.txt + SSH.Get File ${REMOTE TEST ROOT}/${TEST FILE NAME} ${target} + OS.File Should Exist ${target} + [Teardown] OS.Remove File ${target} Get File Should Fail When There Are No Source Files Run Keyword And Expect Error - ... There were no source files matching 'non-existing'. - ... SSH.Get File non-existing + ... There were no source files matching 'non-existing'. + ... SSH.Get File non-existing Get Symlink File - Execute Command cd ${REMOTE TEST ROOT}; ln -s ${TEST FILE NAME} ${SYMLINK TO TEST FILE} - SSH.Get File ${REMOTE TEST ROOT}/${SYMLINK TO TEST FILE} . - OS.File Should Exist ${SYMLINK TO TEST FILE} - [Teardown] OS.Remove File ${SYMLINK TO TEST FILE} + Execute Command cd ${REMOTE TEST ROOT}; ln -s ${TEST FILE NAME} ${SYMLINK TO TEST FILE} + SSH.Get File ${REMOTE TEST ROOT}/${SYMLINK TO TEST FILE} . + OS.File Should Exist ${SYMLINK TO TEST FILE} + [Teardown] OS.Remove File ${SYMLINK TO TEST FILE} Get File That Is A Symlink Directory - Execute Command mkdir -p ${REMOTE TEST ROOT}/dir/subdir - Execute Command touch ${REMOTE TEST ROOT}/dir/${TEST FILE NAME} - Execute Command cd ${REMOTE TEST ROOT};ln -s dir/subdir symlink_dir - SSH.Get File ${REMOTE TEST ROOT}/dir/* - OS.File Should Not Exist symlink_dir - [Teardown] OS.Remove File ${TEST FILE NAME} + Execute Command mkdir -p ${REMOTE TEST ROOT}/dir/subdir + Execute Command touch ${REMOTE TEST ROOT}/dir/${TEST FILE NAME} + Execute Command cd ${REMOTE TEST ROOT};ln -s dir/subdir symlink_dir + SSH.Get File ${REMOTE TEST ROOT}/dir/* + OS.File Should Not Exist symlink_dir + [Teardown] OS.Remove File ${TEST FILE NAME} Get File With SCP (transfer) And Preserve Time - [Setup] Create Tmp Dir And Move File - Sleep 15s - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=TRANSFER scp_preserve_times=True - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt - ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Remove Tmp Dir And Remote File + [Setup] Create Tmp Dir And Move File + Sleep 15s + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=TRANSFER scp_preserve_times=True + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt + ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Remove Tmp Dir And Remote File Get File With SCP (all) And Preserve Time - [Setup] Create Tmp Dir And Move File - Sleep 15s - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=ALL scp_preserve_times=True - OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt - ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt - ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Remove Tmp Dir And Remote File + [Setup] Create Tmp Dir And Move File + Sleep 15s + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + SSH.Get File /tmp/test_file.txt ${LOCAL TMPDIR}${/} scp=ALL scp_preserve_times=True + OS.File Should Exist ${LOCAL TMPDIR}${/}test_file.txt + ${last_access_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt + ${last_modify_time} = Run stat -c %X ${LOCAL TMPDIR}${/}test_file.txt + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Remove Tmp Dir And Remote File + *** Keywords *** Create Tmp Dir And Move File - Put File ${TEST FILE} /tmp/ - Create Directory ${LOCAL TMPDIR} + Put File ${TEST FILE} /tmp/ + Create Directory ${LOCAL TMPDIR} Remove Tmp Dir And Remote File - Execute Command rm -f /tmp/test_file.txt - Remove Directory ${LOCAL TMPDIR} yes + Execute Command rm -f /tmp/test_file.txt + Remove Directory ${LOCAL TMPDIR} yes diff --git a/atest/importing_with_args.robot b/atest/importing_with_args.robot index 3fc8c54b3..95b15754c 100644 --- a/atest/importing_with_args.robot +++ b/atest/importing_with_args.robot @@ -1,21 +1,23 @@ *** Settings *** -Library SSHLibrary 3 minutes 30 seconds ${NONE} >> INFO ${NONE} -... ${NONE} ${NONE} \\ +Library SSHLibrary 3 minutes 30 seconds ${NONE} >> INFO ${NONE} +... ${NONE} ${NONE} \\ + *** Test Cases *** Importing Library With Arguments - [Setup] Open Connections - ${conn}= Get Connections - Should Be Equal As Integers ${conn[0].timeout} 210 - Should Be Equal ${conn[0].prompt} >> - Should Be Equal ${conn[1].path_separator}  \\ - Should Be Equal As Integers ${conn[1].timeout} 60 - Should Be Equal ${conn[1].prompt} >> - Should Be Equal ${conn[1].path_separator}  \\ - [Teardown] Close All Connections + [Setup] Open Connections + ${conn}= Get Connections + Should Be Equal As Integers ${conn[0].timeout} 210 + Should Be Equal ${conn[0].prompt} >> + Should Be Equal ${conn[1].path_separator} \\ + Should Be Equal As Integers ${conn[1].timeout} 60 + Should Be Equal ${conn[1].prompt} >> + Should Be Equal ${conn[1].path_separator} \\ + [Teardown] Close All Connections + *** Keywords *** Open Connections - Open Connection localhost - Set Default Configuration timeout=1 minute - Open Connection localhost + Open Connection localhost + Set Default Configuration timeout=1 minute + Open Connection localhost diff --git a/atest/list_directories_in_directory.robot b/atest/list_directories_in_directory.robot index 596055d53..a30851231 100644 --- a/atest/list_directories_in_directory.robot +++ b/atest/list_directories_in_directory.robot @@ -1,70 +1,72 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login And Upload Test Files -Suite Teardown Remove Test Files and Close Connections -Library Collections +Resource resources/sftp.robot +Library Collections + +Suite Setup Login And Upload Test Files +Suite Teardown Remove Test Files and Close Connections + *** Test Cases *** List Directories Using Absolute Path - ${expected} = Create List ${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT} + Lists Should Be Equal ${listing} ${expected} List Directories Using Relative Path - ${expected} = Create List ${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT NAME} + Lists Should Be Equal ${listing} ${expected} List Directories Using Pattern - ${expected} = Create List ${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT} pattern=aaä* - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT} pattern=aaä* + Lists Should Be Equal ${listing} ${expected} List Directories Using Current Working Directory - ${listing} = List Directories In Directory . - Should Contain ${listing} ${REMOTE TEST ROOT NAME} + ${listing} = List Directories In Directory . + Should Contain ${listing} ${REMOTE TEST ROOT NAME} List Directories Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List ${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory symlink - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List ${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory symlink + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Directories Using Non-ASCII Characters In Path - ${expected} = Create List ${DIRECTORY WITH EMPTY SUBDIRECTORY} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${DIRECTORY WITH EMPTY SUBDIRECTORY} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + Lists Should Be Equal ${listing} ${expected} List Directories With Absolute Paths Using Absolute Path - ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT} absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT} absolute=True + Lists Should Be Equal ${listing} ${expected} List Directories With Absolute Paths Using Relative Path - ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ${target} = Set Variable ${REMOTE TEST ROOT NAME} - ${listing} = List Directories In Directory ${target} absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ${target} = Set Variable ${REMOTE TEST ROOT NAME} + ${listing} = List Directories In Directory ${target} absolute=True + Lists Should Be Equal ${listing} ${expected} List Directories With Absolute Paths Using Current Working Directory - ${listing} = List Directories In Directory . absolute=True - Should Contain ${listing} ${REMOTE TEST ROOT} + ${listing} = List Directories In Directory . absolute=True + Should Contain ${listing} ${REMOTE TEST ROOT} List Directories With Absolute Paths Using Pattern - ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory ${REMOTE TEST ROOT} pattern=aaä* - ... absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory ${REMOTE TEST ROOT} pattern=aaä* + ... absolute=True + Lists Should Be Equal ${listing} ${expected} List Directories With Absolute Paths Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ${listing} = List Directories In Directory symlink absolute=True - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ${listing} = List Directories In Directory symlink absolute=True + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Directories Should Fail When Source Path Does Not Exists - ${target} = Set Variable not_exists - Run Keyword And Expect Error There was no directory matching '${target}'. - ... List Directories In Directory ${target} + ${target} = Set Variable not_exists + Run Keyword And Expect Error There was no directory matching '${target}'. + ... List Directories In Directory ${target} diff --git a/atest/list_directory.robot b/atest/list_directory.robot index fd94bc30a..e223f82f7 100644 --- a/atest/list_directory.robot +++ b/atest/list_directory.robot @@ -1,108 +1,110 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login And Upload Test Files -Suite Teardown Remove Test Files and Close Connections -Library Collections +Resource resources/sftp.robot +Library Collections + +Suite Setup Login And Upload Test Files +Suite Teardown Remove Test Files and Close Connections + *** Test Cases *** List Content Using Absolute Path - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${SUBDIRECTORY NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Directory ${REMOTE TEST ROOT} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${SUBDIRECTORY NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Directory ${REMOTE TEST ROOT} + Lists Should Be Equal ${listing} ${expected} List Content Using Relative Path - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${SUBDIRECTORY NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Directory ${REMOTE TEST ROOT NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${SUBDIRECTORY NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Directory ${REMOTE TEST ROOT NAME} + Lists Should Be Equal ${listing} ${expected} List Content Using Pattern - ${expected} = Create List ${FILE WITH SPECIAL CHARS NAME} - ${listing} = List Directory ${REMOTE TEST ROOT} pattern=spec* - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${FILE WITH SPECIAL CHARS NAME} + ${listing} = List Directory ${REMOTE TEST ROOT} pattern=spec* + Lists Should Be Equal ${listing} ${expected} List Content Using Current Working Directory - ${listing} = List Directory . - Should Contain ${listing} ${REMOTE TEST ROOT NAME} + ${listing} = List Directory . + Should Contain ${listing} ${REMOTE TEST ROOT NAME} List Content Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${SUBDIRECTORY NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Directory symlink - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${SUBDIRECTORY NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Directory symlink + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Content Using Non-ASCII Characters In Path - ${expected} = Create List ${FILE WITH NON-ASCII NAME} - ... ${DIRECTORY WITH EMPTY SUBDIRECTORY} - ${listing} = List Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${FILE WITH NON-ASCII NAME} + ... ${DIRECTORY WITH EMPTY SUBDIRECTORY} + ${listing} = List Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + Lists Should Be Equal ${listing} ${expected} List Content With Absolute Paths Using Absolute Path - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Directory ${REMOTE TEST ROOT} absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Directory ${REMOTE TEST ROOT} absolute=True + Lists Should Be Equal ${listing} ${expected} List Content With Absolute Paths Using Relative Path - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Directory ${REMOTE TEST ROOT NAME} absolute=True - Lists Should Be Equal ${listing} ${EXPECTED} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Directory ${REMOTE TEST ROOT NAME} absolute=True + Lists Should Be Equal ${listing} ${EXPECTED} List Content With Absolute Paths Using Pattern - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Directory ${REMOTE TEST ROOT} pattern=?est* absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Directory ${REMOTE TEST ROOT} pattern=?est* absolute=True + Lists Should Be Equal ${listing} ${expected} List Content With Absolute Paths Using Current Working Directory - ${listing} = List Directory . absolute=True - Should Contain ${listing} ${REMOTE TEST ROOT} + ${listing} = List Directory . absolute=True + Should Contain ${listing} ${REMOTE TEST ROOT} List Content With Absolute Paths Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Directory symlink absolute=True - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Directory symlink absolute=True + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Content Should Fail When Source Path Not Exists - ${target} = Set Variable not_exists - Run Keyword And Expect Error There was no directory matching '${target}'. - ... List Directory ${target} + ${target} = Set Variable not_exists + Run Keyword And Expect Error There was no directory matching '${target}'. + ... List Directory ${target} diff --git a/atest/list_files_in_directory.robot b/atest/list_files_in_directory.robot index 82114bab7..79216dc37 100644 --- a/atest/list_files_in_directory.robot +++ b/atest/list_files_in_directory.robot @@ -1,103 +1,105 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login And Upload Test Files -Suite Teardown Remove Test Files and Close Connections -Resource resources/sftp.robot -Library Collections +Resource resources/sftp.robot +Resource resources/sftp.robot +Library Collections + +Suite Setup Login And Upload Test Files +Suite Teardown Remove Test Files and Close Connections + *** Test Cases *** List Files Using Absolute Path - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT} + Lists Should Be Equal ${listing} ${expected} List Files Using Relative Path - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT NAME} + Lists Should Be Equal ${listing} ${expected} List Files Using Pattern - ${expected} = Create List ${FILE WITH NEWLINES NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT} pattern=*newlines.txt - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${FILE WITH NEWLINES NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT} pattern=*newlines.txt + Lists Should Be Equal ${listing} ${expected} List Files Using Current Working Directory - ${listing} = List Files In Directory . - Should Not Contain ${listing} ${REMOTE TEST ROOT} + ${listing} = List Files In Directory . + Should Not Contain ${listing} ${REMOTE TEST ROOT} List Files Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List - ... ${FILE WITH NEWLINES NAME} - ... ${CORRUPTED FILE NAME} - ... ${FILE WITH SPECIAL CHARS NAME} - ... ${FILE WITH SQUARE BRACKETS NAME} - ... ${TEST FILE NAME} - ${listing} = List Files In Directory symlink - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List + ... ${FILE WITH NEWLINES NAME} + ... ${CORRUPTED FILE NAME} + ... ${FILE WITH SPECIAL CHARS NAME} + ... ${FILE WITH SQUARE BRACKETS NAME} + ... ${TEST FILE NAME} + ${listing} = List Files In Directory symlink + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Files With Non-ASCII Characters In Path - ${expected} = Create List ${FILE WITH NON-ASCII NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List ${FILE WITH NON-ASCII NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME} + Lists Should Be Equal ${listing} ${expected} List Files With Absolute Paths Using Absolute Path - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT} absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT} absolute=True + Lists Should Be Equal ${listing} ${expected} List Files With Absolute Paths Using Relative Path - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT NAME} absolute=True - Lists Should Be Equal ${listing} ${EXPECTED} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT NAME} absolute=True + Lists Should Be Equal ${listing} ${EXPECTED} List Files With Absolute Paths Using Pattern - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Files In Directory ${REMOTE TEST ROOT} pattern=?est* - ... absolute=True - Lists Should Be Equal ${listing} ${expected} + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Files In Directory ${REMOTE TEST ROOT} pattern=?est* + ... absolute=True + Lists Should Be Equal ${listing} ${expected} List Files With Absolute Paths Using Current Working Directory - ${listing} = List Files In Directory . absolute=True - Should Not Contain ${listing} ${REMOTE TEST ROOT} + ${listing} = List Files In Directory . absolute=True + Should Not Contain ${listing} ${REMOTE TEST ROOT} List Files With Absolute Paths Using Symlink As Path - [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink - ${expected} = Create List - ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} - ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} - ... ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${listing} = List Files In Directory symlink absolute=True - Lists Should Be Equal ${listing} ${expected} - [Teardown] Execute Command rm -f symlink + [Setup] Execute Command ln -s ${REMOTE TEST ROOT} symlink + ${expected} = Create List + ... ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + ... ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SPECIAL CHARS NAME} + ... ${REMOTE TEST ROOT}/${FILE WITH SQUARE BRACKETS NAME} + ... ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${listing} = List Files In Directory symlink absolute=True + Lists Should Be Equal ${listing} ${expected} + [Teardown] Execute Command rm -f symlink List Files Should Fail When Source Path Not Exists - ${target} = Set Variable not_exists - Run Keyword And Expect Error There was no directory matching '${target}'. - ... List Files In Directory ${target} + ${target} = Set Variable not_exists + Run Keyword And Expect Error There was no directory matching '${target}'. + ... List Files In Directory ${target} diff --git a/atest/logging.robot b/atest/logging.robot index 364d4cd41..ae1dcbee3 100644 --- a/atest/logging.robot +++ b/atest/logging.robot @@ -1,23 +1,25 @@ *** Settings *** -Resource resources/common.robot -Test Teardown Close All Connections -Library OperatingSystem +Resource resources/common.robot +Library OperatingSystem + +Test Teardown Close All Connections + *** Test Cases *** Enable Logging - [Setup] Remove File ${OUTPUTDIR}${/}sshlog.txt - Enable SSH Logging ${OUTPUTDIR}${/}sshlog.txt + [Setup] Remove File ${OUTPUTDIR}${/}sshlog.txt + Enable SSH Logging ${OUTPUTDIR}${/}sshlog.txt Login As Valid User - File Should Not Be Empty ${OUTPUTDIR}${/}sshlog.txt + File Should Not Be Empty ${OUTPUTDIR}${/}sshlog.txt Log Level To None - [Documentation] LOG 2.2:1 NONE - ... LOG 2.2:2 NONE - Set Default Configuration loglevel=NONE + [Documentation] LOG 2.2:1 NONE + ... LOG 2.2:2 NONE + Set Default Configuration loglevel=NONE Login As Valid User - [Teardown] Set Default Configuration loglevel=INFO + [Teardown] Set Default Configuration loglevel=INFO Log Level To Info - [Documentation] LOG 1.2:1 GLOB: Logging into * - ... LOG 1.2:2 GLOB: *test@* + [Documentation] LOG 1.2:1 GLOB: Logging into * + ... LOG 1.2:2 GLOB: *test@* Login As Valid User diff --git a/atest/login.robot b/atest/login.robot index 45cbe9572..c1c4eaa9b 100644 --- a/atest/login.robot +++ b/atest/login.robot @@ -1,87 +1,89 @@ *** Settings *** -Resource resources/common.robot -Test Setup Open Connection ${HOST} -Test Teardown Close All Connections +Resource resources/common.robot + +Test Setup Open Connection ${HOST} +Test Teardown Close All Connections + +Test Tags login -Test Tags login *** Variables *** -${KEY DIR} ${LOCAL TESTDATA}${/}keyfiles -${KEY USERNAME} testkey -${KEY} ${KEY DIR}${/}id_rsa -${INVALID USERNAME} invalidusername -${INVALID PASSWORD} invalidpassword -${INVALID KEY} ${KEY DIR}${/}id_rsa_invalid +${KEY DIR} ${LOCAL TESTDATA}${/}keyfiles +${KEY USERNAME} testkey +${KEY} ${KEY DIR}${/}id_rsa +${INVALID USERNAME} invalidusername +${INVALID PASSWORD} invalidpassword +${INVALID KEY} ${KEY DIR}${/}id_rsa_invalid + *** Test Cases *** Login With Valid Username And Password Login As Valid User Login With Invalid Username Or Password - [Setup] Open Connection ${HOST} - Run Keyword And Expect Error Authentication failed for user '${INVALID USERNAME}'. - ... Login ${INVALID USERNAME} ${PASSWORD} + [Setup] Open Connection ${HOST} + Run Keyword And Expect Error Authentication failed for user '${INVALID USERNAME}'. + ... Login ${INVALID USERNAME} ${PASSWORD} Login With Public Key When Valid Username And Key - [Setup] Open Connection ${HOST} prompt=${PROMPT} - Login With Public Key ${KEY USERNAME} ${KEY} + [Setup] Open Connection ${HOST} prompt=${PROMPT} + Login With Public Key ${KEY USERNAME} ${KEY} Login With Public Key When Invalid Username - [Documentation] A username that does not exist on the target machine leads to a rather misleading error message about key lengths. - ... See: https://github.com/fabric/fabric/issues/2182#issuecomment-1362940149 - Run Keyword And Expect Error ValueError: q must be exactly 160, 224, or 256 bits long - ... Login With Public Key ${INVALID USERNAME} ${KEY} + [Documentation] A username that does not exist on the target machine leads to a rather misleading error message about key lengths. + ... See: https://github.com/fabric/fabric/issues/2182#issuecomment-1362940149 + Run Keyword And Expect Error ValueError: q must be exactly 160, 224, or 256 bits long + ... Login With Public Key ${INVALID USERNAME} ${KEY} Login With Public Key When Invalid Key - Run Keyword And Expect Error Login with public key failed for user '${KEY USERNAME}'. - ... Login With Public Key ${KEY USERNAME} ${INVALID KEY} + Run Keyword And Expect Error Login with public key failed for user '${KEY USERNAME}'. + ... Login With Public Key ${KEY USERNAME} ${INVALID KEY} Login With Public Key When Non-Existing Key - Run Keyword And Expect Error Given key file 'not_existing_key' does not exist. - ... Login With Public Key ${KEY USERNAME} not_existing_key + Run Keyword And Expect Error Given key file 'not_existing_key' does not exist. + ... Login With Public Key ${KEY USERNAME} not_existing_key Logging In Returns Server Output - [Setup] Open Connection ${HOST} - ${output}= Login ${USERNAME} ${PASSWORD} - Should Contain ${output} Last login: - ${output}= Read - Should Be Equal ${output.strip()} ${EMPTY} + [Setup] Open Connection ${HOST} + ${output}= Login ${USERNAME} ${PASSWORD} + Should Contain ${output} Last login: + ${output}= Read + Should Be Equal ${output.strip()} ${EMPTY} Logging In Returns Server Output If Prompt Is Set - [Setup] Open Connection ${HOST} prompt=${PROMPT} - ${output}= Login With Public Key ${KEY USERNAME} ${KEY} - Should Contain ${output} Last login: - ${output}= Read - Should Be Equal ${output.strip()} ${EMPTY} + [Setup] Open Connection ${HOST} prompt=${PROMPT} + ${output}= Login With Public Key ${KEY USERNAME} ${KEY} + Should Contain ${output} Last login: + ${output}= Read + Should Be Equal ${output.strip()} ${EMPTY} Login Using Config File - [Setup] Open Connection ${TEST_HOSTNAME} prompt=${PROMPT} - Login password=test read_config=True + [Setup] Open Connection ${TEST_HOSTNAME} prompt=${PROMPT} + Login password=test read_config=True Login With Public Key Using Config File - [Setup] Open Connection ${TESTKEY_HOSTNAME} prompt=${PROMPT} - Login With Public Key read_config=True + [Setup] Open Connection ${TESTKEY_HOSTNAME} prompt=${PROMPT} + Login With Public Key read_config=True Login With No Password - [Setup] Open Connection ${HOST} prompt=${PROMPT} - Login ${USERNAME_NOPASSWD} + [Setup] Open Connection ${HOST} prompt=${PROMPT} + Login ${USERNAME_NOPASSWD} Login With Explicit No Password - [Setup] Open Connection ${HOST} prompt=${PROMPT} + [Setup] Open Connection ${HOST} prompt=${PROMPT} TRY - Login ${USERNAME_NOPASSWD} ${EMPTY_STRING} - EXCEPT Authentication failed for user '${USERNAME_NOPASSWD}'. AS ${ex} + Login ${USERNAME_NOPASSWD} ${EMPTY_STRING} + EXCEPT Authentication failed for user '${USERNAME_NOPASSWD}'. AS ${ex} Pass Execution Authentication with empty password failed as expected: ${ex} END Fail Authentication with empty password should have failed Login With Empty Quotes No Password - [Setup] Open Connection ${HOST} prompt=${PROMPT} - Login ${USERNAME_NOPASSWD} "" + [Setup] Open Connection ${HOST} prompt=${PROMPT} + Login ${USERNAME_NOPASSWD} "" Login Using Config File Proxy Command - [Tags] no-gh-actions - [Setup] Open Connection ${TEST_PROXY_HOSTNAME} prompt=${PROMPT} - ${output}= Login password=test read_config=True - Should Contain ${output} test@ - + [Tags] no-gh-actions + [Setup] Open Connection ${TEST_PROXY_HOSTNAME} prompt=${PROMPT} + ${output}= Login password=test read_config=True + Should Contain ${output} test@ diff --git a/atest/put_directory.robot b/atest/put_directory.robot index 5dd63057c..cc21cf0d9 100644 --- a/atest/put_directory.robot +++ b/atest/put_directory.robot @@ -1,142 +1,148 @@ *** Settings *** -Resource resources/sftp.robot -Suite Setup Login As Valid User -Suite Teardown Close All Connections -Library OperatingSystem WITH NAME OS -Library Collections -Library DateTime +Resource resources/sftp.robot +Library OperatingSystem WITH NAME OS +Library Collections +Library DateTime + +Suite Setup Login As Valid User +Suite Teardown Close All Connections + *** Test Cases *** Put Directory To Existing Remote Path - [Setup] SSH.Directory Should Not Exist textfiles - Put Directory ${LOCAL TEXTFILES} . - Remote Directory Should Exist With Content ./textfiles - [Teardown] Execute Command rm -rf ./textfiles + [Setup] SSH.Directory Should Not Exist textfiles + Put Directory ${LOCAL TEXTFILES} . + Remote Directory Should Exist With Content ./textfiles + [Teardown] Execute Command rm -rf ./textfiles Put Directory To Non-Existing Remote Path - [Setup] SSH.Directory Should Not Exist another_dir_name - Put Directory ${LOCAL TEXTFILES} another_dir_name - Remote Directory Should Exist With Content another_dir_name - [Teardown] Execute Command rm -rf another_dir_name + [Setup] SSH.Directory Should Not Exist another_dir_name + Put Directory ${LOCAL TEXTFILES} another_dir_name + Remote Directory Should Exist With Content another_dir_name + [Teardown] Execute Command rm -rf another_dir_name Put Directory Including Subdirectories To Existing Remote Path - Put Directory ${LOCAL TEXTFILES} . recursive=True - Remote Directory Should Exist With Subdirectories ./textfiles - [Teardown] Execute Command rm -rf ./textfiles + Put Directory ${LOCAL TEXTFILES} . recursive=True + Remote Directory Should Exist With Subdirectories ./textfiles + [Teardown] Execute Command rm -rf ./textfiles Put Directory Including Subdirectories To Existing Remote Path With SCP (transfer) - Put Directory ${LOCAL TEXTFILES} . recursive=True scp=TRANSFER - Remote Directory Should Exist With Subdirectories ./textfiles - [Teardown] Execute Command rm -rf ./textfiles + Put Directory ${LOCAL TEXTFILES} . recursive=True scp=TRANSFER + Remote Directory Should Exist With Subdirectories ./textfiles + [Teardown] Execute Command rm -rf ./textfiles Put Directory Including Subdirectories To Existing Remote Path With SCP (all) - Put Directory ${LOCAL TEXTFILES} . recursive=True scp=ALL - Remote Directory Should Exist With Subdirectories ./textfiles - [Teardown] Execute Command rm -rf ./textfiles + Put Directory ${LOCAL TEXTFILES} . recursive=True scp=ALL + Remote Directory Should Exist With Subdirectories ./textfiles + [Teardown] Execute Command rm -rf ./textfiles Put Directory Including Subdirectories To Non-Existing Remote Path - [Setup] SSH.Directory Should Not Exist another/dir/path - Put Directory ${LOCAL TEXTFILES} another/dir/path recursive=True - Remote Directory Should Exist With Subdirectories another/dir/path - [Teardown] Execute Command rm -rf another + [Setup] SSH.Directory Should Not Exist another/dir/path + Put Directory ${LOCAL TEXTFILES} another/dir/path recursive=True + Remote Directory Should Exist With Subdirectories another/dir/path + [Teardown] Execute Command rm -rf another Put Directory Including Empty Subdirectories - [Setup] OS.Create Directory ${LOCAL TEXTFILES}${/}empty - Put Directory ${LOCAL TEXTFILES} . recursive=True - SSH.Directory Should Exist textfiles/empty - Remote Directory Should Exist With Subdirectories textfiles - [Teardown] Remove Local Empty Directory And Remote Files + [Setup] OS.Create Directory ${LOCAL TEXTFILES}${/}empty + Put Directory ${LOCAL TEXTFILES} . recursive=True + SSH.Directory Should Exist textfiles/empty + Remote Directory Should Exist With Subdirectories textfiles + [Teardown] Remove Local Empty Directory And Remote Files Put Directory With Square Brackets In Name - [Setup] OS.Create Directory ${LOCAL TEXTFILES}${/}directory[1] - Put Directory ${LOCAL TEXTFILES} . recursive=True - SSH.Directory Should Exist textfiles/directory[1] - [Teardown] Remove Local And Remote Directory With Square Brackets + [Setup] OS.Create Directory ${LOCAL TEXTFILES}${/}directory[1] + Put Directory ${LOCAL TEXTFILES} . recursive=True + SSH.Directory Should Exist textfiles/directory[1] + [Teardown] Remove Local And Remote Directory With Square Brackets Put Directory Using Relative Source - [Setup] SSH.Directory Should Not Exist ${REMOTE TEST ROOT} - Put Directory ${CURDIR}${/}testdata${/}textfiles ${REMOTE TEST ROOT} - Remote Directory Should Exist With Content ${REMOTE TEST ROOT} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + [Setup] SSH.Directory Should Not Exist ${REMOTE TEST ROOT} + Put Directory ${CURDIR}${/}testdata${/}textfiles ${REMOTE TEST ROOT} + Remote Directory Should Exist With Content ${REMOTE TEST ROOT} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put Directory Should Fail When Source Does Not Exists - Run Keyword And Expect Error There was no source path matching 'non-existing'. - ... Put Directory non-existing + Run Keyword And Expect Error There was no source path matching 'non-existing'. + ... Put Directory non-existing Put Directory Containing A File With Colon In Its Name - [Tags] linux - [Setup] SSH.Directory Should Not Exist ${REMOTE TEST ROOT} - Create File With Colon Char In Its Name - Put Directory ${CURDIR}${/}testdata${/}textfiles ${REMOTE TEST ROOT} - Check And Remove Local Added Directory ${REMOTE TEST ROOT} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + [Tags] linux + [Setup] SSH.Directory Should Not Exist ${REMOTE TEST ROOT} + Create File With Colon Char In Its Name + Put Directory ${CURDIR}${/}testdata${/}textfiles ${REMOTE TEST ROOT} + Check And Remove Local Added Directory ${REMOTE TEST ROOT} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put Directory And Check For Proper Permissions - [Tags] linux - Put Directory ${CURDIR}${/}testdata${/}to_put recursive=True mode=0755 - ${output}= Execute Command ls - Should Contain ${output} to_put - Check File Permissions 0755 to_put${/}ExampleText3.txt - Check Folder Permissions 0755 - [Teardown] Execute Command rm -rf ${CURDIR}${/}testdata${/}to_put + [Tags] linux + Put Directory ${CURDIR}${/}testdata${/}to_put recursive=True mode=0755 + ${output} = Execute Command ls + Should Contain ${output} to_put + Check File Permissions 0755 to_put${/}ExampleText3.txt + Check Folder Permissions 0755 + [Teardown] Execute Command rm -rf ${CURDIR}${/}testdata${/}to_put Put Directory With SCP (transfer) And Preserve Time - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Put Directory ${LOCAL TEXTFILES} . recursive=True scp=TRANSFER scp_preserve_times=True - Remote Directory Should Exist With Subdirectories ./textfiles - ${last_access_time} = Execute Command stat -c %X ./textfiles/test_file.txt - ${last_modify_time} = Execute Command stat -c %X ./textfiles/test_file.txt - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Execute Command rm -rf ./textfiles + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Put Directory ${LOCAL TEXTFILES} . recursive=True scp=TRANSFER scp_preserve_times=True + Remote Directory Should Exist With Subdirectories ./textfiles + ${last_access_time} = Execute Command stat -c %X ./textfiles/test_file.txt + ${last_modify_time} = Execute Command stat -c %X ./textfiles/test_file.txt + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Execute Command rm -rf ./textfiles Put Directory With SCP (all) And Preserve Time - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Put Directory ${LOCAL TEXTFILES} . recursive=True scp=ALL scp_preserve_times=True - Remote Directory Should Exist With Subdirectories ./textfiles - ${last_access_time} = Execute Command stat -c %X ./textfiles - ${last_modify_time} = Execute Command stat -c %X ./textfiles - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - Remote Directory Should Exist With Subdirectories ./textfiles - [Teardown] Execute Command rm -rf ./textfiles + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Put Directory ${LOCAL TEXTFILES} . recursive=True scp=ALL scp_preserve_times=True + Remote Directory Should Exist With Subdirectories ./textfiles + ${last_access_time} = Execute Command stat -c %X ./textfiles + ${last_modify_time} = Execute Command stat -c %X ./textfiles + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + Remote Directory Should Exist With Subdirectories ./textfiles + [Teardown] Execute Command rm -rf ./textfiles + *** Keywords *** Remove Local Empty Directory And Remote Files - OS.Remove Directory ${LOCAL TEXTFILES}${/}empty - Execute Command rm -rf ./textfiles + OS.Remove Directory ${LOCAL TEXTFILES}${/}empty + Execute Command rm -rf ./textfiles Remove Local And Remote Directory With Square Brackets - OS.Remove Directory ${LOCAL TEXTFILES}${/}directory[1] - Execute Command rm -rf ./textfiles + OS.Remove Directory ${LOCAL TEXTFILES}${/}directory[1] + Execute Command rm -rf ./textfiles Remote Directory Should Exist With Content - [Arguments] ${destination} - SSH.File Should Exist ${destination}/${TEST FILE NAME} - SSH.File Should Exist ${destination}/${FILE WITH NEWLINES NAME} - SSH.File Should Exist ${destination}/${FILE WITH SPECIAL CHARS NAME} - SSH.File Should Not Exist ${destination}/${FILE WITH NON-ASCII NAME} - SSH.Directory Should Not Exist ${destination}/${SUBDIRECTORY NAME} + [Arguments] ${destination} + SSH.File Should Exist ${destination}/${TEST FILE NAME} + SSH.File Should Exist ${destination}/${FILE WITH NEWLINES NAME} + SSH.File Should Exist ${destination}/${FILE WITH SPECIAL CHARS NAME} + SSH.File Should Not Exist ${destination}/${FILE WITH NON-ASCII NAME} + SSH.Directory Should Not Exist ${destination}/${SUBDIRECTORY NAME} Remote Directory Should Exist With Subdirectories - [Arguments] ${destination} - SSH.File Should Exist ${destination}/${TEST FILE NAME} - SSH.File Should Exist ${destination}/${FILE WITH NEWLINES NAME} - SSH.File Should Exist ${destination}/${FILE WITH SPECIAL CHARS NAME} - SSH.File Should Not Exist ${destination}/${FILE WITH NON-ASCII NAME} - SSH.File Should Exist ${destination}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} + [Arguments] ${destination} + SSH.File Should Exist ${destination}/${TEST FILE NAME} + SSH.File Should Exist ${destination}/${FILE WITH NEWLINES NAME} + SSH.File Should Exist ${destination}/${FILE WITH SPECIAL CHARS NAME} + SSH.File Should Not Exist ${destination}/${FILE WITH NON-ASCII NAME} + SSH.File Should Exist ${destination}/${SUBDIRECTORY NAME}/${FILE WITH NON-ASCII NAME} Create File With Colon Char In Its Name - SSH.File Should Not Exist ${COLON CHAR FILE} - OS.Create File ${COLON CHAR FILE} + SSH.File Should Not Exist ${COLON CHAR FILE} + OS.Create File ${COLON CHAR FILE} Check And Remove Local Added Directory - [Arguments] ${destination} - ${files_list} = SSH.List Files In Directory ${destination} - List should contain value ${files_list} ${COLON CHAR FILE_NAME} - [Teardown] OS.Remove File ${COLON CHAR FILE} + [Arguments] ${destination} + ${files_list} = SSH.List Files In Directory ${destination} + List should contain value ${files_list} ${COLON CHAR FILE_NAME} + [Teardown] OS.Remove File ${COLON CHAR FILE} Check Folder Permissions - [Arguments] ${expected_permission} - ${actual_permission}= Execute Command stat -c %a to_put${/}Folder3 - Should Be Equal As Integers ${actual_permission} ${expected_permission} Folder has not expected permission ${expected_permission}:\t${actual_permission} + [Arguments] ${expected_permission} + ${actual_permission} = Execute Command stat -c %a to_put${/}Folder3 + Should Be Equal As Integers + ... ${actual_permission} + ... ${expected_permission} + ... Folder has not expected permission ${expected_permission}:\t${actual_permission} diff --git a/atest/put_file.robot b/atest/put_file.robot index 8776b8b43..61d7943f4 100644 --- a/atest/put_file.robot +++ b/atest/put_file.robot @@ -1,178 +1,184 @@ -*** Settings *** -Resource resources/sftp.robot -Suite Setup Login As Valid User -Suite Teardown Close All Connections -Library OperatingSystem WITH NAME OS -Library String -Library DateTime +*** Settings *** +Resource resources/sftp.robot +Library OperatingSystem WITH NAME OS +Library String +Library DateTime + +Suite Setup Login As Valid User +Suite Teardown Close All Connections + *** Test Cases *** Put File To Absolute Destination - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${FILE WITH NON-ASCII NAME} - Put File ${FILE WITH NON-ASCII}  ${REMOTE TEST ROOT}/ - SSH.File Should Exist ${REMOTE TEST ROOT}/${FILE WITH NON-ASCII NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${FILE WITH NON-ASCII NAME} + Put File ${FILE WITH NON-ASCII} ${REMOTE TEST ROOT}/ + SSH.File Should Exist ${REMOTE TEST ROOT}/${FILE WITH NON-ASCII NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File To Absolute Destination With SCP (transfer) - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Put File ${TEST FILE}  ${REMOTE TEST ROOT}/ scp=TRANSFER - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Put File ${TEST FILE} ${REMOTE TEST ROOT}/ scp=TRANSFER + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File To Absolute Destination With SCP (all) - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Execute Command mkdir ${REMOTE TEST ROOT NAME} - Put File ${TEST FILE}  ${REMOTE TEST ROOT}/ scp=ALL - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Execute Command mkdir ${REMOTE TEST ROOT NAME} + Put File ${TEST FILE} ${REMOTE TEST ROOT}/ scp=ALL + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File To Absolute Destination With Intermediate Subdirectories - SSH.File Should Not Exist ${REMOTE TEST ROOT}/robotdir/${FILE WITH NON-ASCII NAME} - Put File ${FILE WITH NON-ASCII}  ${REMOTE TEST ROOT}/robotdir/ - SSH.File Should Exist ${REMOTE TEST ROOT}/robotdir/${FILE WITH NON-ASCII NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/robotdir/${FILE WITH NON-ASCII NAME} + Put File ${FILE WITH NON-ASCII} ${REMOTE TEST ROOT}/robotdir/ + SSH.File Should Exist ${REMOTE TEST ROOT}/robotdir/${FILE WITH NON-ASCII NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File To Relative Destination - SSH.File Should Not Exist foo.txt - Put File ${FILE WITH NON-ASCII}  foo.txt - SSH.File Should Exist foo.txt - [Teardown] Execute Command rm -f foo.txt + SSH.File Should Not Exist foo.txt + Put File ${FILE WITH NON-ASCII} foo.txt + SSH.File Should Exist foo.txt + [Teardown] Execute Command rm -f foo.txt Put File To Relative Destination With Intermediate Subdirectories - SSH.File Should Not Exist robotdir/${FILE WITH NON-ASCII NAME} - Put File ${FILE WITH NON-ASCII}  robotdir/ - SSH.File Should Exist robotdir/${FILE WITH NON-ASCII NAME} - [Teardown] Execute Command rm -rf robotdir + SSH.File Should Not Exist robotdir/${FILE WITH NON-ASCII NAME} + Put File ${FILE WITH NON-ASCII} robotdir/ + SSH.File Should Exist robotdir/${FILE WITH NON-ASCII NAME} + [Teardown] Execute Command rm -rf robotdir Put File To Existing Directory Without Trailing Path Separator - SSH.Directory Should Not Exist robotdir + SSH.Directory Should Not Exist robotdir Execute Command mkdir robotdir - Put File ${FILE WITH NON-ASCII}  robotdir - SSH.File Should Exist robotdir/${FILE WITH NON-ASCII NAME} - [Teardown] Execute Command rm -rf robotdir + Put File ${FILE WITH NON-ASCII} robotdir + SSH.File Should Exist robotdir/${FILE WITH NON-ASCII NAME} + [Teardown] Execute Command rm -rf robotdir Put File With Square Brackets - SSH.File Should Not Exist ${FILE WITH SQUARE BRACKETS NAME} - Put File ${FILE WITH SQUARE BRACKETS} robotdir/ - SSH.File Should Exist robotdir/${FILE WITH SQUARE BRACKETS NAME} - [Teardown] Execute Command rm -rf robotdir + SSH.File Should Not Exist ${FILE WITH SQUARE BRACKETS NAME} + Put File ${FILE WITH SQUARE BRACKETS} robotdir/ + SSH.File Should Exist robotdir/${FILE WITH SQUARE BRACKETS NAME} + [Teardown] Execute Command rm -rf robotdir Put File To Home Directory - SSH.File Should Not Exist ${FILE WITH NON-ASCII NAME} - Put File ${FILE WITH NON-ASCII} . - SSH.File Should Exist ${FILE WITH NON-ASCII NAME} - [Teardown] Execute Command rm -f ${FILE WITH NON-ASCII NAME} + SSH.File Should Not Exist ${FILE WITH NON-ASCII NAME} + Put File ${FILE WITH NON-ASCII} . + SSH.File Should Exist ${FILE WITH NON-ASCII NAME} + [Teardown] Execute Command rm -f ${FILE WITH NON-ASCII NAME} Put File With Special Characters In Filename - [Documentation] http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55 - ${target} = Set Variable ${FILE WITH SPECIAL CHARS NAME} - SSH.File Should Not Exist ${target} - Put File ${FILE WITH SPECIAL CHARS}  ${target} - SSH.File Should Exist ${target} - [Teardown] Execute Command rm -f ${target} + [Documentation] http://code.google.com/p/robotframework-sshlibrary/issues/detail?id=55 + ${target} = Set Variable ${FILE WITH SPECIAL CHARS NAME} + SSH.File Should Not Exist ${target} + Put File ${FILE WITH SPECIAL CHARS} ${target} + SSH.File Should Exist ${target} + [Teardown] Execute Command rm -f ${target} Put File Should Fail When There Are No Source Files - Run Keyword And Expect Error There are no source files matching 'nonexisting'. - ... SSH.Put File nonexisting + Run Keyword And Expect Error There are no source files matching 'nonexisting'. + ... SSH.Put File nonexisting Put File And Specify Remote Newlines - [Setup] Create Directory ${LOCAL TMPDIR} - ${target} = Set Variable ${FILE WITH NEWLINES NAME} - SSH.File Should Not Exist ${target} - Put File ${FILE WITH NEWLINES} ${target} newline=CRLF - SSH.File Should Exist ${target} - ${expected} = OS.Get Binary File ${FILE WITH NEWLINES} - SSH.Get File ${target} ${LOCAL TMPDIR}${/} - ${content}= OS.Get Binary File ${LOCAL TMPDIR}${/}${FILE WITH NEWLINES NAME} - ${win_rn}= Encode String To Bytes \r\n UTF-8 - ${linux_n}= Encode String To Bytes ${\n} UTF-8 - ${content}= Replace String ${content} ${win_rn} ${linux_n} - Should Be Equal ${content} ${expected} - [Teardown] Remove Local Temp Dir And Remote File ${target} + [Setup] Create Directory ${LOCAL TMPDIR} + ${target} = Set Variable ${FILE WITH NEWLINES NAME} + SSH.File Should Not Exist ${target} + Put File ${FILE WITH NEWLINES} ${target} newline=CRLF + SSH.File Should Exist ${target} + ${expected} = OS.Get Binary File ${FILE WITH NEWLINES} + SSH.Get File ${target} ${LOCAL TMPDIR}${/} + ${content} = OS.Get Binary File ${LOCAL TMPDIR}${/}${FILE WITH NEWLINES NAME} + ${win_rn} = Encode String To Bytes \r\n UTF-8 + ${linux_n} = Encode String To Bytes ${\n} UTF-8 + ${content} = Replace String ${content} ${win_rn} ${linux_n} + Should Be Equal ${content} ${expected} + [Teardown] Remove Local Temp Dir And Remote File ${target} Put File With Pattern In Source File Name - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - Put File ${LOCAL TEXTFILES}${/}?est*.txt ${REMOTE TEST ROOT}/ - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - SSH.File Should Exist ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + Put File ${LOCAL TEXTFILES}${/}?est*.txt ${REMOTE TEST ROOT}/ + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + SSH.File Should Exist ${REMOTE TEST ROOT}/${FILE WITH NEWLINES NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File With SCP And Pattern Matching - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Execute Command mkdir ${REMOTE TEST ROOT NAME} - Put File ${LOCAL TEXTFILES}${/}tes*.txt ${REMOTE TEST ROOT}/ scp=ALL - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Execute Command mkdir ${REMOTE TEST ROOT NAME} + Put File ${LOCAL TEXTFILES}${/}tes*.txt ${REMOTE TEST ROOT}/ scp=ALL + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File With Pattern In Source Directory Name - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Put File ${LOCAL TEST DATA}${/}text*es${/}${TEST FILE NAME} ${REMOTE TEST ROOT}/ - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Put File ${LOCAL TEST DATA}${/}text*es${/}${TEST FILE NAME} ${REMOTE TEST ROOT}/ + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Putting Multiple Source Files To Single File Fails - Run Keyword And Expect Error ValueError: It is not possible to copy multiple source files to one destination file. - ... Put File ${LOCAL TEXTFILES}${/}?est*.txt invalid.txt + Run Keyword And Expect Error + ... ValueError: It is not possible to copy multiple source files to one destination file. + ... Put File + ... ${LOCAL TEXTFILES}${/}?est*.txt + ... invalid.txt Put File Overwrite If User In The Same Group - [Tags] no-gh-actions - Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} - SSH.File Should Exist ${TEST FILE NAME} - Add testkey User To Group test And Set Permissions - Change User And Overwrite File - Switch Connection 1 - SSH.File Should Exist ${TEST FILE NAME} - [Teardown] Remove testkey User From Group test And Cleanup + [Tags] no-gh-actions + Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} + SSH.File Should Exist ${TEST FILE NAME} + Add testkey User To Group test And Set Permissions + Change User And Overwrite File + Switch Connection 1 + SSH.File Should Exist ${TEST FILE NAME} + [Teardown] Remove testkey User From Group test And Cleanup Put File And Check For Proper Permissions - [Tags] linux - Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} ${REMOTE TEST ROOT}/ mode=0755 - ${output}= Execute Command ls - Should Contain ${output} to_put - Check File Permissions 0755 ${REMOTE_TEST_ROOT}${/}${TEST FILE NAME} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + [Tags] linux + Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} ${REMOTE TEST ROOT}/ mode=0755 + ${output} = Execute Command ls + Should Contain ${output} to_put + Check File Permissions 0755 ${REMOTE_TEST_ROOT}${/}${TEST FILE NAME} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File With Scp (all) And Preserve Time - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Execute Command mkdir ${REMOTE TEST ROOT NAME} - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Put File ${TEST FILE}  ${REMOTE TEST ROOT}/ scp=ALL scp_preserve_times=True - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${last_access_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${last_modify_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Execute Command mkdir ${REMOTE TEST ROOT NAME} + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Put File ${TEST FILE} ${REMOTE TEST ROOT}/ scp=ALL scp_preserve_times=True + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${last_access_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${last_modify_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} Put File With SCP (transfer) And Preserve Time - SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - Execute Command mkdir ${REMOTE TEST ROOT NAME} - ${current_time} = Get Current Date result_format=epoch exclude_millis=False - Put File ${TEST FILE}  ${REMOTE TEST ROOT}/ scp=TRANSFER scp_preserve_times=True - SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${last_access_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} - ${last_modify_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} - Should Be True ${current_time} > ${last_access_time} - Should Be True ${current_time} > ${last_modify_time} - [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + SSH.File Should Not Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + Execute Command mkdir ${REMOTE TEST ROOT NAME} + ${current_time} = Get Current Date result_format=epoch exclude_millis=False + Put File ${TEST FILE} ${REMOTE TEST ROOT}/ scp=TRANSFER scp_preserve_times=True + SSH.File Should Exist ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${last_access_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} + ${last_modify_time} = Execute Command stat -c %X ${REMOTE TEST ROOT}/${TEST FILE NAME} + Should Be True ${current_time} > ${last_access_time} + Should Be True ${current_time} > ${last_modify_time} + [Teardown] Execute Command rm -rf ${REMOTE TEST ROOT} + *** Keywords *** Change User And Overwrite File - Open Connection ${HOST} prompt=${PROMPT} - Login With Public Key ${KEY USERNAME} ${KEY} - Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} ${REMOTE HOME TEST} - [Teardown] Close Connection + Open Connection ${HOST} prompt=${PROMPT} + Login With Public Key ${KEY USERNAME} ${KEY} + Put File ${LOCAL TEXTFILES}${/}${TEST FILE NAME} ${REMOTE HOME TEST} + [Teardown] Close Connection Add testkey User To Group test And Set Permissions - Execute Command usermod -a -G test testkey sudo=True sudo_password=test - Execute Command chmod -R 660 ${TEST FILE NAME} + Execute Command usermod -a -G test testkey sudo=True sudo_password=test + Execute Command chmod -R 660 ${TEST FILE NAME} Remove testkey User From Group test And Cleanup - Execute Command gpasswd -d testkey test sudo=True sudo_password=test - Execute Command rm -rf ${TEST FILE NAME} + Execute Command gpasswd -d testkey test sudo=True sudo_password=test + Execute Command rm -rf ${TEST FILE NAME} Remove Local Temp Dir And Remote File - [Arguments] ${path} - Remove Directory ${LOCAL TMPDIR} yes - Execute Command rm -f ${path} + [Arguments] ${path} + Remove Directory ${LOCAL TMPDIR} yes + Execute Command rm -f ${path} diff --git a/atest/regexp_prompt.robot b/atest/regexp_prompt.robot index 2445b011e..b73ec510f 100644 --- a/atest/regexp_prompt.robot +++ b/atest/regexp_prompt.robot @@ -1,29 +1,31 @@ *** Settings *** -Resource resources/common.robot -Test Teardown Close All Connections +Resource resources/common.robot + +Test Teardown Close All Connections + *** Test Cases *** Read Until Prompt With Regexp Prompt - Open Connection localhost prompt=REGEXP:[$#] - Login test test - Write pwd - ${output}= Read Until Prompt - Should Contain ${output} $ - Write export PS1\='\\u\@\\h \\W # ' - ${output1}= Read Until Prompt - Should Contain ${output1} \# - [Teardown] Close connection + Open Connection localhost prompt=REGEXP:[$#] + Login test test + Write pwd + ${output}= Read Until Prompt + Should Contain ${output} $ + Write export PS1\='\\u\@\\h \\W # ' + ${output1}= Read Until Prompt + Should Contain ${output1} \# + [Teardown] Close connection Set Client Configuration With Regexp Prompt - Open Connection localhost prompt=$ - Login test test - Write pwd - ${output}= Read Until Prompt - Should Contain ${output} $ - Set Client Configuration prompt=REGEXP:[$#] - Write export PS1\='\\u\@\\h \\W # ' - ${output1}= Read Until Prompt - Should Contain ${output1} \# - Write export PS1\='\\u\@\\h \\W $ ' - ${output2}= Read Until Prompt - Should Contain ${output2} $ + Open Connection localhost prompt=$ + Login test test + Write pwd + ${output}= Read Until Prompt + Should Contain ${output} $ + Set Client Configuration prompt=REGEXP:[$#] + Write export PS1\='\\u\@\\h \\W # ' + ${output1}= Read Until Prompt + Should Contain ${output1} \# + Write export PS1\='\\u\@\\h \\W $ ' + ${output2}= Read Until Prompt + Should Contain ${output2} $ diff --git a/atest/resources/common.robot b/atest/resources/common.robot index ee51c1ff4..2acdc2337 100644 --- a/atest/resources/common.robot +++ b/atest/resources/common.robot @@ -1,35 +1,40 @@ *** Settings *** -Library SSHLibrary WITH NAME SSH +Library SSHLibrary WITH NAME SSH + *** Variables *** -${USERNAME} test -${USERNAME_NOPASSWD} test-nopasswd -${PASSWORD} test -${HOST} localhost -${PROMPT} $ -${REMOTE TEST ROOT NAME} robot-testdir -${REMOTE HOME TEST} /home/test -${REMOTE TEST ROOT} ${REMOTE HOME TEST}/${REMOTE TEST ROOT NAME} -${LOCAL TESTDATA} ${CURDIR}${/}..${/}testdata -${KEY DIR} ${LOCAL TESTDATA}${/}keyfiles -${KEY USERNAME} testkey -${KEY} ${KEY DIR}${/}id_rsa -${TEST_HOSTNAME} test_hostname -${TESTKEY_HOSTNAME} testkey_hostname -${TEST_PROXY_HOSTNAME} test_proxy_hostname -${EMPTY_STRING} \ +${USERNAME} test +${USERNAME_NOPASSWD} test-nopasswd +${PASSWORD} test +${HOST} localhost +${PROMPT} $ +${REMOTE TEST ROOT NAME} robot-testdir +${REMOTE HOME TEST} /home/test +${REMOTE TEST ROOT} ${REMOTE HOME TEST}/${REMOTE TEST ROOT NAME} +${LOCAL TESTDATA} ${CURDIR}${/}..${/}testdata +${KEY DIR} ${LOCAL TESTDATA}${/}keyfiles +${KEY USERNAME} testkey +${KEY} ${KEY DIR}${/}id_rsa +${TEST_HOSTNAME} test_hostname +${TESTKEY_HOSTNAME} testkey_hostname +${TEST_PROXY_HOSTNAME} test_proxy_hostname +${EMPTY_STRING} \ + *** Keywords *** Login As Valid User - Open Connection ${HOST} prompt=${PROMPT} - Login ${USERNAME} ${PASSWORD} + Open Connection ${HOST} prompt=${PROMPT} + Login ${USERNAME} ${PASSWORD} Remove Test Files And Close Connections - Execute Command rm -rf ${REMOTE TEST ROOT} + Execute Command rm -rf ${REMOTE TEST ROOT} Close All Connections Check File Permissions - [Arguments] ${expected_permission} ${remote_file}=to_put${/}ExampleText3.txt - ${actual_permission}= Execute Command stat -c %a ${remote_file} - Should Not Be Empty ${actual_permission} Failed to determine permissions for file:\t${remote_file} - Should Be Equal As Integers ${actual_permission} ${expected_permission} File '${remote_file}' does not have expected permissions '${expected_permission}' set:\t${actual_permission} + [Arguments] ${expected_permission} ${remote_file}=to_put${/}ExampleText3.txt + ${actual_permission}= Execute Command stat -c %a ${remote_file} + Should Not Be Empty ${actual_permission} Failed to determine permissions for file:\t${remote_file} + Should Be Equal As Integers + ... ${actual_permission} + ... ${expected_permission} + ... File '${remote_file}' does not have expected permissions '${expected_permission}' set:\t${actual_permission} diff --git a/atest/resources/sftp.robot b/atest/resources/sftp.robot index 10f93113f..e4ed00b65 100644 --- a/atest/resources/sftp.robot +++ b/atest/resources/sftp.robot @@ -1,31 +1,34 @@ -*** Settings *** +*** Settings *** Resource common.robot + *** Variables *** -${LOCAL TMPDIR} ${TEMPDIR}${/}robot-sshlibrary-test-tmpdir -${LOCAL TEXTFILES} ${LOCAL TESTDATA}${/}textfiles -${FILE WITH NEWLINES NAME} Test_newlines.txt -${FILE WITH NEWLINES} ${LOCAL TEXTFILES}${/}${FILE WITH NEWLINES NAME} -${TEST FILE NAME} test_file.txt -${TEST FILE} ${LOCAL TEXTFILES}${/}${TEST FILE NAME} -${FILE WITH SPECIAL CHARS NAME} special%2Fchars.txt -${FILE WITH SPECIAL CHARS} ${LOCAL TEXTFILES}${/}${FILE WITH SPECIAL CHARS NAME} -${SUBDIRECTORY NAME} aaääöö -${FILE WITH NON-ASCII NAME} aaääöö.txt -${DIRECTORY WITH EMPTY SUBDIRECTORY} contains_only_empty_subdir -${EMPTY SUB DIR} empty -${FILE WITH NON-ASCII} ${LOCAL TEXTFILES}${/}${SUBDIRECTORY NAME}${/}${FILE WITH NON-ASCII NAME} -${COLON CHAR FILE NAME} special:char.txt -${COLON CHAR FILE} ${LOCAL TEXTFILES}${/}special:char.txt -${SYMLINK TO TEST FILE} symlink_to_text_file.txt -${FILE WITH SQUARE BRACKETS NAME} test[1].txt -${FILE WITH SQUARE BRACKETS} ${LOCAL TEXTFILES}${/}${FILE WITH SQUARE BRACKETS NAME} -${CORRUPTED FILE NAME} corrupted.txt -${CORRUPTED FILE} ${LOCAL TEXTFILES}${/}${CORRUPTED FILE NAME} +${LOCAL TMPDIR} ${TEMPDIR}${/}robot-sshlibrary-test-tmpdir +${LOCAL TEXTFILES} ${LOCAL TESTDATA}${/}textfiles +${FILE WITH NEWLINES NAME} Test_newlines.txt +${FILE WITH NEWLINES} ${LOCAL TEXTFILES}${/}${FILE WITH NEWLINES NAME} +${TEST FILE NAME} test_file.txt +${TEST FILE} ${LOCAL TEXTFILES}${/}${TEST FILE NAME} +${FILE WITH SPECIAL CHARS NAME} special%2Fchars.txt +${FILE WITH SPECIAL CHARS} ${LOCAL TEXTFILES}${/}${FILE WITH SPECIAL CHARS NAME} +${SUBDIRECTORY NAME} aaääöö +${FILE WITH NON-ASCII NAME} aaääöö.txt +${DIRECTORY WITH EMPTY SUBDIRECTORY} contains_only_empty_subdir +${EMPTY SUB DIR} empty +${FILE WITH NON-ASCII} ${LOCAL TEXTFILES}${/}${SUBDIRECTORY NAME}${/}${FILE WITH NON-ASCII NAME} +${COLON CHAR FILE NAME} special:char.txt +${COLON CHAR FILE} ${LOCAL TEXTFILES}${/}special:char.txt +${SYMLINK TO TEST FILE} symlink_to_text_file.txt +${FILE WITH SQUARE BRACKETS NAME} test[1].txt +${FILE WITH SQUARE BRACKETS} ${LOCAL TEXTFILES}${/}${FILE WITH SQUARE BRACKETS NAME} +${CORRUPTED FILE NAME} corrupted.txt +${CORRUPTED FILE} ${LOCAL TEXTFILES}${/}${CORRUPTED FILE NAME} + *** Keywords *** Login And Upload Test Files Login As Valid User - Put Directory ${LOCAL TEXTFILES} ${REMOTE TEST ROOT} recursive=True - Execute command mkdir ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${DIRECTORY WITH EMPTY SUBDIRECTORY} - Execute command mkdir ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${DIRECTORY WITH EMPTY SUBDIRECTORY}/${EMPTY SUB DIR} \ No newline at end of file + Put Directory ${LOCAL TEXTFILES} ${REMOTE TEST ROOT} recursive=True + Execute command mkdir ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${DIRECTORY WITH EMPTY SUBDIRECTORY} + Execute command + ... mkdir ${REMOTE TEST ROOT}/${SUBDIRECTORY NAME}/${DIRECTORY WITH EMPTY SUBDIRECTORY}/${EMPTY SUB DIR} diff --git a/atest/resources/shell.robot b/atest/resources/shell.robot index 723be68d5..7b475bf76 100644 --- a/atest/resources/shell.robot +++ b/atest/resources/shell.robot @@ -1,12 +1,14 @@ *** Settings *** Resource common.robot + *** Variables *** -${LOCAL SCRIPTS} ${LOCAL TESTDATA}${/}scripts -${TEST SCRIPT NAME} test.sh -${TEST SCRIPT} ${LOCAL SCRIPTS}${/}${TEST SCRIPT NAME} +${LOCAL SCRIPTS} ${LOCAL TESTDATA}${/}scripts +${TEST SCRIPT NAME} test.sh +${TEST SCRIPT} ${LOCAL SCRIPTS}${/}${TEST SCRIPT NAME} + *** Keywords *** Login And Upload Test Scripts Login As Valid User - Put Directory ${LOCAL SCRIPTS} ${REMOTE TEST ROOT} recursive=True newline=LF + Put Directory ${LOCAL SCRIPTS} ${REMOTE TEST ROOT} recursive=True newline=LF diff --git a/atest/resources/write_and_read_resource.robot b/atest/resources/write_and_read_resource.robot index 151787a48..e51e311fa 100644 --- a/atest/resources/write_and_read_resource.robot +++ b/atest/resources/write_and_read_resource.robot @@ -1,11 +1,12 @@ *** Settings *** -Resource shell.robot +Resource shell.robot + *** Variables *** -${COUNTER NAME} counter.txt -${INTERACTIVE TEST SCRIPT NAME} test_interactive.sh -${INTERACTIVE TEST SCRIPT} ${LOCAL SCRIPTS}${/}${INTERACTIVE TEST SCRIPT NAME} -${REPEAT TEST SCRIPT NAME} test_repeat.sh -${REPEAT TEST SCRIPT} ${LOCAL SCRIPTS}${/}${REPEAT TEST SCRIPT NAME} -${CORRUPTED FILE NAME} corrupted.txt -${CORRUPTED FILE} ${LOCAL TESTDATA}${/}textfiles${/}${CORRUPTED FILE NAME} +${COUNTER NAME} counter.txt +${INTERACTIVE TEST SCRIPT NAME} test_interactive.sh +${INTERACTIVE TEST SCRIPT} ${LOCAL SCRIPTS}${/}${INTERACTIVE TEST SCRIPT NAME} +${REPEAT TEST SCRIPT NAME} test_repeat.sh +${REPEAT TEST SCRIPT} ${LOCAL SCRIPTS}${/}${REPEAT TEST SCRIPT NAME} +${CORRUPTED FILE NAME} corrupted.txt +${CORRUPTED FILE} ${LOCAL TESTDATA}${/}textfiles${/}${CORRUPTED FILE NAME} diff --git a/atest/start_command.robot b/atest/start_command.robot index da4de1dc9..801f0e946 100644 --- a/atest/start_command.robot +++ b/atest/start_command.robot @@ -1,84 +1,86 @@ *** Settings *** -Resource resources/shell.robot -Suite Setup Login And Upload Test Scripts -Suite Teardown Remove Test Files And Close Connections +Resource resources/shell.robot + +Suite Setup Login And Upload Test Scripts +Suite Teardown Remove Test Files And Close Connections + *** Test Cases *** Start Command And Read Process Output With Defaults - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${stdout} = Read Command Output - Should Be Equal ${stdout} This is stdout + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${stdout} = Read Command Output + Should Be Equal ${stdout} This is stdout Start Command And Read Only Return Code - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${rc} = Read Command Output return_stdout=False return_rc=yes - Should Be Equal As Integers ${rc} 0 + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${rc} = Read Command Output return_stdout=False return_rc=yes + Should Be Equal As Integers ${rc} 0 Start Command And Execute Command - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} Hello - Should Be Equal ${stdout} Hello - ${stdout} = Read Command Output - Should Be Equal ${stdout} This is stdout + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${stdout} = Execute Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} Hello + Should Be Equal ${stdout} Hello + ${stdout} = Read Command Output + Should Be Equal ${stdout} This is stdout Start Command And Read Process Output With Legacy Stdout - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${stdout} = Read Command Output STDOUT - Should Be Equal ${stdout} This is stdout + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${stdout} = Read Command Output STDOUT + Should Be Equal ${stdout} This is stdout Start Command And Read Process Output With Legacy Stderr - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${stderr} = Read Command Output stderr - Should Be Equal ${stderr} This is stderr + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${stderr} = Read Command Output stderr + Should Be Equal ${stderr} This is stderr Start Command And Read Process Output With Legacy Stdout And Stderr - Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} - ${stdout} ${stderr} = Read Command Output both - Should Be Equal ${stdout} This is stdout - Should Be Equal ${stderr} This is stderr + Start Command ${REMOTE TEST ROOT}/${TEST SCRIPT NAME} + ${stdout} ${stderr} = Read Command Output both + Should Be Equal ${stdout} This is stdout + Should Be Equal ${stderr} This is stderr Reading Command Output Without Command Started Run Keyword And Expect Error - ... No started commands to read output from. - ... Read Command Output + ... No started commands to read output from. + ... Read Command Output Start Sudo Command With Correct Password - [Tags] linux - Start Command -k pwd sudo=True sudo_password=test - ${stdout} = Read Command Output - Should Contain ${stdout} ${REMOTE HOME TEST} + [Tags] linux + Start Command -k pwd sudo=True sudo_password=test + ${stdout} = Read Command Output + Should Contain ${stdout} ${REMOTE HOME TEST} Start Sudo Command With Incorrect Password - [Tags] linux - Start Command -k pwd sudo=True sudo_password=test123 - ${stdout} = Read Command Output - Should Not Contain ${stdout} ${REMOTE HOME TEST} + [Tags] linux + Start Command -k pwd sudo=True sudo_password=test123 + ${stdout} = Read Command Output + Should Not Contain ${stdout} ${REMOTE HOME TEST} Start Time Consuming Sudo Command - [Tags] linux - Start Command -k sleep 5; echo cat sudo=True sudo_password=test - ${stdout} = Read Command Output - Should Contain ${stdout} cat + [Tags] linux + Start Command -k sleep 5; echo cat sudo=True sudo_password=test + ${stdout} = Read Command Output + Should Contain ${stdout} cat Start Command And Read Process Output With Invoke Subsystem - Start Command subsys invoke_subsystem=yes - ${stdout} = Read Command Output - Should Be Equal ${stdout} Subsystem invoked. + Start Command subsys invoke_subsystem=yes + ${stdout} = Read Command Output + Should Be Equal ${stdout} Subsystem invoked. Read Command Output With Timeout - Start Command sleep 15 - Run Keyword And Expect Error *Timed out in 5 seconds Read Command Output timeout=5s + Start Command sleep 15 + Run Keyword And Expect Error *Timed out in 5 seconds Read Command Output timeout=5s Start Commands In Different Connections - [Setup] Login As Valid User - [Documentation] PASS - ... LOG 7:1 INFO Reading output of command 'pwd'. - ... LOG 9:1 INFO Reading output of command 'hostname'. - Switch Connection 1 - Start Command pwd - Switch Connection 2 - Start Command hostname - Switch Connection 1 - ${out}= Read Command Output return_stderr=True + [Documentation] PASS + ... LOG 7:1 INFO Reading output of command 'pwd'. + ... LOG 9:1 INFO Reading output of command 'hostname'. + [Setup] Login As Valid User + Switch Connection 1 + Start Command pwd + Switch Connection 2 + Start Command hostname + Switch Connection 1 + ${out} = Read Command Output return_stderr=True Switch Connection 2 - ${out}= Read Command Output return_stderr=True + ${out} = Read Command Output return_stderr=True diff --git a/atest/tunnels.robot b/atest/tunnels.robot index 11b2fb8c7..5d0bf1831 100644 --- a/atest/tunnels.robot +++ b/atest/tunnels.robot @@ -1,82 +1,88 @@ *** Settings *** -Resource resources/common.robot -Test Setup Open Connection ${HOST} -Test Teardown Close All Connections -Library OperatingSystem -Library Tunnels.py +Resource resources/common.robot +Library OperatingSystem +Library Tunnels.py + +Test Setup Open Connection ${HOST} +Test Teardown Close All Connections + *** Variables *** -${LOCAL PORT} 9000 -${REMOTE HOST} google.com -${REMOTE PORT} 80 -${DEFAULT SSH PORT} 22 -${LOCAL SSH PORT} 2222 +${LOCAL PORT} 9000 +${REMOTE HOST} google.com +${REMOTE PORT} 80 +${DEFAULT SSH PORT} 22 +${LOCAL SSH PORT} 2222 + *** Test Cases *** Local Tunnel Should Be Closed - [Documentation] LOG 3:1 GLOB: Now forwarding port ${LOCAL PORT} to ${REMOTE HOST}:${REMOTE PORT} ... - ... LOG 6:2 GLOB: Connected! Tunnel open * - ... LOG 6:3 GLOB: Tunnel closed from * - Login ${USERNAME} ${PASSWORD} - Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} - Dummy Connect ${LOCAL PORT} - Port Should Not Be Free ${LOCAL PORT} + [Documentation] LOG 3:1 GLOB: Now forwarding port ${LOCAL PORT} to ${REMOTE HOST}:${REMOTE PORT} ... + ... LOG 6:2 GLOB: Connected! Tunnel open * + ... LOG 6:3 GLOB: Tunnel closed from * + Login ${USERNAME} ${PASSWORD} + Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} + Dummy Connect ${LOCAL PORT} + Port Should Not Be Free ${LOCAL PORT} Close All Connections - Wait For Port To Be Closed ${LOCAL PORT} - Port Should Be Free ${LOCAL PORT} + Wait For Port To Be Closed ${LOCAL PORT} + Port Should Be Free ${LOCAL PORT} Local Tunnel With Public Key - Login With Public Key ${KEY USERNAME} ${KEY} - Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} - Port Should Not Be Free ${LOCAL PORT} + Login With Public Key ${KEY USERNAME} ${KEY} + Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} + Port Should Not Be Free ${LOCAL PORT} Local Tunnel SSH - [Documentation] LOG 3:1 GLOB: Now forwarding port ${LOCAL SSH PORT} to ${HOST}:${DEFAULT SSH PORT} ... - ... LOG 8:2 GLOB: Connected! Tunnel open * - Login ${USERNAME} ${PASSWORD} - Create Local SSH Tunnel ${LOCAL SSH PORT} ${HOST} ${DEFAULT SSH PORT} - Port Should Not Be Free ${LOCAL SSH PORT} - Open Connection ${HOST} port=${LOCAL SSH PORT} - Login ${USERNAME} ${PASSWORD} - Execute Command ls + [Documentation] LOG 3:1 GLOB: Now forwarding port ${LOCAL SSH PORT} to ${HOST}:${DEFAULT SSH PORT} ... + ... LOG 8:2 GLOB: Connected! Tunnel open * + Login ${USERNAME} ${PASSWORD} + Create Local SSH Tunnel ${LOCAL SSH PORT} ${HOST} ${DEFAULT SSH PORT} + Port Should Not Be Free ${LOCAL SSH PORT} + Open Connection ${HOST} port=${LOCAL SSH PORT} + Login ${USERNAME} ${PASSWORD} + Execute Command ls Local Tunnel With Default Remote Port - Login With Public Key ${KEY USERNAME} ${KEY} - Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} - Port Should Not Be Free ${LOCAL PORT} + Login With Public Key ${KEY USERNAME} ${KEY} + Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} + Port Should Not Be Free ${LOCAL PORT} Local Tunnel With Bind Address - Login ${USERNAME} ${PASSWORD} - Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} bind_address=localhost - Port Should Be Binded To Localhost ${LOCAL PORT} + Login ${USERNAME} ${PASSWORD} + Create Local SSH Tunnel ${LOCAL PORT} ${REMOTE HOST} ${REMOTE PORT} bind_address=localhost + Port Should Be Binded To Localhost ${LOCAL PORT} + *** Keywords *** Port Should Not Be Free - [Arguments] ${port} - ${result} Run Keyword If os.sep == '/' - ... Run netstat -tulpn - ... ELSE - ... Run netstat -an - Should Contain ${result} :${port} + [Arguments] ${port} + IF os.sep == '/' + ${result} Run netstat -tulpn + ELSE + ${result} Run netstat -an + END + Should Contain ${result} :${port} Port Should Be Binded To Localhost - [Arguments] ${port} - ${result} Run Keyword If os.sep == '/' - ... Run netstat -tulpn - ... ELSE - ... Run netstat -an - ${ip} Set Variable If '${HOST}' == 'localhost' 127.0.0.1 [?::1]? - Should Match Regexp ${result} ${ip}:${port} + [Arguments] ${port} + IF os.sep == '/' + ${result} Run netstat -tulpn + ELSE + ${result} Run netstat -an + END + ${ip} Set Variable If '${HOST}' == 'localhost' 127.0.0.1 [?::1]? + Should Match Regexp ${result} ${ip}:${port} Port Should Be Free - [Arguments] ${port} - ${result} Run Keyword If os.sep == '/' - ... Run netstat -tulpn - ... ELSE - ... Run netstat -an - Should Not Contain ${result} :${port} + [Arguments] ${port} + IF os.sep == '/' + ${result} Run netstat -tulpn + ELSE + ${result} Run netstat -an + END + Should Not Contain ${result} :${port} Wait For Port To Be Closed - [Arguments] ${port} - Wait Until Keyword Succeeds 2 min 10s Port Should Be Free ${port} - + [Arguments] ${port} + Wait Until Keyword Succeeds 2 min 10s Port Should Be Free ${port} diff --git a/atest/write_and_read/other_writes_and_reads.robot b/atest/write_and_read/other_writes_and_reads.robot index 122137b93..ab8c3b804 100644 --- a/atest/write_and_read/other_writes_and_reads.robot +++ b/atest/write_and_read/other_writes_and_reads.robot @@ -1,125 +1,125 @@ *** Settings *** -Resource ../resources/write_and_read_resource.robot -Suite Setup Run Keywords Login And Upload Test Scripts AND Put File ${CORRUPTED FILE} ${REMOTE TEST ROOT} -Suite Teardown Remove Test Files and Close Connections +Resource ../resources/write_and_read_resource.robot +Suite Setup Run Keywords Login And Upload Test Scripts AND Put File ${CORRUPTED FILE} ${REMOTE TEST ROOT} +Suite Teardown Remove Test Files and Close Connections -*** Test Cases *** +*** Test Cases *** Write And Read Until - ${output} = Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - Should Contain ${output} ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - ${output} = Read Until Give your name? - Should Contain ${output} Give your name? - ${output} = Write Mr. Ääkkönen - Should Contain ${output} Mr. Ääkkönen - ${output} = Read Until Prompt - Should Contain ${output} Hello Mr. Ääkkönen + ${output} = Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + Should Contain ${output} ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + ${output} = Read Until Give your name? + Should Contain ${output} Give your name? + ${output} = Write Mr. Ääkkönen + Should Contain ${output} Mr. Ääkkönen + ${output} = Read Until Prompt + Should Contain ${output} Hello Mr. Ääkkönen Write And Read Until Prompt - Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - Write Mr. Ääkkönen - ${output} = Read Until Prompt - Should Contain ${output} Hello Mr. Ääkkönen + Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + Write Mr. Ääkkönen + ${output} = Read Until Prompt + Should Contain ${output} Hello Mr. Ääkkönen Write And Read Until Regexp - Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - ${output} = Read Until Regexp Give.*\\? - Should Contain ${output} Give your name? - Write Mr. Ääkkönen - Comment Prompt needs to be escaped because it might be $ - ${output} = Read Until Regexp (?s).*\\${PROMPT} - Should Contain ${output} Hello Mr. Ääkkönen - Should End With ${output} ${PROMPT} + Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + ${output} = Read Until Regexp Give.*\\? + Should Contain ${output} Give your name? + Write Mr. Ääkkönen + Comment Prompt needs to be escaped because it might be $ + ${output} = Read Until Regexp (?s).*\\${PROMPT} + Should Contain ${output} Hello Mr. Ääkkönen + Should End With ${output} ${PROMPT} Write Non-String - Write ${1} - ${output} = Read Until Prompt - Should Contain ${output} 1 + Write ${1} + ${output} = Read Until Prompt + Should Contain ${output} 1 Write Bare Non-String - Write Bare ${False}\n - ${output} = Read Until Prompt - Should Contain ${output} False + Write Bare ${False}\n + ${output} = Read Until Prompt + Should Contain ${output} False Write In Case Of Timeout - Write Foo Bar And Some Other - Set Client Configuration timeout=1 - ${status} ${error} = Run Keyword And Ignore Error - ... Read Until This is not found - Should Start With ${error} No match found for 'This is not found' in 1 second + Write Foo Bar And Some Other + Set Client Configuration timeout=1 + ${status} ${error} = Run Keyword And Ignore Error + ... Read Until This is not found + Should Start With ${error} No match found for 'This is not found' in 1 second Write Returning Stderr - Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - Read Until Give your name? - Write Error - ${output} = Read Until ${PROMPT} - Should Contain ${output} Hello Error - Should Contain ${output} This is Error + Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + Read Until Give your name? + Write Error + ${output} = Read Until ${PROMPT} + Should Contain ${output} Hello Error + Should Contain ${output} This is Error Write Bare And Read Until - Write Bare ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME}\n - ${output} = Read Until name? - Write Bare Mr. Ääkkönen\n - ${output2} = Read Until Prompt - Should Contain ${output} Give your name? - Should Contain ${output2} Hello Mr. Ääkkönen - Should Contain ${output2} ${PROMPT} + Write Bare ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME}\n + ${output} = Read Until name? + Write Bare Mr. Ääkkönen\n + ${output2} = Read Until Prompt + Should Contain ${output} Give your name? + Should Contain ${output2} Hello Mr. Ääkkönen + Should Contain ${output2} ${PROMPT} Write Until Expected Output - Write Until Expected Output ${REMOTE TEST ROOT}/${REPEAT TEST SCRIPT NAME}\n - ... 3 15 seconds 0.5 seconds - [Teardown] Execute Command rm -f ${COUNTER NAME} + Write Until Expected Output ${REMOTE TEST ROOT}/${REPEAT TEST SCRIPT NAME}\n + ... 3 15 seconds 0.5 seconds + [Teardown] Execute Command rm -f ${COUNTER NAME} Write Until Expected Output In Case Of Timeout - Run Keyword And Expect Error No match found for '11' in 2 seconds. - ... Write Until Expected Output ${REMOTE TEST ROOT}/${REPEAT TEST SCRIPT NAME}\n - ... 11 2s 0.5s - [Teardown] Execute Command rm -f ${COUNTER NAME} + Run Keyword And Expect Error No match found for '11' in 2 seconds. + ... Write Until Expected Output ${REMOTE TEST ROOT}/${REPEAT TEST SCRIPT NAME}\n + ... 11 2s 0.5s + [Teardown] Execute Command rm -f ${COUNTER NAME} Read Until Prompt With Strip Prompt - Write echo This is a test - ${output}= Read Until Prompt strip_prompt=True - Should Contain ${output} This is a test - Should Not Contain ${output} ${PROMPT} + Write echo This is a test + ${output} = Read Until Prompt strip_prompt=True + Should Contain ${output} This is a test + Should Not Contain ${output} ${PROMPT} Read Until REGEXP Prompt With Strip Prompt - Set Client Configuration prompt=REGEXP:[#$] - Write echo This is a test - ${output}= Read Until Prompt strip_prompt=True - Should Contain ${output} This is a test - Should Not Match Regexp ${output} [#$] - [Teardown] Set Client Configuration prompt=${PROMPT} + Set Client Configuration prompt=REGEXP:[#$] + Write echo This is a test + ${output} = Read Until Prompt strip_prompt=True + Should Contain ${output} This is a test + Should Not Match Regexp ${output} [#$] + [Teardown] Set Client Configuration prompt=${PROMPT} Configure Session Width And Height - Set Client Configuration prompt=${PROMPT} height=48 width=160 - ${conn} Get Connection 1 - Should Be Equal As Integers ${conn.height} 48 - Should Be Equal As Integers ${conn.width} 160 - Write stty size - ${output}= Read Until Prompt - Should Contain ${output} 48 160 - [Teardown] Set Client Configuration height=24 width=80 + Set Client Configuration prompt=${PROMPT} height=48 width=160 + ${conn} = Get Connection 1 + Should Be Equal As Integers ${conn.height} 48 + Should Be Equal As Integers ${conn.width} 160 + Write stty size + ${output} = Read Until Prompt + Should Contain ${output} 48 160 + [Teardown] Set Client Configuration height=24 width=80 Read Until With Encoding Errors On Strict - Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - Run Keyword And Expect Error *codec can't decode byte* Read Until Hello + Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + Run Keyword And Expect Error *codec can't decode byte* Read Until Hello Read Until With Encoding Errors On Replace - Set Client Configuration encoding_errors=replace - Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ${output} = Read Until Hello - Should Contain ${output} Hello + Set Client Configuration encoding_errors=replace + Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ${output} = Read Until Hello + Should Contain ${output} Hello Read Until With Encoding Errors On Ignore - Set Client Configuration encoding_errors=ignore - Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ${output} = Read Until Hello - Should Contain ${output} Hello + Set Client Configuration encoding_errors=ignore + Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ${output} = Read Until Hello + Should Contain ${output} Hello Read Until With Encoding Errors Set In Open Connection - [Setup] Run Keywords Open Connection ${HOST} prompt=${PROMPT} encoding_errors=replace AND - ... Login ${USERNAME} ${PASSWORD} - Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} - ${output} = Read Until Hello - Should Contain ${output} Hello + [Setup] Run Keywords Open Connection ${HOST} prompt=${PROMPT} encoding_errors=replace AND + ... Login ${USERNAME} ${PASSWORD} + Write cat ${REMOTE TEST ROOT}/${CORRUPTED FILE NAME} + ${output} = Read Until Hello + Should Contain ${output} Hello diff --git a/atest/write_and_read/write_and_read.robot b/atest/write_and_read/write_and_read.robot index 8f3df57c1..2b34264a1 100644 --- a/atest/write_and_read/write_and_read.robot +++ b/atest/write_and_read/write_and_read.robot @@ -1,15 +1,18 @@ *** Settings *** -Resource ../resources/write_and_read_resource.robot -Suite Setup Login And Upload Test Scripts -Suite Teardown Remove Test Files and Close Connections -Documentation This test case is isolated to its own suite because if `Read` fails -... because of timing issues, it will bleed to other test cases. Timing -... issues are related to the speed of computer. If the test case is -... failing, increase delay for `Read`. - -*** Test cases *** +Documentation This test case is isolated to its own suite because if `Read` fails +... because of timing issues, it will bleed to other test cases. Timing +... issues are related to the speed of computer. If the test case is +... failing, increase delay for `Read`. + +Resource ../resources/write_and_read_resource.robot + +Suite Setup Login And Upload Test Scripts +Suite Teardown Remove Test Files and Close Connections + + +*** Test Cases *** Write And Read - Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} - Write Mr. Ääkkönen - ${output} = Read delay=1s - Should Contain ${output} Hello Mr. Ääkkönen + Write ${REMOTE TEST ROOT}/${INTERACTIVE TEST SCRIPT NAME} + Write Mr. Ääkkönen + ${output} = Read delay=1s + Should Contain ${output} Hello Mr. Ääkkönen