cancel
Showing results for 
Search instead for 
Did you mean: 

Testing Linux command line using Ready API

Highlighted
New Contributor

Testing Linux command line using Ready API

Hi Team,

 

I am new to Ready API, I have steps in my manual test case that needs me to log on to Linux using Putty and access files, execute commands.

 

Is it feasible to log in to Linux and execute commands using Ready API. 

Note: I am using Ready API for webservices testing and as a extension of my test case I want to make property changes and restart server.

4 REPLIES 4
Community Hero

Re: Testing Linux command line using Ready API

Please elaborate more on the use case? If you are testing web services, you can verify it based on the response mostly. Why putty / or access files?


Regards,
Rao.
New Contributor

Re: Testing Linux command line using Ready API

Hi,

 

Ofcourse the webservice response is being checked on Ready API window, but as one of pre-requisite of my test case I have to make property changes, restart services and then send a SOAP request. Basically this is a negative test to verify SOAP response when server is down.

Community Hero

Re: Testing Linux command line using Ready API

Hi @vivekanandan_m ,

 

The answer to your question is yes - you can log into a Linux machine and execute commands through ReadyApi.

 

Short answer

In order to execute a command you need to create a text file that contains the command. This file must be on the same machine as the ReadyApi application. You also need to have Putty on the same machine. Then you create a groovy script step and you can execute the command as:

'cmd /c D:\\applications\\putty\\putty.exe -ssh yourserver -l yourusername -pw yourpassword -m D:\\applications\\putty\\commands.txt'.execute()

Long answer

ReadyApi can execute cmd commands through groovy script. Luckily, putty can be ran from cmd. Smiley Happy

Follow the following steps to be able to run commands from ReadyApi in Linux machines:

1. Copy Putty on the same machine as ReadyApi.

2. Again, on the same machine as ReadyApi create text files containing your commands. Normally you can put multiple commands in the same ile when working with Linux but I can't guarantee that. You will need to try it yourself.

3. Open your ReadyApi project and add a step of type Groovy script. The synthax for executing a cmd command is:

'cmd /c DUMMYCOMMAND'.execute()

4. The command for running putty is:

putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands

5. From points 3 and 5 we get then:

'cmd /c putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands'.execute()

6. Please note that when using putty.exe you also need to specify the path to it. So this would look like

'cmd /c D:\\applications\\putty\\putty.exe...

The same goes for the file containing your commands.

7. If you don't want to worry about point 6, you can always add putty to your Windows path.

 

Considerents

1. If you commit this project in git like this, you will also commit the username and password there, which is a bad practice.

2. Changing properties and restarting servers will increase your test duration. On the long run, it might be useful to find other solutions for this. (like putting property changes in the unit tests instead)



If my answer helped please click on the 'Accept as Solution' button.
Community Hero

Re: Testing Linux command line using Ready API

Alternative to passwords is to use the private key to connect.


Regards,
Rao.
New Here?
Join us and watch the welcome video:
6 / 7 API Testing Mistakes Video
Top Kudoed Authors