no

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...

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);
 }
}

Related

java-testing 8524901988171863784

Post a Comment Default Comments

item