简体   繁体   English

SoapUI如何动态生成请求密码?

[英]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.我需要动态生成请求的密码,因为我需要与时间戳连接并使用 SHA-256 编码以获得实际密码。 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.您可以完全访问 SoapUI 中的 Groovy 语言。 You can do any sort of coding in a Groovy script test step.您可以在 Groovy 脚本测试步骤中进行任何类型的编码。 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:在请求 XML 中,您参数化要从属性中读取的值:

<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.唯一的问题是您必须在 SOAP 请求步骤之前执行 Groovy 步骤,但这可以在测试用例级别完成,也可以在 Groovy 中的循环中完成,具体取决于您的项目结构。 I usually have a Groovy script that:我通常有一个 Groovy 脚本:

  • does calculations or SQL to get input values进行计算或 SQL 以获取输入值
  • sets properties设置属性
  • calls the SOAP steps调用 SOAP 步骤
  • extract required response values from resp XML从 resp XML 中提取所需的响应值

in a loop.在一个循环中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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