Forum Discussion

NFox's avatar
NFox
Occasional Contributor
11 years ago

Best Method for Base64 Encoding Paramaters

Hello all,

So I have the following requirement, and was wondering if I am going about the solution in the best way.

I have a TestCase to test the registration method of a Soap Post Request.
In the header I am required to pass username and password variables, which are base64 encoded, along with some other information.

For the purpose of the TestCase, I want to be able to generate a username, which is then base64 encoded, so that I can run the test multiple times, without getting username already exists errors.

So, my plan was to:
- create a TestCase Custom Property called Base64EncodedString
- make the first teststep a groovyscript to generate a random string, then base64 encode the string, then save the string to the custom property
- use the custom property in the second teststep as a paramater in the header.

Is this an efficient way to do this?

I was looking at using the following line in the groovyscript:
def encoded = "Tester_[RandomNumber]".bytes.encodeBase64().toString()


Many thanks