Forum Discussion
manAtWork
16 years agoNew Contributor
thanks kamahade,
that did the trick. I combined your script with the one from the blog and another script for encoding base64 and got:
when I use testrunner.sh (or testrunner.bat) from the console, the script is executed and I get basic authentication in all outgoing messages.
For this to work, the 'basicAuthUser' and 'basicAuthPass' properties need to be set on the test suite, of course.
thanks again!
that did the trick. I combined your script with the one from the blog and another script for encoding base64 and got:
import com.eviware.soapui.impl.wsdl.teststeps.*
import com.eviware.soapui.support.types.StringToStringMap
for( testCase in testSuite.getTestCaseList() ) {
log.info("Setting HTTP basic auth for all WSDL test requests in test case ["+
testCase.getLabel()+"]")
for( testStep in testCase.getTestStepList() ) {
if( testStep instanceof WsdlTestRequestStep ) {
def headers = new StringToStringMap()
def auth = testSuite.getPropertyValue("basicAuthUser") + ":" + testSuite.getPropertyValue("basicAuthPass")
log.info "auth: " + auth
def encodedAuth = auth.bytes.encodeBase64().toString()
log.info "encodedAuth: " + encodedAuth
headers.putIfMissing("Authorization","Basic " + encodedAuth)
testStep.getHttpRequest().setRequestHeaders(headers)
}
}
}
when I use testrunner.sh (or testrunner.bat) from the console, the script is executed and I get basic authentication in all outgoing messages.
For this to work, the 'basicAuthUser' and 'basicAuthPass' properties need to be set on the test suite, of course.
thanks again!