How to set basic authentication setting in soapUI testSuite project
Tech-Today

How to set basic authentication setting in soapUI testSuite project


This post assumes that you already have soapUI installed on your machine with testCases and testSuite.

Our problem is when we have several testCases inside a testSuite that needs to be authenticated with BASIC. There are 3 ways as described here: http://thewonggei.com/2010/08/05/configure-http-basic-auth-once-for-soapui-test-suties/. Method 1 works, but method 2 and 3 failed for me.

So my workaround is to set the "Authorization" variable in the header with an encoded username:password value.

Basically what you will see in the header is:

Authorization: "BASIC xxx"

Where xxx is as described above. To encode a username and password you can use: https://www.base64encode.org/

import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.types.*;

StringToStringMap headers = new StringToStringMap();
headers.put("Authorization","Basic bWV2ZW8uYWRtaW46bWV2ZW8uYWRtaW4=");

for( testCase in testSuite.getTestCaseList() ) {
log.info("Setting basic auth for all WSDL test requests in test case ["+testCase.getLabel()+"]")
for( testStep in testCase.getTestStepList() ) {
testStep.getTestRequest().setPreemptive(true);
testStep.getTestRequest().setRequestHeaders(headers);
}
}




- How To Call A Javaee Rest Web Service With Basic Authentication Using Jquery Ajax
I don't really remember when I coded it, nor where I got it but I'm writing it here for future use :-) Below is the code I use to test CORS, http://en.wikipedia.org/wiki/Cross-origin_resource_sharing. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>...

- How To Call Java Rest Web Service In Soapui
The following code is an explanation of how you can call a rest web service in java. Below you can find the actual java code and soapUI configuration. We enumerate 3 type of methods namely: POST, PUT and DELETE. How to call rest web service using soapUI...

- Jax-rs 2.0 Security Tutorial In Javaee And Jboss
This tutorial will summarize how the author was able to call a secured rest webservice using resteasy. We will not go into detail on how we build the entire project since the code is already pushed at github. Basically we will just note down the most...

- Creating And Testing A Web Service Using Soap Ui
I just want to share a simple example on how to create and test a web service on java. Download and install the following: 1.) eclipse java (client) 2.) eclipse jee (web service) 3.) jboss 5.1 AS 4.) soap ui, get the stand alone (http://www.soapui.org/)...

- Junit 4.7 Expected Exception Failed
I recently downloaded the new version of JUnit which is 4.7 and linked it to my project. Then all the test cases that should be ok if an exception is encountered failed. My immediate solution was to remove the extends TestCase to each test classes. With...



Tech-Today








.