Forum Discussion

shaidyn's avatar
6 years ago

Making SoapUI Tests work with SSL Authentication via the command line, using relative file paths

Hi there, folks. I'm relatively new to SoapUI, and I'm trying to do something relatively complex. I've been given a SoapUI Project containing three test suits, each of which has their own tests. These reach out to an environment that requires SSL Authentication to connect. The end goal is to create a series of commands that can be entered on the command line that will run the tests. These commands will then be saved to a TeamCity implementation to automate the running of the SoapUI Tests, on a Linux RHEL box. I've tried a number of possible solutions, and each seems to get me part of the way there. I'm hoping y'all can help me connect the dots.


In the SoapUI GUI, if I go to File > Preferences > SSL Settings, I can enter the Keystore, Keystore Password, and click "Client Authentication" to "requires client authentication". This uses an absolute file path. If I run my project, everything passes.


As I understand it, the changes to the SoapUI Preferences page are "user based", meaning if I run this project elsewhere those changes won't be available. However, according to the documentation I can pass around the soapui-settings.xml file and reference it from the command line. Unfortunately, this isn't working for me. The command I'm using is:


./ -aArjJ -f "results" -t /home/[name]/soapui-settings.xml /home/[name]/Downloads/[Project].xml


When I run this command, the tests fail to authenticate. I'm pointing to the same settings file that the GUI is using, making no changes, but it doesn't work.


I decided to change tack and instead of using the Preferences, I'd use the WSS Configuration. I removed the keystore from the preferences, and I added a Keystore, which had an absolute path, and then added a reference to this keystore to each of the tests under the SSL Keystore property (found under the HTTP TestRequest Properties tab). After adding this to each test, once again, things pass! Sort of. If I run the project, all my tests will pass. But if I run my project a second time, everything fails, citing an authentication error. If I wait a few minutes, and run again, things pass once more. It's like there's a cooldown between uses of the keystore. This makes no sense to me.


I pushed on. The Keystore that I added to WSS Configuration has an absolute path, but I need relative path. I read online that I can set this programatically, using this script:


import com.eviware.soapui.settings.SSLSettings
import com.eviware.soapui.SoapUI 

// set
SoapUI.settings.setString( SSLSettings.KEYSTORE, ~/Downloads/SoapKey.p12 )
SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD, [password] )

// get
SoapUI.settings.getString( SSLSettings.KEYSTORE, "value to return if there is no such setting set" )


I opened my main project window, I selected the Test Suites tab at the top, and selected "setup script" at the bottom. But when I run my tests with this script, nothing runs, and I see this in the error log:


org.codehaus.groovy.control.MultipleCompliationErrorsException: startup failed: Script5.groovy: 4: expecting ')' found 'SoapKey'


It seems to be complaining about the name of my keystore key.


I just want to be able to run a SoapUI Project using SSL Authentication via the command line using a relative path to the .p12 file. Is there any way to make this work?



2 Replies

    • Olga_T's avatar
      SmartBear Alumni (Retired)

      Hi everyone,


      shaidyn, do you have any updates for us? Was the provided article helpful?
      If the question was answered, could you please mark it as solved so that other users could easily find the solution?

      Thanks in advance,