cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy Scripts & Base64 Encoding

SOLVED
Highlighted
New Contributor

Groovy Scripts & Base64 Encoding

Hi guys,

 

I'm new to SoapUI and I'm currently creating a SOAP project to test an API and part of the XML request that is sent needs to include user authentication which is a base64 hash of the username and password.

 

At the moment I'm creating the hash using a simple python script then copy & pasting it in to my XML request which is fine for the moment but what I'd rather do is automate the generation of the hash and inserting it in to the request.  What I'm trying to figure out is whether I can do this using a groovy script or if there is a way to get SoapUI to interact with my python script?

 

Any help appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Leader

Re: Groovy Scripts & Base64 Encoding

Hi @StooH :

 

You can store the output in class level property by following:

 

testRunner.testCase.setPropertyValue("KEYNAME", OUTPUT);

 

and store where ever in Test Case you wanted to use if you want to use by following:

 

context.expand('${#TestCase#KEYNAME}')

 

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

3 REPLIES 3
Highlighted
Community Hero

Re: Groovy Scripts & Base64 Encoding

Does it change for test or is it one time that want to convert?


Regards,
Rao.
New Contributor

Re: Groovy Scripts & Base64 Encoding

So I've managed to create a groovy script which converts the contents of a txt file in to the base64 has that I need to create, however what I'm now stuggling to do is use the hashed output from the script within the SOAP request as it just keeps returning 

Highlighted
Community Leader

Re: Groovy Scripts & Base64 Encoding

Hi @StooH :

 

You can store the output in class level property by following:

 

testRunner.testCase.setPropertyValue("KEYNAME", OUTPUT);

 

and store where ever in Test Case you wanted to use if you want to use by following:

 

context.expand('${#TestCase#KEYNAME}')

 

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors