Contributions
Base64 decode a binary content with Groovy script
I use following script to decode a Base64 coded binary content and put it into a string then write to file. byte[] decoded = slurper.signatureValue.decodeBase64(); String sigValue = new String(decoded) def path = context.expand('${Properties#outDir}') + context.expand('${Properties#fileName}') def myFile = new File(path) myFile.write(sigValue) When I useNotepad++withMIME tools pluginto decode it and save it, output is different and not sure, what is difference caused by.577Views0likes0Commentsget value from SOAP response in Script Assertion
I try to save attachment from SOAP response using followingGroovyscript asScript Assertionin SoapUI. def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def props = messageExchange.modelItem.testStep.testCase.getTestStepByName("Properties") def outputDir = new File(context.expand('${Properties#outputFolder}')) responseContent = context.response def parsedXML = new XmlSlurper().parseText(responseContent) def out_filename = parsedXML.'**'.findAll { it.name() == 'name' }.toString(); out_filename = out_filename.substring(1, out_filename.length() - 1); props.setPropertyValue("out_filename",out_filename); def fileName = outputDir.toString() + '\\' + out_filename def response = messageExchange.response assert null != response, "response is null" def outFile = new FileOutputStream(new File(fileName)) def ins = messageExchange.responseAttachments[0]?.inputStream if (ins) { com.eviware.soapui.support.Tools.writeAll(outFile, ins) } ins.close() outFile.close() It is successfully saved, when I execute it manually, but it fails when SOAP request is executed. Error:out_filenameis null.305Views0likes0CommentsError getting response; javax.net.ssl.SSLException: Connection has been shutdown
I get following error message, when I try to send big sized files. Same request is ok, when file attachment is a smaller file. I already set socket timeout and max response time to180000 ms, but got same error. Error getting response; javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Software caused connection abort: socket write error1.8KViews0likes2CommentsSoapUI 5.6.0 UnsupportedClassVersionError on Windows 8.1
I have installed following version of Java. java 15 2020-09-15 Java(TM) SE Runtime Environment (build 15+36-1562) Java HotSpot(TM) 64-Bit Server VM (build 15+36-1562, mixed mode, sharing) When I've started SoapUI 5.6, I have got following error message: java.lang.UnsupportedClassVersionError: com/eviware/soapui/SoapUI has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.exe4j.runtime.LauncherEngine.launch(LauncherEngine.java:81) at com.exe4j.runtime.WinLauncher.main(WinLauncher.java:94) at com.install4j.runtime.launcher.WinLauncher.main(WinLauncher.java:25)Solved1.1KViews0likes1CommentImplementation of RFC3161 in Groovy script
I need to get timestamp from a TSA in a Groovy script, in a SoapUI project. I try to use following script to get timestamp. import org.bouncycastle.asn1.* import org.bouncycastle.asn1.cmp.* import org.bouncycastle.operator.* import org.bouncycastle.tsp.* import com.google.inject.AbstractModule import com.google.inject.Provides import com.google.inject.Inject public interface TSAClient { public byte[] getToken(byte[] imprint) } class TSAModule extends AbstractModule { private String url private String username private String password public TSAModule(String url, String username, String password) { this.url = url this.username = username this.password = password } @Override protected void configure() { } @Provides TSAClient tsaClient() { new TSAClientImpl(url, username, password) } } public class TSAClientImpl implements TSAClient { String tsaURL = "http://localhost:5050/timestamp" String tsaUsername String tsaPassword public TSAClientImpl() { } public TSAClientImpl(String url, String username, String password) { this.tsaURL = url this.tsaUsername = username this.tsaPassword = password } @Override public byte[] getToken(byte[] imprint) { byte[] respBytes = null def algoFinder = new DefaultDigestAlgorithmIdentifierFinder() def algoIdentifier = algoFinder.find("SHA-256") // Setup the time stamp request def tsqGenerator = new TimeStampRequestGenerator() tsqGenerator.certReq = true //tsqGenerator.reqPolicy = new ASN1ObjectIdentifier("1.3.6.1.4.1.13762.3") def nonce = BigInteger.valueOf(System.currentTimeMillis()) def request = tsqGenerator.generate(algoIdentifier.objectId, imprint, nonce) byte[] requestBytes = request.encoded // Call the communications layer respBytes = getTSAResponse(requestBytes) // Handle the TSA response def response = new TimeStampResponse(respBytes) // validate communication level attributes (RFC 3161 PKIStatus) response.validate(request) def failure = response.failInfo int value = (failure == null) ? 0 : failure.intValue() if (value != 0) { throw new IOException("TSA failure: ${value} (${response.statusString})") } // extract just the time stamp token (removes communication status info) def tsToken = response.timeStampToken if (tsToken == null) { throw new IOException("TSA failed to return token: ${response.status} (${response.statusString})") } def tsTokenInfo = tsToken.timeStampInfo byte[] encoded = tsToken.encoded encoded } def getTSAResponse(byte[] requestBytes) { // Setup the TSA connection def tsaConnection = new URL(tsaURL).openConnection() tsaConnection.doInput = true tsaConnection.doOutput = true tsaConnection.useCaches = false tsaConnection.setRequestProperty("Content-Type", "application/timestamp-query") //tsaConnection.setRequestProperty("Content-Transfer-Encoding", "base64") tsaConnection.setRequestProperty("Content-Transfer-Encoding", "binary") if (tsaUsername != null && tsaUsername != "") { String userPassword = tsaUsername + ":" + tsaPassword tsaConnection.setRequestProperty("Authorization", "Basic " + userPassword.bytes.encodeBase64().toString()) } def out = tsaConnection.outputStream out << requestBytes out.close() // Get TSA response as a byte array def inp = tsaConnection.inputStream def baos = new ByteArrayOutputStream() baos << inp byte[] respBytes = baos.toByteArray() def encoding = tsaConnection.getContentEncoding() if (encoding != null && encoding.equalsIgnoreCase("base64")) { respBytes = new String(respBytes).decodeBase64() } respBytes } } I imported bcprov-jdk15on-1.62.jar, bcpkix-jdk15on-1.62.jar, guice-4.2.2.jar and javax.inject-1.jar dependencies to SOAPUI_HOME/bin/ext folder. I get following error message during execution: java.lang.NoClassDefFoundError: Unable to load class com.google.inject.AbstractModule due to missing dependency [Lorg/aopalliance/intercept/MethodInterceptor; Source of code: https://github.com/carohadad/seginf/tree/master/Sinapuli-service/src/main/groovy/garantito/sinapuli/tsa862Views0likes0CommentsExecute Groovy scripts after SOAP request in SoapUI
I execute a script from a Groovy script in SoapUI project. def tCase = testRunner.testCase.testSuite.testCases["TC1"] def tStep = tCase.testSteps["attachIt"] tStep.run(testRunner, context) There is another loop in this script, which is to execute a SOAP request. After that two more Groovy scripts should be executed to process output. These are in same testcase after SOAP request step, but aren't executed automatically.790Views0likes1Comment