Encryption with "CryptoJS" in SoapUI
Hello everybody.
I need to send a request in JSON to a web service that must check the authorization. In the encryption is used "CryptoJS".
I have already donwloaded the library, its path is (I have attached an image with the path):
C:\Program Files\SmartBear\SoapUI-5.2.1\bin\ext
and it is well taken by Soap UI. But when I execute the groovy script I got this error:
"groovy.lang.MissingPropertyException: No such property: CryptoJS for class: Script1"
Any idea of why is it? please.
That is my code (I have attached it too) :
import components.*;
import rollups.*;
def client = 'IMS';
def key = 'DWDAWAFFAFACSCPisDJSAD';
def secret = 'A93reRTUJHsCuQSHR+L3GxqOJyDmQpCgps102ciuabc=';
def base64Secret = CryptoJS.enc.Hex.stringify(secret);
def rawSignature = client+ key +b64BodyContent;
def decoded_secret = CryptoJS.enc.Base64.parse(secret);
// Generate HMAC SHA256 signature
def hash = CryptoJS.HmacSHA256(rawSignature,decoded_secret);
def base64hash = hash.toString(CryptoJS.enc.Base64);
def auth = "amx "+ client+":"+base64hash;
//testRunner.testCase.testSuite.setPropertyValue( "OdometerUnit", value )
testRunner.setPropertyValue( "authorization", auth )
Thanks a lot in advance
Hi,
You need to add the .jar files to the <SoapUI Pro install directory>\bin\ext directory, not a zipped archive or just js files.
Please refer: https://support.smartbear.com/readyapi/docs/testing/scripts/about.html
But, unfortunately, even after downloading jar files from here: https://jar-download.com/?detail_search=a%3A%22crypto-js%22&a=crypto-js and putting them to the \bin\ext folder I get the same error.