简体   繁体   中英

SoapUI how to generate dynamically request password?

I need to generate the password of the request dynamically, because I need to concatenate with a timestamp and encoded with SHA-256 to get the actual password. The question will be where to create the script to generate password and how to added to the request or to a variable that is read in the request.

Is there a way to generate that password to every request?

You have full access to the Groovy language in SoapUI. You can do any sort of coding in a Groovy script test step. Then you can store the resulting value in a property :

testRunner.testCase.setPropertyValue("passwordVar", passwdResult)

And in the request XML you parameterize the value to be read from the property:

<passwordNode>${#TestCase#passwordVar}</passwordNode>

The only catch is that you will have to execute the Groovy step before the SOAP request step, but that can be done at test case level, or in a loop in Groovy, depending on your project structure. I usually have a Groovy script that:

  • does calculations or SQL to get input values
  • sets properties
  • calls the SOAP steps
  • extract required response values from resp XML

in a loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM