Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
miikaoskari committed Aug 28, 2024
2 parents 633e1f2 + a7ef0d0 commit fe83a68
Show file tree
Hide file tree
Showing 42 changed files with 1,809 additions and 2,877 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/CI-jython.yml

This file was deleted.

17 changes: 8 additions & 9 deletions .github/workflows/CI-python.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
name: SSHLibrary Python CI

on: [ push, pull_request ]
on: [push, pull_request]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
python-version: [ 3.8 ]
os: ["ubuntu-latest"]
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install paramiko scp
pip install .
- name: Configure test environment for Linux
run: |
sudo useradd test -m -s /bin/bash
Expand Down Expand Up @@ -54,8 +53,8 @@ jobs:
ssh-add atest/testdata/keyfiles/id_rsa
- name: Run tests
run: |
python atest/run.py -e no-gh-actions atest
- uses: actions/upload-artifact@v1
robot -d results -e no-gh-actions -b console.log atest
- uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: Test Results - ${{ runner.os }}
Expand Down
26 changes: 7 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ SSHLibrary_ is a `Robot Framework`_ test
library for SSH and SFTP. The project is hosted on GitHub_
and downloads can be found from PyPI_.

SSHLibrary is operating system independent and supports Python 2.7 as well
as Python 3.4 or newer. In addition to the normal Python_ interpreter,
it also works with `Jython 2.7`_.
SSHLibrary is operating system independent and supports Python 3.6 or newer.

The library has the following main usages:

Expand Down Expand Up @@ -57,21 +55,13 @@ this command::
pip install git+https://github.com/robotframework/SSHLibrary.git

Alternatively you can download the source distribution from PyPI_, extract
it, and install it using one of the following depending are you using
Python or Jython::
it, and install it using one the command::

python setup.py install
jython setup.py install

A benefit of using pip is that it automatically installs scp, paramiko
and Cryptography_ modules (or PyCrypto_ if paramiko version < 2.0)
that SSHLibrary requires on Python.

On Jython, SSHLibrary requires Trilead SSH JAR distribution. You need to download
`Trilead SSH JAR distribution`_ and add it to CLASSPATH.

On Windows operating system, when using Python version < 3.0, SSHLibrary will
require win_inet_pton_. The minimum supported win_inet_pton version is ``1.1.0``.
that SSHLibrary requires.

For creating SSH tunnels robotbackgroundlogger_ > 1.2 is also a requirement.

Expand Down Expand Up @@ -143,19 +133,17 @@ available:

.. _Robot Framework: http://robotframework.org
.. _Robot Framework User Guide: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-test-libraries
.. _SSHLibrary: https://github.com/robotframework/SSHLibrary
.. _GitHub: https://github.com/robotframework/SSHLibrary
.. _SSHLibrary: https://github.com/MarketSquare/SSHLibrary
.. _GitHub: https://github.com/MarketSquare/SSHLibrary
.. _Python: http://python.org
.. _pip: http://pip-installer.org
.. _PyPI: https://pypi.python.org/pypi/robotframework-sshlibrary
.. _Keyword Documentation: http://robotframework.org/SSHLibrary/SSHLibrary.html
.. _Keyword Documentation: https://marketsquare.github.io/SSHLibrary/SSHLibrary.html
.. _Jython 2.7: http://jython.org
.. _paramiko: http://www.paramiko.org
.. _scp: https://github.com/jbardin/scp.py
.. _Cryptography: https://cryptography.io
.. _PyCrypto: http://www.pycrypto.org
.. _Trilead SSH JAR distribution: http://search.maven.org/remotecontent?filepath=com/trilead/trilead-ssh2/1.0.0-build221/trilead-ssh2-1.0.0-build221.jar
.. _win_inet_pton: https://github.com/hickeroar/win_inet_pton
.. _robotbackgroundlogger: https://github.com/robotframework/robotbackgroundlogger
.. _gcc: https://pkgs.alpinelinux.org/packages?name=gcc&branch=edge
.. _make: https://pkgs.alpinelinux.org/packages?name=make&branch=edge
Expand All @@ -165,4 +153,4 @@ available:
.. _robotframework-users: http://groups.google.com/group/robotframework-users
.. _Slack community: https://robotframework-slack-invite.herokuapp.com
.. _issue tracker: https://github.com/robotframework/SSHLibrary/issues
.. _Other support forums: http://robotframework.org/#support
.. _Other support forums: http://robotframework.org/#support
5 changes: 4 additions & 1 deletion atest/Tunnels.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import socket
from robot.api.deco import library, keyword


@library
class Tunnels:

@keyword
def dummy_connect(self, local_port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', int(local_port)))
s.connect(("127.0.0.1", int(local_port)))
s.close()
19 changes: 3 additions & 16 deletions atest/connections.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/common.robot
Test Teardown Close All Connections

Expand Down Expand Up @@ -37,29 +36,19 @@ Switch Connection To None
Switch Connection ${NONE}
Connection Should Be Closed

Switch to closed connection pybot
[Tags] pybot
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

Switch to closed connection jybot
[Tags] jybot
Switch to closed connection
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

Get pre-login banner without open connection
[Tags] pybot no-gh-actions
[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
[Tags] pybot
Open Connection ${HOST} prompt=${PROMPT}
Login ${USERNAME} ${PASSWORD}
${banner} = Get Pre Login Banner
Expand Down Expand Up @@ -115,12 +104,10 @@ Reuse Closed Connection Alias
Should Be Equal ${conn.alias} alias1

Connection To Host Read From SSH Config File
[Tags] pybot
Open Connection ${TEST_HOSTNAME}
Login ${USERNAME} ${PASSWORD} read_config=True

Connection To Host Ignoring SSH Config File
[Tags] pybot
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
Expand All @@ -136,7 +123,7 @@ Write Bare In Teardown Should Not Hang If Auth Failed
[Teardown] Run Keyword And Expect Error *Cannot open session, you need to establish a connection first. Write Bare ls

Login With Agent
[Tags] pybot no-gh-actions
[Tags] no-gh-actions
Open Connection ${HOST}
Login ${KEY USERNAME} allow_agent=True

Expand Down
8 changes: 2 additions & 6 deletions atest/execute_command.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/shell.robot
Suite Setup Login And Upload Test Scripts
Suite Teardown Remove Test Files And Close Connections
Expand All @@ -8,7 +7,6 @@ Library DateTime

*** Test Cases ***
Execute Timeout
[Tags] pybot
[Documentation] FAIL SSHClientException: Timed out in 3 seconds
... LOG 1:2 INFO GLOB: *Command no. 1*Command no. 2*Command no. 3*
Execute Command for i in {1..10}; do echo "Command no. $i"; sleep 1; done timeout=3s output_if_timeout=True
Expand Down Expand Up @@ -74,7 +72,6 @@ Execute Command With Robot Timeout
Execute Command cat

Execute Command With Huge Output
[Tags] pybot # this fails with jybot
[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
Expand All @@ -101,9 +98,8 @@ Execute Command With Timeout
Run Keyword and Expect Error *Timed out in 5 seconds Execute Command sleep 10 timeout=5s

Execute Command In Certain Amount Of Time
[Tags] pybot
${start_time}= Get Current Date result_format=%s exclude_millis=False
${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=%s exclude_millis=False
${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
1 change: 0 additions & 1 deletion atest/file_and_dir_exists.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Force Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login And Upload Test Files
Suite Teardown Remove Test Files and Close Connections
Expand Down
1 change: 0 additions & 1 deletion atest/get_connection.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/common.robot
Test Teardown Close All Connections
Library OperatingSystem
Expand Down
4 changes: 0 additions & 4 deletions atest/get_directory.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login and Upload Test Files
Suite Teardown Remove Test Files And Close Connections
Expand All @@ -20,7 +19,6 @@ Get Directory To Existing Local Path With SCP (transfer)
[Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True

Get Directory To Existing Local Path With SCP (all)
[Tags] pybot
[Setup] Create Directory ${LOCAL TMPDIR}
Get Directory ${REMOTE TEST ROOT} ${LOCAL TMPDIR} scp=ALL
Directory Should Exist Including Subdirectories ${LOCAL TMPDIR} ${/}robot-testdir
Expand Down Expand Up @@ -93,7 +91,6 @@ Get Directory containing a symlink
[Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True

Get Directory With SCP (transfer) And Preserve Time
[Tags] pybot
[Setup] Create Directory ${LOCAL TMPDIR}
Sleep 15s
${current_time} = Get Current Date result_format=epoch exclude_millis=False
Expand All @@ -106,7 +103,6 @@ Get Directory With SCP (transfer) And Preserve Time
[Teardown] Remove Directory ${LOCAL TMPDIR} recursive=True

Get Directory With SCP (all) And Preserve Time
[Tags] pybot
[Setup] Create Directory ${LOCAL TMPDIR}
Sleep 15s
${current_time} = Get Current Date result_format=epoch exclude_millis=False
Expand Down
4 changes: 0 additions & 4 deletions atest/get_file.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login and Upload Test Files
Suite Teardown Remove Test Files And Close Connections
Expand Down Expand Up @@ -46,7 +45,6 @@ Get File From Path Not Under Remote Home With SCP (all)
[Teardown] Remove Tmp Dir And Remote File

Get File With SCP And Pattern Matching
[Tags] pybot
[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
Expand Down Expand Up @@ -98,7 +96,6 @@ Get File That Is A Symlink Directory
[Teardown] OS.Remove File ${TEST FILE NAME}

Get File With SCP (transfer) And Preserve Time
[Tags] pybot
[Setup] Create Tmp Dir And Move File
Sleep 15s
${current_time} = Get Current Date result_format=epoch exclude_millis=False
Expand All @@ -111,7 +108,6 @@ Get File With SCP (transfer) And Preserve Time
[Teardown] Remove Tmp Dir And Remote File

Get File With SCP (all) And Preserve Time
[Tags] pybot
[Setup] Create Tmp Dir And Move File
Sleep 15s
${current_time} = Get Current Date result_format=epoch exclude_millis=False
Expand Down
1 change: 0 additions & 1 deletion atest/importing_with_args.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Force Tags pybot jybot
Library SSHLibrary 3 minutes 30 seconds ${NONE} >> INFO ${NONE}
... ${NONE} ${NONE} \\

Expand Down
1 change: 0 additions & 1 deletion atest/list_directories_in_directory.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Force Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login And Upload Test Files
Suite Teardown Remove Test Files and Close Connections
Expand Down
1 change: 0 additions & 1 deletion atest/list_directory.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Force Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login And Upload Test Files
Suite Teardown Remove Test Files and Close Connections
Expand Down
1 change: 0 additions & 1 deletion atest/list_files_in_directory.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Force Tags pybot jybot
Resource resources/sftp.robot
Suite Setup Login And Upload Test Files
Suite Teardown Remove Test Files and Close Connections
Expand Down
2 changes: 0 additions & 2 deletions atest/logging.robot
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
*** Settings ***
Default Tags pybot jybot
Resource resources/common.robot
Test Teardown Close All Connections
Library OperatingSystem

*** Test Cases ***
Enable Logging
[Tags] pybot
[Setup] Remove File ${OUTPUTDIR}${/}sshlog.txt
Enable SSH Logging ${OUTPUTDIR}${/}sshlog.txt
Login As Valid User
Expand Down
Loading

0 comments on commit fe83a68

Please sign in to comment.