Forum Discussion

d82ej9dut's avatar
d82ej9dut
Occasional Contributor
7 years ago
Solved

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

2 Replies