妖碧落

导航

计算签名及beanshell断言

import org.apache.commons.codec.digest.DigestUtils;
import java.io.*;
import org.apache.jmeter.config.Arguments; 
Arguments args = sampler.getArguments(); 
String str1 = vars.get("body"); 
//String bodyStr = str1.substring(1, str1.length()).replace("(","").replace(")","");

String timestamptmp = String.valueOf(Long.valueOf("${__time(,)}"));

String query_str = "body=" + str1 + "&timestamp=" + timestamptmp + "&uid=" + "${mobile}" ; //&req_id=123
String sig = DigestUtils.sha256Hex(query_str).toUpperCase();

vars.put("timestamp",timestamptmp);
vars.put("sig",sig);
vars.put("query_str",query_str);


log.info("AAAAA"+ctx.getCurrentSampler());
//log.info("KKKKKKKKKK"+query_str);
//log.info("PPPPP"+bodyStr);

 

计算签名

import org.apache.commons.codec.digest.DigestUtils;
import org.apache.jmeter.config.Arguments; 
Arguments args = sampler.getArguments(); 
String str1 = vars.get("codebody");


String timestamptmp = String.valueOf(Long.valueOf("${__time(,)}"));

String query_str = "body=" + str1 + "&timestamp=" + timestamptmp +"&token=" +"${Token}" + "&uid=" + "${mobile}"  ; //&req_id=123

String sig = DigestUtils.sha256Hex(query_str).toUpperCase();
vars.put("timestamp",timestamptmp);
vars.put("sig",sig);

log.info("测试操作请求地址为"+ctx.getCurrentSampler());
log.info(query_str);

 


正则提取 : .*(\d{6}).*




















posted on 2020-01-20 11:45  妖碧落  阅读(235)  评论(0编辑  收藏  举报