Forum Discussion

Claudiu_Adam's avatar
Claudiu_Adam
Occasional Contributor
4 years ago

removing Incoming Wss and Outgoing Wss fromsoapui project

Dear all,

 

I am trying to prepare a cleanup script for one of my projects, and I am at the step where I clean all the incoming, outgoing and keystores with the following code:

 

// dependencies for setting the certs and users profiles
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.config.TestStepConfig;
import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.impl.wsdl.WsdlProjectFactory;
import com.eviware.soapui.impl.wsdl.WsdlTestSuite;
import com.eviware.soapui.impl.wsdl.support.wss.DefaultWssContainer;
import com.eviware.soapui.impl.wsdl.support.wss.IncomingWss;
import com.eviware.soapui.impl.wsdl.support.wss.OutgoingWss;
import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType;
import com.eviware.soapui.impl.wsdl.support.wss.crypto.KeyMaterialWssCrypto;
import com.eviware.soapui.impl.wsdl.support.wss.entries.SignatureEntry;
import com.eviware.soapui.impl.wsdl.support.wss.entries.TimestampEntry;
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
import com.eviware.soapui.impl.wsdl.teststeps.*;
import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepRegistry;
import com.eviware.soapui.model.settings.Settings;
import com.eviware.soapui.model.testsuite.TestStep;
import com.eviware.soapui.settings.HttpSettings;
import com.eviware.soapui.support.types.StringToStringMap;

// dependency for setting the global ssl cert
import com.eviware.soapui.settings.SSLSettings

 

def cryptoList = testRunner.testCase.testSuite.project.wssContainer.getCryptoList()
def incomingWssNo = testRunner.testCase.testSuite.project.wssContainer.getIncomingWssCount()
def outgoingWssNo = testRunner.testCase.testSuite.project.wssContainer.getOutgoingWssCount()

 

cryptoList.each { crypto ->
log.info "Crypto label removed-->${crypto.getLabel()}"
testRunner.testCase.testSuite.project.wssContainer.removeCrypto(crypto)
};


log.info incomingWssNo

if(incomingWssNo > 0)
for(int i in 0..incomingWssNo) {
testRunner.testCase.testSuite.project.wssContainer.removeIncomingWssAt(i)
}

 

log.info outgoingWssNo

if(outgoingWssNo > 0)
for(int i in 0..outgoingWssNo) {
testRunner.testCase.testSuite.project.wssContainer.removeOutgoingWssAt(i)
}

 

Even this is working, is not working properly.. for example, I got lots of out of bound index errors, if I run multiple times, all the entries will be cleaned.. I want to remove everything by a single run.. can anyone spot the issue?

 

really appreciated,

cadam

  • nmrao's avatar
    nmrao
    Champion Level 3

    Claudiu_Adam 

    Please try if the below helps. 

    NOTE: I couldn't test.

    By the way interested to know what the use case? How often these are cleared?

     

    def project =testRunner.testCase.testSuite.project
    def removeCrypto = { container -> container.each { project.wssContainer.removeCrypto(it) } }
    removeCrypto(project.wssContainer.cryptoList)
    removeCrypto(project.wssContainer.incomingWssList)
    removeCrypto(project.wssContainer.outgoingWssList)

     

    • nmrao's avatar
      nmrao
      Champion Level 3
      By the way, once the statement at line 3, executed, there may not be anything in either incoming or outgoing.
      • Claudiu_Adam's avatar
        Claudiu_Adam
        Occasional Contributor

        I am calling the code from test step level..

         

        removeCrypto accepts as parameter a WssCrypto not a list ..