断言加密的响应信息

1、在http请求-->添加-->断言-->bean shell 断言

import com.changfu.EncryptAndDecryptInterface;  //导入jar包的EncryptAndDecryptInterface类
import org.json.JSONObject; //导入
String json_res = prev.getResponseDataAsString(); //获取上个响应信息
String resb = EncryptAndDecryptInterface.getDecrypt(json_res);  //调用解密工具解密
vars.put("resb",resb);  
log.info("解密后的响应信息json="+resb);
JSONObject resbonseJson = new JSONObject(resb); //解析json
String status_str = resbonseJson.get("status").toString(); //截取status字段值
vars.put("status_str",status_str);
log.info("执行状态="+status_str);
String result = "0";
vars.put("result_str",result);
if (!status_str.equals(result)) {   //响应信息的状态值status_str不等于0,则断言其他与实际值不一致
    Failure=true;       
    FailureMessage="statuscode与实际值不一致, 实际值为:"+status_str+", 响应信息: "+resb;
}

 

 

转蜗牛:https://www.cnblogs.com/wnfindbug/p/5817114.html

posted on 2018-12-20 15:03  璇子的蓝色城堡  阅读(493)  评论(0编辑  收藏  举报