Wednesday 18 August 2021

Exporting Test Plan from SoapUI

We recently had a need to export the test plan from SoapUI since there was no test plan available on the project and we only had test data.

For export, we created a groovy script in the SoapUI project and with that we were able to export the Test plan.

Sunday 9 February 2020

SoapUI: Performing Actions on Linux Machine

Automation brings many challenges which need different solutions. We also came to a situation where we had to execute a command on a Linux platform, or, read a file/log from the Linux platform.

We created a groovy script to achieve the same. We had a lot of help from several blogs and sites and I thought it would be interesting to put the result as a complete solution at once place.


Thursday 2 January 2020

SoapUI : Maven Integration Error AutoImportMethodFactory

I have had an upgrade of my OS from Windows 7 to Windows 10. This led me to reconfigure my maven integration settings.

While launching a few of the tests that used to work perfectly before with the same configuration, I saw some new errors

10:39:11,310 ERROR [SoapUI] An error occurred [com.eviware.soapui.plugins.auto.factories.AutoDiscoveryMethodFactory], see error log for details
java.lang.ClassNotFoundException: com.eviware.soapui.plugins.auto.factories.AutoDiscoveryMethodFactory
        at java.lang.Class.forNameImpl(Native Method)
        at java.lang.Class.forName(Class.java:333)
        at com.eviware.soapui.plugins.LoaderBase.loadAutoFactories(LoaderBase.java:96)
        at com.eviware.soapui.plugins.LoaderBase.loadFactories(LoaderBase.java:64)
        at com.eviware.soapui.plugins.PluginLoader.loadPluginFactories(PluginLoader.java:129)
        at com.eviware.soapui.plugins.PluginLoader.loadPlugin(PluginLoader.java:92)
        at com.eviware.soapui.plugins.PluginLoader.loadPlugin(PluginLoader.java:42)
        at com.eviware.soapui.plugins.PluginManager.doInstallPlugin(PluginManager.java:136)
        at com.eviware.soapui.plugins.PluginManager.access$600(PluginManager.java:38)
        at com.eviware.soapui.plugins.PluginManager$LoadPluginsTask.computeSequentially(PluginManager.java:415)
        at com.eviware.soapui.plugins.PluginManager$LoadPluginsTask.compute(PluginManager.java:372)

Although these errors did not impact my tests, they did impact how the console logs were looking and hence a fix was needed.

After some google around, the fix appears to be very easy.

https://community.smartbear.com/t5/SoapUI-Open-Source/AutoDiscoveryMethodFactory-ClassNotFoundException-when-executing/td-p/105397

If the SoapUI version is 5.2.1 (I use this and found the same problem), the problem ties to the default plugins installed under "C:\Users\<user name>\.soapuios\plugin".

For SoapUI 5.2.1, there are 4 default plugins installed under this directory:
  1. readyapi-swaggerhub-plugin-1.0.jar
  2. ready-mqtt-plugin-dist.jar
  3. ready-uxm-plugin-1.0.1-dist.jar
  4. soapui-swagger-plugin-2.2-dist.jar
Just rename the original folder 'plugins' to 'plugins_NOTinUse' (or something else), so that default plugins could be forced hidden during runtime. The problem then disappeared.

It works like a charm :)

Tuesday 5 November 2019

SSL Handshake Overview

Reference : https://support.f5.com/csp/article/K15292

SSL Handshake Overview


SSL communication consists of a series of messages exchanged between two parties (client and server). The SSL handshake between a client and server consists of nine steps, and appears as follows.


The SSL messages determine the parameters of the encrypted communication channel that the two parties will use. It is important that the client and server agree on the message details, such as the protocol version, cipher suites, secure renegotiation, or client certificate requests. Otherwise the handshake will fail. The SSL handshake has the following messaging components:

ClientHello


When a client first attempts to connect to an SSL server, it initiates the session by sending a ClientHello message to the server. The ClientHello message starts the SSL communication between the two systems. The ClientHello message contains some of the following components:
  • Version: The version field contains the highest SSL version that the client supports.
  • Random: A random number generated by the client.
  • Session ID: An arbitrary sequence of bytes chosen by the server; it identifies a particular SSL session. The client may attempt to resume a previously established session by sending a non-zero session ID.
  • Cipher suites: Identifies the list of ciphers suites that the client supports.
  • Compression: Identifies the list of compression methods that the client supports.

ServerHello


If the server is able to find an acceptable set of algorithms, it responds to the ClientHello message with a ServerHello message. The server may use the ServerHello message to allow a resumed session. The ServerHello message contains some of the following components:
  • Version: The version field contains the highest SSL version supported by both the client and server.
  • Random: A random number generated by the server.
  • Session ID: Identifies a particular SSL session. If the client sends a non-zero session ID and the server locates a match in its cache, the server will attempt to respond with the same value as was supplied by the client, and resume the session using the same cipher suite.
  • Cipher suites: Identifies the cipher suite chosen by the server from the list of ciphers that the client supports.
  • Compression: Identifies the compression method chosen by the server from the list that the client supports.

Certificate


The server sends its Certificate message containing the server's certificate or list of (chain) certificates, depending on the selected cipher suite.

Note: The server may send a ServerKeyExchange message when the server Certificate message does not contain enough data to allow the client to exchange a premaster secret. This is true of some ciphers such as DHE-DSS.

ServerHelloDone


After sending its certificate, the server sends a ServerHelloDone message, indicating it is done with handshake negotiation.

ClientKeyExchange


The client sends the ClientKeyExchange message containing the PreMasterSecret. The PreMasterSecret is sent encrypted using the public key of the server.

ChangeCipherSpec


Both the client and server send the ChangeCipherSpec message after the security parameters have been determined. The ChangeCipherSpec message activates the negotiated SSL options for the session. From this point forward, all messages are authenticated and encrypted. This stage is significant as it indicates that subsequent records will be protected under the newly negotiated CipherSpec and keys.

Finished


Each party sends a Finished message under the new algorithm, keys and secrets. The Finished message indicates that the handshake is complete, and the parties may begin to exchange application layer data.


Resumed SSL sessions


A resumed SSL session implements session identifier (session ID) to re-establish a previously negotiated session. When an SSL handshake is resumed, the client presents the session ID from the previously negotiated session. If the server finds the session ID in its cache and accepts the resumed session, it sends back the same session ID and the parties skip the public key operation. If the server does not accept the resumed session, it issues a new session ID and implements the full SSL handshake. The resumed SSL handshake between a client and server consists of the following steps.

  


Testing SSL connections (using s_client)

After you enable SSL debug logging on the BIG-IP system, you should test SSL connections for the virtual server using a web browser or other utility, such as the OpenSSL utility, s_client, or cURL. Using the s_client utility may provide additional debugging information that you can use to troubleshoot the issue. After making several requests to the virtual server, you can review and analyze the debug log files on the BIG-IP system.
Impact of procedure: Performing the following procedure should not have a negative impact on your system.
  1. Log in to the command line of a Linux host (with a current version of OpenSSL) that can access the SSL virtual server.
  2. To test SSL connections for the virtual server, use the following command syntax:
    openssl s_client -connect <virtual_server>:<port> -msg
    For example:
    openssl s_client -connect 10.12.23.115:443 -msg
    openssl s_client -connect https://<url_of_website> -msg
  3. If the handshake attempt fails, take note of SSL errors returned by the s_client utility.
  4. If the handshake succeeds, type the following at the prompt:
    GET / HTTP/1.0
  5. Press Enter twice.
    The HTML page should display.


Thursday 16 May 2019

SoapUI : Websphere MQ Test Integration with Groovy

MQ Injection and reception of messages using groovy is rather easy than setting up with HermesJMS and far more stable.

Below is a simple example :



While integrating with maven, you will have to ensure that you have included the following dependencies in your pom file.




Saturday 28 July 2018

Creating Multi-Module Pom Project

In one of my previous posts, I've written about creating maven project for simple purpose. Of course maven can be used for more complex projects as well and the structure defined by maven becomes really useful.
While working on a project you'd realize it has more complex needs, you would need a system where you can develop different independent components and that leads to the scenario we are going to cover in this post. We will be creating a project with maven which will serve as parent, or you can say binding element for the build of the other sub-projects or modules. Maven has a feature which allows you to create multi module project. We are going to see how.
To create a multi module project, we will have to start with a simple project about which you can learn from my previous post Creating a simple Maven Project.

# mvn archetype:generate -DgroupId=myProject.myCompany.com -DartifactId=myProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Once done, you  would see that a directory with name "myProject" as per the artifactId defined earlier is created. Now move into this directory where you would see the pom.xml file created by maven the pom file may appear as below :



Before we move to creation of the modules, we need to do some changes in the parent pom file which was stated above. Locate and modify the lines as given below.

Modify the parameter packaging from "jar" to "pom". Now using the below command, you can create the modules.

# mvn archetype:generate -DgroupId=myProject.myCompany.com -DartifactId=myModule1 -DinteractiveMode=false
You will notice that a new directory is created in the parent directory, open the pom file inside which would appear as below


You will also notice that there are few extra lines added in the main project pom file as below Every new module created will have similar to above line added to the main pom.xml file. So that was quick update about creating a multi module pom project, hope you enjoyed and it was helpful.

Update
If you are running a latest version of maven, you would realize that the build is failing with rather strange error as below
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myModule1: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
If you have the above error while build, you might need to  add below lines in the main project's (parent) pom file under "project" head.


With above changes, you should be able to build your project successfully using the command
# mvn clean install

Thursday 6 April 2017

SoapUI, HermesJMS, IBM Websphere MQ automation with Maven

I was working on the project where I need to automate tests with interact with IBM websphere MQ queues. I have been able to achieve it from SoapUI and HermesJMS (I have already talked about the steps in my old post here) soon to face the next challenge to integrate with Jenkins and run the tests with scheduled builds. 
In my hope to find an existing solution on net, I looked for it on google. Unfortunately it didn't help that much as the solutions available did not help me but they gave me an idea about how to achieve the same. I am using maven for integration of my solution here.


Step 1 : HeremesJMS Configuration File

I would suggest to simplify the HermesJMS configuration file which was created in the steps performed in exercise earlier. Remove all the unnecessary elements and keep only those that you would need for your test.  Here below is my configuration file which I've used



You would notice that I've used a keyword "MQ_LIB_LOCATION" while providing the path of the IBM websphere MQ dependency jar files which are used by HermesJMS in order to create connection. While my experiment I realized that in order to be able to run my build I'll have to keep my hermes configuration file autonomous. Hence, I needed to update the file dynamically with help of "com.google.code.maven-replacer-plugin" of maven. With help of this plugin I change the path of the libraries used by HermesJMS.


Step 2 : Create Maven Project skeleton

As explained above we will have to update the Hermes configuration files dynamically, hence a separate maven project module would be needed for achieving this and another module will be used to execute the SoapUI project.

Create the master project using below command and then the modules under the master project
mvn archetype:generate -DgroupId=myorg.com -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
This command will create a directory "myapp" with the master project, now edit the pom file and change "packaging" parameter from "jar" to "pom" and remove the directory "src" from the master project as you will not be using it.
Once done, you can create the modules. Go to the master project directory and create the two modules with below commands
mvn archetype:generate -DgroupId=myorg.com -DartifactId=SoapProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
mvn archetype:generate -DgroupId=myorg.com -DartifactId=UpdateHermesJMS -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
Now the two projects are ready, you can update the pom file to meet your need. We will start with the project to update the Hermes configuration.


Step 3 : Module UpdateHermesJMS

Now is the time to setup your module to update the hermesJMS configuration to be able to run in any environment. For this add a "com.google.code.maven-replacer-plugin" plugin to the project. I have created a folder "resources" under "src/main/" where I have put the folder for hermes configuration "hermes", the package of hermes "HermesJMS" and the library files for IBM Websphere MQ which is needed by HermesJMS for connecting to websphere MQ.
Below is example from my project : 


Step 4 : Module SoapProject

You are now set to work on the final module which is going to execute the SoapUI tests. There are few elements you should focus on and we will discuss about them one by one. 

Dependencies : Since the module UpdateHermesJMS should be executed before the SoapProject in order to have your configuration ready, this project needs to be prioritized. For that we need to define this module as dependency in the SoapProject module

Another level of dependencies has to be defined at plugin level for HermesJMS and websphere MQ library. 


I hope you are already aware of the SoapUI project execution and related plugin. The only thing extra you may have to do is to define two additional global variable for your project that will be used by SoapUI to configure HermesJMS
<globalProperties>
    <value>HERMES_JMS=${basedir}/../updateHermesConf/src/main/resources/HermesJMS</value>
    <value>hermesConfig=${basedir}/../updateHermesConf/src/main/resources/hermes</value>
</globalProperties>

Step 5 : Project LoadScript

Your maven project should be ready, however your project still needs one more tweeks in order to be able to use the right HermesJMS and corresponding configuration file.
Open your SoapUI workspace, right click on the project click on "Show Project View" and go on "Load Script" on the window of the project and insert the below script to configure HermesJMS and its configuration from the variables we have defined in previous step.



Now you are all set with the project and you can integrate your maven project on Jenkins with a simple maven build.