Package com.privalia.qa.specs
Class SshGSpec
- java.lang.Object
-
- com.privalia.qa.specs.BaseGSpec
-
- com.privalia.qa.specs.SshGSpec
-
public class SshGSpec extends BaseGSpec
Steps definitions for running bash commands and establishing SSH connections with a remote host- Author:
- Jose Fernandez
-
-
Field Summary
-
Fields inherited from class com.privalia.qa.specs.BaseGSpec
commonspec
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
assertCommandExistsOnTimeOut(Integer timeout, Integer wait, String command, String search)
Checks ifexpectedCount
element is found, whithin atimeout
and with a locationmethod
.void
checkShellExitStatus(int expectedExitStatus)
Deprecated.Success exit status is directly checked in the "execute remote command" method, so this is not needed anymore.void
copyFromRemoteFile(String remotePath, String localPath)
Copies file/s from remote system into local systemvoid
copyToRemoteFile(String localPath, String remotePath)
Copies file/s from local system to remote systemvoid
executeCommand(String command, String foo, Integer exitStatus, String bar, String envVar)
Executes the command specified in remote systemvoid
executeLocalCommand(String command, Integer exitStatus, String envVar)
Executes the command specified in local systemvoid
findShellOutput(String search)
Check the existence of a text at a command outputvoid
notFindShellOutput(String search)
Check the non existence of a text at a command outputvoid
openSSHConnection(String remoteHost, String user, String foo, String password, String bar, String pemFile)
Opens a ssh connection to remote host-
Methods inherited from class com.privalia.qa.specs.BaseGSpec
getCommonSpec
-
-
-
-
Constructor Detail
-
SshGSpec
public SshGSpec(CommonG spec)
Default constructor.- Parameters:
spec
- CommonG object
-
-
Method Detail
-
openSSHConnection
@Given("^I open a ssh connection to \'(.+?)\' with user \'(.+?)\'( and password \'(.+?)\')?( using pem file \'(.+?)\')?$") public void openSSHConnection(String remoteHost, String user, String foo, String password, String bar, String pemFile) throws Exception
Opens a ssh connection to remote host- Parameters:
remoteHost
- remote hostuser
- remote userfoo
- the foopassword
- (required if pemFile null)bar
- the barpemFile
- (required if password null)- Throws:
Exception
- exception
-
copyFromRemoteFile
@Given("^I inbound copy \'(.+?)\' through a ssh connection to \'(.+?)\'$") public void copyFromRemoteFile(String remotePath, String localPath) throws Exception
Copies file/s from remote system into local system- Parameters:
remotePath
- path where file is going to be copylocalPath
- path where file is located- Throws:
Exception
- exception
-
copyToRemoteFile
@Given("^I outbound copy \'(.+?)\' through a ssh connection to \'(.+?)\'$") public void copyToRemoteFile(String localPath, String remotePath) throws Exception
Copies file/s from local system to remote system- Parameters:
localPath
- path where file is locatedremotePath
- path where file is going to be copy- Throws:
Exception
- exception
-
executeLocalCommand
@Given("^I run \'(.+?)\' locally( with exit status \'(.+?)\')?( and save the value in environment variable \'(.+?)\')?$") public void executeLocalCommand(String command, Integer exitStatus, String envVar) throws Exception
Executes the command specified in local system- Parameters:
command
- command to be run locallyexitStatus
- command exit statusenvVar
- environment variable name- Throws:
Exception
- exception
-
executeCommand
@Given("^I run \'(.+?)\' in the ssh connection( with exit status \'(.+?)\')?( and save the value in environment variable \'(.+?)\')?$") public void executeCommand(String command, String foo, Integer exitStatus, String bar, String envVar) throws Exception
Executes the command specified in remote system- Parameters:
command
- command to be run locallyfoo
- regex needed to match methodexitStatus
- command exit statusbar
- regex needed to match methodenvVar
- environment variable name- Throws:
Exception
- exception
-
assertCommandExistsOnTimeOut
@Then("^in less than \'(\\d+?)\' seconds, checking each \'(\\d+?)\' seconds, the command output \'(.+?)\' contains \'(.+?)\'$") public void assertCommandExistsOnTimeOut(Integer timeout, Integer wait, String command, String search) throws Exception
Checks ifexpectedCount
element is found, whithin atimeout
and with a locationmethod
. Each negative lookup is followed by a wait ofwait
seconds. Selenium times are not accounted for the mentioned timeout.- Parameters:
timeout
- the max timeto waitwait
- checking intervalcommand
- the commandsearch
- text to search for- Throws:
Exception
- exception
-
findShellOutput
@Then("^the command output contains \'(.+?)\'$") public void findShellOutput(String search) throws Exception
Check the existence of a text at a command output- Parameters:
search
- Text to search- Throws:
Exception
- Exception
-
notFindShellOutput
@Then("^the command output does not contain \'(.+?)\'$") public void notFindShellOutput(String search) throws Exception
Check the non existence of a text at a command output- Parameters:
search
- Text to search- Throws:
Exception
- Exception
-
checkShellExitStatus
@Deprecated @Then("^the command exit status is \'(.+?)\'$") public void checkShellExitStatus(int expectedExitStatus) throws Exception
Deprecated.Success exit status is directly checked in the "execute remote command" method, so this is not needed anymore.Check the exitStatus of previous command execution matches the expected one- Parameters:
expectedExitStatus
- Expected result of the command execution- Throws:
Exception
- Exception
-
-