在SoapUI中使用Groovy的MD5 [英] MD5 using Groovy in SoapUI

查看:198
本文介绍了在SoapUI中使用Groovy的MD5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个测试用例,其中包含由键和值组成的参数。
我需要按照字母顺序采用所有这些参数,然后创建一个MD5散列值,我将传递给此测试的其中一个参数。



有什么建议?我看着谷歌,找不到有用的东西。
感谢您的提前!

解决方案

您可以使用Groovy Script测试步骤检索SoapUI的测试用例属性,如下所示。

  def map = context.testCase.properties.keySet()。inject([:]){map,key  - > map [key] = context.testCase.getPropertyValue(key); map} 
map.each {key,value - > log.info属性名称:$ {key}和value:$ {value}}

自你有map / key = value格式的属性,你应该能够实现你想要的。

/gist.github.com/ikarius/299062/85b6540c99878f50f082aaee236ef15fc78e527crel =nofollow noreferrer>这里
$ b


import java。 security.MessageDigest


$ b def generateMD5_A(String s){
MessageDigest.getInstance(MD5)。digest(s.bytes).encodeHex()。toString ()
}



I created a test case which contains parameters that consist of key and value. I need to take all those parameters in an alphabetic order, and then create a MD5 hash value which i will pass to one of the parameters of this test.

Any suggestions? i looked in google and cannot find anything helpful. Thanks ahead!

解决方案

You can retrieve the SoapUI's test case properties using a Groovy Script test step as given below.

def map = context.testCase.properties.keySet().inject([:]){map, key ->  map[key] = context.testCase.getPropertyValue(key); map }  
map.each { key, value ->     log.info "Property name : ${key} and value : ${value}" }

Since you have the properties in map / key=value format, you should able to achieve what you are looking for.

Regarding md5 generation Refer here

import java.security.MessageDigest

def generateMD5_A(String s){ MessageDigest.getInstance("MD5").digest(s.bytes).encodeHex().toString() }

这篇关于在SoapUI中使用Groovy的MD5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆