ContributionsMost RecentMost LikesSolutionsRe: Set SSL Keystore using Groovy on Test Step level Hi , Sorry but what i am trying to do is Delete any existing Keystores through Groovy each time the test case runs . What is happening currently is that i am able to define the TLS through groovy but then it keeps adding below the already existing certificate. Can you please help me with Delleting the Certificate fromt he Keystore Tab (using Groovy) Re: Set SSL Keystore using Groovy on Test Step level Hi All , The original issue was that we have to test our API's for Swagger Endpoints and Apigee Endpoints Swagger uses TLS Apigee uses Ping Fed tokens. Since i wanted to write the tests only 1 time and then reuse them for multiple environments (like Swagger QA , Swagger UAT , Apigee QA, Apigee UAT) I wanted a capability to Programmatically (through Groovy) Setup the TLS and Assign it to test Steps. So I was able to write the Script as i mentioned above. So now if my tests are running against Swagger URL , i am able to set the TLS Certificate (through groovy) However , when i want to run the same test for Apigee URLs (which only accept Pink Fed tokens and fails if TLS is supplied) my tests fail since i dont know how to Programatically Delete the TLS Setup. //SSL is only used for Swagger tests. Before running this test , make sure the jks certificate is saved on Local on Location : {ProjectDir}\CompositeFolderName\ZGV0Dependencies //Also make sure to define 3 Project Propertiesunder Default Environment as : a) KeystoreFolder b) KeystorePassword c)KeystoreFileName import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType import com.eviware.soapui.impl.rest.RestMethod import com.eviware.soapui.impl.rest.RestRequestInterface.HttpMethod import com.eviware.soapui.impl.rest.RestResource import com.eviware.soapui.impl.wsdl.support.wss.WssCrypto import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType def JenkinsEnv = testRunner.getTestCase().getTestSuite().getProject().getActiveEnvironmentName() log.info 'The Test Environment on which the Script is executing is : ' +JenkinsEnv def TestEnv if (JenkinsEnv.contains('Apigee')) TestEnv = "Apigee Env" else if (JenkinsEnv.contains('Default')) TestEnv = "Default Env" else if (!JenkinsEnv.contains('Apigee')) TestEnv = "Swagger Env" log.info 'Alias name of this env is : ' +TestEnv if (TestEnv.contains('Swagger')) { def GetCertificateList = testRunner.testCase.testSuite.project.wssContainer.getCryptoList() if (GetCertificateList.isEmpty()) //if no key store is defined on this project, create a keystore { log.info "No Keystore is Defined for this Project. Creating a Keystore First" //Flip the Environment to Default to get the Values below context.getTestCase().getTestSuite().getProject().setActiveEnvironment('Default environment') log.info 'Flipping the Env to : ' +testRunner.getTestCase().getTestSuite().getProject().getActiveEnvironmentName() + " to fetch some Custom Project Properties" //Get the Values of Certificate location and Certificate Password ( these values are Setup for Default environment) def RelativePath = testRunner.testCase.testSuite.project.getPath() def KeystoreFolder = context.expand( '${#Project#KeystoreFolder}' ) def KeystoreFileName = context.expand( '${#Project#KeystoreFileName}' ) def KeystorePassword= context.expand( '${#Project#KeystorePassword}' ) def KeystorePath = RelativePath+"\\"+KeystoreFolder+"\\"+KeystoreFileName log.info "Keystore is Stored on Location " + KeystorePath //Re-Flip the Env back to jenkins Env ( Jenkins sends a Trigger to run the Tests against diff env like Swagger QA or Apigee QA) context.getTestCase().getTestSuite().getProject().setActiveEnvironment(JenkinsEnv) log.info 'The Environment is flipped Back to : ' + testRunner.getTestCase().getTestSuite().getProject().getActiveEnvironmentName() //Set the TLS testRunner.testCase.testSuite.project.wssContainer.addCrypto(KeystorePath,KeystorePassword,CryptoType.KEYSTORE) //path, password, cryptoType } else { log.info "Certificate is already defined : " +GetCertificateList } GetCertificateList = testRunner.testCase.testSuite.project.wssContainer.getCryptoList() def step = testRunner.testCase.testSteps['GET - TEST'].testRequest step.setSslKeystore(GetCertificateList[0]) log.info "Selecting the Keystore for the test before running the API as : " +GetCertificateList[0] } else { log.info "Since the Test is running on Apigee , no need to setup TLS" // I need a Script here to Delete the TLS Certificate since if i dont do this , my Test Fails as Apigee does not expect TLS cert when i am hitting their end point } I am almost there but i am just missing the last piece of the puzzle. Hope i can get some help Re: Set SSL Keystore using Groovy on Test Step level Hi , Quick Update. I got the solution after i put in 3 hours into this thing. Here it goes for the community. import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType import com.eviware.soapui.impl.rest.RestMethod import com.eviware.soapui.impl.rest.RestRequestInterface.HttpMethod import com.eviware.soapui.impl.rest.RestResource import com.eviware.soapui.impl.wsdl.support.wss.WssCrypto import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType def myList = testRunner.testCase.testSuite.project.wssContainer.getCryptoList() if (myList.isEmpty()) //if no key store is defined on this project, create a keystore { log.info "No Keystore is Defined for this Project. Creating a Keystore First" testRunner.testCase.testSuite.project.wssContainer.addCrypto(context.expand( '${#Project#KeystorePath}' ),context.expand( '${#Project#KeystorePassword}' ),CryptoType.KEYSTORE) //path, password, cryptoType } //Once the Keystore is Created , Apply it to whichever tests you want to apply it to myList = testRunner.testCase.testSuite.project.wssContainer.getCryptoList() log.info myList def step = testRunner.testCase.testSteps['GET - TEST'].testRequest step.setSslKeystore(myList[0]) Set SSL Keystore using Groovy on Test Step level On the Project Level i have setup the Keystore. Now i want to be able to Select this on Test Step Level using Groovy. In the Step : Select SSL on Test Step i wrote a groovy to do the same but it is failing. import com.eviware.soapui.impl.rest.RestMethod import com.eviware.soapui.impl.rest.RestRequestInterface.HttpMethod import com.eviware.soapui.impl.rest.RestResource import com.eviware.soapui.impl.wsdl.support.wss.WssCrypto import com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep import com.eviware.soapui.impl.wsdl.support.wss.crypto.CryptoType def step = testRunner.testCase.testSteps['GET - TEST'].testRequest log.info step.getSslKeystore() // This step works fine and reads the Keystore Selected on the Test Step (if any) step.setSslKeystore( 'keystore.jks') // This step does not work and gives error message Error : groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.RestTestRequest.setSslKeystore() is applicable for argument types: (java.lang.String) values: [keystore.jks] Possible solutions: setSslKeystore(com.eviware.soapui.impl.wsdl.support.wss.WssCrypto), getSslKeystore() error at line: 13 Please note that my tests require for me to be able to select & deselect the SSL Keystore for a test step dynamically (through groovy) based on the environment i am running my tests on .. (for ex : QA , UAT etc) SolvedRe: Tags option greyed out in ReadyAPI Hi Community, I am using ReadyAPI 2.4.0 . On SOAPUI Pro > I am not able to find the Tag icon when i select the Test case. I have attached the Image below for reference. Connect to Network Path with Windows security using Groovy Scripting Hi , I have the below API Response which contains a Key : Attachment Path. I am trying to verify using Groovy Script Test Step if the file exists on that Path or not. The thing is when i try to open the path manually , i get a Windows Security popup (asking me to enter username and password) and only then can i enter the path and verify the image exists or not on that location. I found a workaround where Iff i Map this Attachment Location path in widows (maps as Z drive), i am able to use groovy to check for the existence of the image. But the problem with that is , each time my PC restarts , the Mapped drive is gone and i have to remap it for this test step to run. Can some one help me if there is a way to validate the existence of the image on this server { "Bulletin" : { "BulletinID" : "******-***-4e62-a84e-85cce1b49540", "UniqueKey" : "TS88-****", "CreatedByID" : "8989", "Title" : "Bulletin_edit", "ModuleLookupID" : "35453452", "DateClosed" : null, "IsActive" : true, "DateCreated" : "2019-06-17T03:10:50.857", "ModifiedByID" : "4354333345", "DateLastModified" : "2019-06-19T06:55:38.08", "LastModifiedBy" : "abc", "COMSmodules" : "sdadasdadas" }, "Section" : "Bulletin", "FileTitle" : "title", "FileName" : "filename.jpg", "AttachmentPath" : "\\\\blahblah.com\\abc00$\\QA\\Attachments\\Bulletins\\filename.jpg", "AttachmentID" : "54546" } Groovy Script : import groovy.json.JsonSlurper def response = context.expand( '${GET Request#Response}' ) def jsonSlurper = new JsonSlurper() def jsonObject = jsonSlurper.parseText(response) def path = jsonObject.AttachmentPath.toString() //Get the attachment Path from the API Response log.info path path = path.replaceAll("]","") Split = path.split(/[\\]/) size = Split.length FileName = Split[size-1] log.info "File name is : " +FileName Filename = "Z:\\\\"+FileName \\Mapped drive file name log.info "Mapped Path : " +Filename File file = new File(Filename) log.info "Check if the File exists on the Mapped Path : " +file.exists() assert file.exists().toString()=="true","File does not exist on the Server: Z:\" SolvedRe: Save API Response as Excel for Content-Type: application/ms-excel unfortunately i havent gotten time to look into this and have been pulled into something else. I will make sure to look into the valuable suggetions and post it on this thread. Re: Save API Response as Excel for Content-Type: application/ms-excel Hi Richie, I am attaching the Outline tab for the API (please check the screenshot Capture3.png) . After looking into it further , i see that if I hit this API and get the Response and in the Response Section > HTML Tab > Click on Save to file ... and Save it as filename.xls , then i am able to view the API Response Data (see attachment ExcelExport1.docx) Now my goal to remove the manual intervention so that the each time i hit the API with certain input params , the xls response gets saved on a particular location. any ideas if that is possible ? As again , thanks a lot to people helping me on this . Re: Save API Response as Excel for Content-Type: application/ms-excel Hi Tanya, That is how the API response is received. When i hit this API on Swagger, in the Response i get an option to download the xlsx file. I am not sure how to test this API where the Content-Type is application/ms-excel. Save API Response as Excel for Content-Type: application/ms-excel Hi , I have an API whose Raw Response is as below Request : GET {URL}?isActiveUser=true HTTP/1.1 Raw Response : HTTP/1.1 200 OK Cache-Control: private Transfer-Encoding: chunked Content-Type: application/ms-excel Server: Microsoft-IIS/10.0 content-disposition: attachment; filename=AllUsers_Active.xls X-AspNet-Version: 4.0.30319 Persistent-Auth: true X-Powered-By: ASP.NET Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: https://url.com Access-Control-Allow-Headers: Accept,Content-Type Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS Date: Mon, 03 Jun 2019 14:42:21 GMT <div> <table cellspacing="0" rules="all" border="1" style="border-collapse:collapse;"> <tr> <th scope="col">EmployeeNumber</th><th scope="col">FirstName</th><th scope="col">MiddleName</th><th scope="col">SurName</th><th scope="col">Phone</th><th scope="col">Title</th><th scope="col">RegionName</th><th scope="col">ReportsTo</th><th scope="col">ReportsToName</th><th scope="col">IsActive</th><th scope="col">Group</th> </tr><tr> <td>100221076</td><td>Pilu</td><td> </td><td>Goopos</td><td> </td><td> </td><td>Atlantic</td><td> </td><td>N/A</td><td>1</td><td> </td> </tr><tr> <td>100221845</td><td>Losedaci</td><td> </td><td>Siyezke</td><td> </td><td> </td><td>Atlantic</td><td> </td><td>N/A</td><td>1</td><td> </td> </tr><tr> <td>100224203</td><td>Euoxmi</td><td> </td><td>Olova</td><td> </td><td> </td><td>Atlantic</td><td> </td><td>N/A</td><td>1</td><td> </td> </tr> </table> </div> On UI , This API is used to save the Data of a Grid in Excel (based on the input Params) As per other Forum Topics , in my Test Case i added a Property Transfer Step and Data Sink Step to save the API Response in Excel. However , in the saved excel , I get all the API response Data in One Cell . Data is not structured as a grid . Please see the document containing Prop Transfer and Data Sink settings and my excel output . Can you please help point out how to get the API response in Excel ? Solved