如何使用 Groovy 脚本设置密钥库
How to set Keystore using Groovy script
我需要设置相关的 link 证书。但是在 WS-Security Configuration - Keystores 中我只能设置绝对路径。我如何使用脚本来做到这一点?
import com.eviware.soapui.settings.SSLSettings
import com.eviware.soapui.SoapUI
// set
SoapUI.settings.setString( SSLSettings.KEYSTORE, pathToKeystore )
SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD, keystorePassword )
// get
SoapUI.settings.getString( SSLSettings.KEYSTORE, "value to return if there is no such setting set" )
https://www.soapui.org/scripting-properties/tips-tricks.html
import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType
// 1. Specify the path to your keystore
def keystorePath = "C:\pathToKeystore\your_keystore.jks"
// To use a relative path
//def keystorePath = context.expand('${projectDir}') + "\report\your_keystore.jks"
// 2. Add a keystore
testRunner.testCase.testSuite.project.wssContainer.addCrypto(keystorePath,"keystore_password",CryptoType.KEYSTORE) //path, password, cryptoType
// 3. Get the status in the log
log.info(testRunner.testCase.testSuite.project.wssContainer.getCryptoByName("your_keystore.jks").getStatus()) // specify the name of your keystore
此代码按照您的要求运行。
我需要设置相关的 link 证书。但是在 WS-Security Configuration - Keystores 中我只能设置绝对路径。我如何使用脚本来做到这一点?
import com.eviware.soapui.settings.SSLSettings
import com.eviware.soapui.SoapUI
// set
SoapUI.settings.setString( SSLSettings.KEYSTORE, pathToKeystore )
SoapUI.settings.setString( SSLSettings.KEYSTORE_PASSWORD, keystorePassword )
// get
SoapUI.settings.getString( SSLSettings.KEYSTORE, "value to return if there is no such setting set" )
https://www.soapui.org/scripting-properties/tips-tricks.html
import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType
// 1. Specify the path to your keystore
def keystorePath = "C:\pathToKeystore\your_keystore.jks"
// To use a relative path
//def keystorePath = context.expand('${projectDir}') + "\report\your_keystore.jks"
// 2. Add a keystore
testRunner.testCase.testSuite.project.wssContainer.addCrypto(keystorePath,"keystore_password",CryptoType.KEYSTORE) //path, password, cryptoType
// 3. Get the status in the log
log.info(testRunner.testCase.testSuite.project.wssContainer.getCryptoByName("your_keystore.jks").getStatus()) // specify the name of your keystore
此代码按照您的要求运行。