Book Image

Mastering SoapUI

Book Image

Mastering SoapUI

Overview of this book

SoapUI is an open-source cross-platform testing application that provides complete test coverage and supports all the standard protocols and technologies. This book includes real-time examples of implementing SoapUI to achieve quality and business assurance. Starting with the features and functionalities of SoapUI, the book will then focus on functional testing, load testing, and security testing of web services. Furthermore, you will learn how to automate your services and then design data-driven, keyword-driven, and hybrid-driven frameworks in SoapUI. Then the book will show you how to test UIs and services using SoapUI with the help of Selenium. You will also learn how to integrate SoapUI with Jenkins for CI and SoapUI test with QC with backward- and forward-compatibility. The final part of the book will show you how to virtualize a service response in SoapUI using Service Mocking. You will finish the journey by discovering the best practices for SoapUI test automation and preparing yourself for the online certification of SoapUI.
Table of Contents (18 chapters)
Mastering SoapUI
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
7
SoapUI Integration with Jenkins and HP QC
Index

Test approaches in SOA testing


Approaches to test SOA architecture are usually based on the scope of the project and requirements to test. Let's look at an example.

Following is a diagram of a three-tier architecture based on SOA architecture:

  • Validation1 or V1: Validation of integration between Presentation Layer to the Services Layer

  • Validation2 or V2: Validation of integration between Services Layer to the Service Catalogue Layer

  • Validation3 or V3: Validation of integration between Product catalogue layer and the database or backend Layer

So we have three integration points which makes us understand that we need integration testing also with functional, performance and security testing. So let's sum up the types of testing that are required to test end-to-end Greenfield projects.

  • Functional testing

  • Integration testing

  • Performance testing

  • Security testing

  • Automation testing

Functional testing

A web service may expose single or multiple functionalities via operations and sometimes we need to test a business flow which requires calling multiple services in sequence which is known as orchestration testing in which we validate that a particular business flow meets the requirement.

Let's see how to configure a SOAP service in SoapUI for functional testing

  1. Open SoapUI by clicking on the launch icon.

  2. Click on File in upper-left corner of the top navigation bar.

  3. Click on New SOAP Project heading in the File menu.

  4. Verify that a popup opens up which asks for the WSDL or WADL details. There are two ways you can pass a URL to the web location of the WSDL, or you can pass a link to the downloaded WSDL on your local system.

  5. Enter the project name details and the WSDL location which can either be on your local machine or be called from a URL, then click on OK. You may verify that the WSDL is successfully loaded in SoapUI with all the operations.

  6. Now you can see that service is successfully loaded in the workspace of SoapUI.

  7. Now, the first step toward an organized test suite is to create a test suite and relevant test cases. To achieve this, click on the operation request:

  8. When you click on Add to TestCase you are asked for the test suite name and then a test case name and finally you will be presented with the following popup:

    Here you can create a TestCase and add validations to it at run time.

  9. After clicking OK you are ready to start your functional and integration testing:

Let's take an example of how to test a simple web service functionally.

Test case: Validate that Search Customer searches for the customer from the system database using an MSISDN (Telecom Service).

Note

Please note MSISDN is a unique identifier for a user to be searched in the database and is a mandatory parameter.

API to be tested, Search Customer:

  • Request body:

    <v11:SearchCustomerRequest>
        <v11:username>TEST_Agent1</v11:username>
         <v11:orgID>COM01</v11:orgID>
         <v11:MSISDN>447830735969</v11:MSISDN>

So to test it we pass the mandatory parameters and verify the response which should get us the response parameters expected to be fetched.

By this we validate that searching for the customer using some Search criteria is successful or not, similarly, in order to test this service from a business point of view we need to validate this service with multiple scenarios. Following is a list of a few of them.

Considering it's a telecom application search customer service:

  • Verify that a prepay customer is successfully searched for using Search customer

  • Verify that a post-pay customer is successfully searched for using Search customer

  • Verify that agents are successfully searched for using search customer

  • Verify that the results retrieved in response have the right data

  • Verify that all the mandatory parameters are presenting the response of the service

Here is how the response looks:

Response Search Customer

<TBD>

Previous are some examples of Priority1 scenarios that you will require to test this service we will give it a deeper look in the following chapters.

Performance testing

So is it really possible to perform performance testing in SoapUI?

The answer is yes, if you just want to do a very simple test on your service itself, not on the orchestration.

SoapUI does have limitations when it comes to performance testing but it does provide you a functionality to generate load on your web service with different strategies.

So to start with, once you have created your SoapUI project for a service operation, you can just convert the same to a simple load test. Here is how:

  1. Right-click on the Load Test option available:

  2. Now select the name of the load test; a more relevant one will help you in future runs.

  3. You will now see that the load test popup appears and the load test is created:

  4. There are several strategies to generate load in SoapUI. The strategies are as follows:

    • Simple

    • Burst

    • Thread

    • Variance

We will learn more about performance testing using SoapUI in the following chapters.

Security testing

API and web services are highly vulnerable to security attacks and we need to be absolutely sure about the security of the exposed web service depending on the architecture of the web service and the nature of its use.

Some of the common attacks types include the following:

  • Boundary attack

  • Cross-site scripting

  • XPath injection

  • SQL injection

  • Malformed XML

  • XML bomb

  • Malicious attachment

SoapUI's security testing functionality provides scans for every attack type and also, if you want to try a custom attack on the service by writing a custom script.

So the scans provided by SoapUI are as follows:

  • Boundary scan

  • Cross-site scripting scan

  • XPath injection scan

  • SQL injection scan

  • Malformed XML scan

  • XML bomb scan

  • Malicious attachment scan

  • Fuzzing scan

  • Custom script

Following are the steps for how we configure a security test in SoapUI:

  1. You can see an option for Security Tests just below Load Tests in SoapUI.

  2. To add a test, right-click on the Security Tests and select New SecurityTest:

  3. Now select New SecurityTest and verify that a popup asking the name of the security test opens:

  4. Select the name of the security test and click on OK.

  5. After that, you should see the security test configuration window opened on the screen. For the service operation of your test case, in case of multiple operation in the same test case, you can configure for multiple operations in a single security test as well.

    For this pane you can select and configure scans on your service operations.

  6. To add a scan, click on the selected icon in the following screenshot:

  7. After selecting the icon, you can now select the scan you want to generate on your operation:

  8. After that you can configure your scan for the relevant parameter by configuring the XPath of the parameter in the request.

  9. After that you can select Assertions and Strategy tabs from the below options:

  10. You are now ready to run you security test with Boundary Scan:

Now we have learnt how to configure a simple security test in SoapUI, we will learn more about it in detail in the coming chapters.