cancel
Showing results for 
Search instead for 
Did you mean: 

How to set the keystore file and password programmatically on WsdlTestStep?

Highlighted
New Contributor

How to set the keystore file and password programmatically on WsdlTestStep?

Hi there,

We are leveraging the SoapUI test (v2.5) as a smoke test suite, and get to a stage that we can invoke the test step programmatically.  However, we are stuck at the stage that the communication does not send any client certificate (verified by inspecting the SSL communication handshake traffic in debug mode; our web service interaction requires mutual authentication).  To get the ssl cert config in, we tried setting it on the Java system variable or on the SoupUI Project xml through the for the keystore & for the password.  However the SoapUI API still seemed to ignore it.  We also tried the setSslKeystore() method on WsdlRequest but the same failure result.  Another question here is that it is unclear which method is for setting the keystore password.  There is a setPassword() method at the authentication level.  We just used it.

The interesting thing is that when we run the test case on the UI using the green arrow (i.e. submit request to the end point), it worked fine with the keystore configuration on SSL setings in the global preference.  Launch the TestRunner through the UI also returned the same failure result due to SSL cert not being sent.

Any guidance would be appreciated.  Thanks.

Ray


************Code Snippet************
ProjectFactory projectFactory = ProjectFactoryRegistry.getProjectFactory(WSDL);
WsdlProject project = (WsdlProject) projectFactory.createNew(projectFile, projectPassword);
List testSuite = project.getTestSuiteList();
WsdlTestSuite wsdlTestSuite = project.getTestSuiteByName("GetXXTestSuite");
WsdlTestCase wsdlTestCase = wsdlTestSuite.getTestCaseByName("GetXXTestCase");
WsdlTestStep wsdlTestStep = wsdlTestCase.getTestStepByName("GetXX");

// Approach 1 - Failed - No SSL Cert sent
List wsdlInterfaces = (List)wsdlTestStep.getRequiredInterfaces();
if (wsdlInterfaces.size() > 0)
{
WsdlInterface wsdlInterface = (WsdlInterface)wsdlInterfaces.get(0);
WsdlOperation wsdlOperation = wsdlInterface.getOperationByName("GetXX");
WsdlRequest wsdlRequest = wsdlOperation.getRequestByName("GetXXRequest");
wsdlRequest.setSslKeystore(keystore);
wsdlRequest.setPassword("xxx");
wsdlRequest.submit(new WsdlTestRunContext(wsdlTestStep),false);

}

// Approach 2 - Failed - No SSL Cert sent
// SSL Cert path in the project xml file
WsdlTestCaseRunner wsdlTestCaseRunner = wsdlTestCase.run(new StringToObjectMap(), false);
4 REPLIES 4
Highlighted
Super Contributor

Re: How to set the keystore file and password programmatically on WsdlTestStep?

Hi!

You have 2 options:

1) Set the global ssl-settings in your code with

SoapUI.getSettings().setString( SSLSettings.KEYSTORE, "..." )
SoapUI.getSettings().setString( SSLSettings.KEYSTORE_PASSWORD, "..." )

2) Add a Keystore to the WSS Settings in your project (in the project window, WS-Security tab) and then specify that keystores' name for the SslKeystore property on the testrequest in your testcase (not the standalon wsdlrequest);

WsdlTestRequestStep wsdlTestRequestStep = wsdlTestCase.getTestStepByName("GetXX");
wsdlTestRequestStep.getTestRequest().setSslKeystore( ".." )

Hope this helps!

/Ole
eviware.com
Highlighted
New Contributor

Re: How to set the keystore file and password programmatically on WsdlTestStep?

Thanks so much, Ole.  Will check it out.

Ray
Highlighted
New Contributor

Re: How to set the keystore file and password programmatically on WsdlTestStep?

Hey Ole,

By the way, for the option 2 that you laid out, where should we set the password for the keystore?  Appreciate all the help.

Ray
Highlighted
Super Contributor

Re: How to set the keystore file and password programmatically on WsdlTestStep?

Hi Ray,

this keystore password is specified when adding the keystore to the "Security Configurations / Keystores - Certificates" tab in the Project window.

regards!

/Ole
eviware.com
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors