Skip to content
QiTASC.com / intaQt Built-ins /
SSH Built-ins
/ .. /
SSH Built-ins





SSH Built-ins

SSH Built-ins enable the remote execution of any command on a configured SSH server.

Example

1
2
Given check that the file "myfile.txt" is present in the folder "/Users/QiTASC/Desktop/"
And ping

Configuration

Multiple SSH servers and host keys can be added to this configuration. Three different types of SSH authentication can be configured:

  • Username and password

  • Username and identity path

  • Username and Kerberos

Configuration - Username and Password

Syntax

1
2
3
4
5
6
7
8
9
SSHServers {
    <hostKey String> {
        host                            = <String>
        port                            = <Number>
        username                        = <String>
        password                        = <String>
        connectTimeoutMillis            = <Number>
    }
}

Parameters

  • hostkey - The name of the SSH server's host key

  • host - The domain or IP address of the SSH server

  • port - The port the SSH server listens on

  • Default is set to 22

  • username - The username used for authentication

  • connectTimeoutMillis (Optional) - The timeout in milliseconds until the connection is established

  • Default is set to 10000

Example

1
2
3
4
5
6
7
8
9
SSHServers {
    qitascTestSSHServer {
        host                            = "localhost"
        port                            = 38
        username                        = "YourUsername"
        password                        = "YourPassword"
        connectTimeoutMillis            = 30000
    }
}

Configuration - Username and Identity Path

Syntax

1
2
3
4
5
6
7
8
9
SSHServers {
    <hostKey String> {
        host                            = <String>
        port                            = <Number>
        username                        = <Number>
        identityPath                    = <String>
        connectTimeoutMillis            = <Number>
    }
}

Parameters

  • hostkey - The name of the SSH server's host key

  • host - The domain or IP address of the SSH server

  • port - The port the SSH server listens on

  • Default is set to 22

  • username - The username used for authentication

  • identityPath - The private SSH key used for authentication

  • connectTimeoutMillis (Optional) - The timeout in milliseconds until the connection is established

  • Default is set to 10000

Example

1
2
3
4
5
6
7
8
9
SSHServers {
    qitascTestSSHServer2 {
        host                            = "localhost"
        port                            = 35
        username                        = "YourUsername"
        identityPath                    = "Users/YourName/.ssh/"
        connectTimeoutMillis            = 30000
    }
}

Configuration - Username and Kerberos

Syntax

1
2
3
4
5
6
7
8
9
SSHServers {
    <hostKey String> {
        host                            = <String>
        port                            = <Number>
        username                        = <String>
        enableKerberosAuthentication    = <Boolean>
        connectTimeoutMillis            = <Number>
    }
}

Parameters

  • hostkey - The name of the SSH server's host key

  • host - The domain or IP address of the SSH server

  • port - The port the SSH server listens on

  • Default is set to 22

  • username - The username used for authentication

  • enableKerberos - Enables Kerberos authentication

  • Default is set to false

  • connectTimeoutMillis (Optional) - The timeout in milliseconds until the connection is established

  • Default is set to 10000

Example

1
2
3
4
5
6
7
8
SSHServers {
    qitascTestSSHServer3 {
        host                            = "10.0.0.1"
        username                        = "YourUsername"
        enableKerberosAuthentication    = true
        connectTimeoutMillis            = 30000
    }
}

Syntax

1
execute(<hostKey String>, <command String>)

Parameters

  • hostKey - The name of the key configured in the SSHServers configuration

  • command - Can be any SSH command

Example

1
execute(qitascTestSSHServer, command)

An interactive shell session can be executed from within a test case:

Syntax

1
2
3
4
5
6
mySession := openShellSession(<HostKey String>)
mySession.execute(<Command String>)
mySession.readOutput()
mySession.readError()
mySession.readUntil(<Text String>, <timeoutMilliseconds Number>)
mySession.close()

Parameters

  • hostKey - The name of the key configured in the SSHServers configuration
  • This is used for opening and returning the interactive shell session so that commands can then be executed using execute

  • command - This can be any SSH command to be executed

  • text - When using the readUntil method, intaQt will wait until this text appears within a specified timeout

  • timeoutMilliseconds - The amount of time in milliseconds until a session will timeout when using readUntil

Additionally, the readOutput method returns the session's standard output as a string, while readErrorreturns the session's standard error as a string. Using close() will end the interactive shell session. If close() is not used, the session will close upon the test case's completion.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
session := openShellSession("qitascTestSSHServer")

session.execute("CONFIG_PATH=/some/path; export CONFIG_PATH")
println(session.readOutput())

session.execute("cd /some/other/path")
println(session.readOutput())

session.execute("echo " + parameters  + " > parameters.txt")

session.execute("run-the-script ; echo 'END OF' 'EXECUTION'")

output := session.readUntil("END OF EXECUTION", 45000)

println(output)

if ( output.contains("FAILURE") ) then
    println("Execution failed")
    assert false
end