易捷支付完整业务流程的lr脚本编写
业务流程:
1、注册
2、登录
3、重置支付密码
4、下订单
5、支付订单
6、查看订单列表
通用md5.h代码如下:
#ifndef MD5_H
#define MD5_H
#ifdef __alpha
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif
struct MD5Context {
uint32 buf[];
uint32 bits[];
unsigned char in[];
};
extern void MD5Init();
extern void MD5Update();
extern void MD5Final();
extern void MD5Transform();
typedef struct MD5Context MD5_CTX;
#endif
#ifdef sgi
#define HIGHFIRST
#endif
#ifdef sun
#define HIGHFIRST
#endif
#ifndef HIGHFIRST
#define byteReverse(buf, len) /* Nothing */
#else
void byteReverse(buf, longs)unsigned char *buf; unsigned longs;
{
uint32 t;
do {
t = (uint32) ((unsigned) buf[] << | buf[]) << |((unsigned) buf[] << | buf[]);
*(uint32 *) buf = t;
buf += ;
} while (--longs);
}
#endif
void MD5Init(ctx)struct MD5Context *ctx;
{
ctx->buf[] = 0x67452301;
ctx->buf[] = 0xefcdab89;
ctx->buf[] = 0x98badcfe;
ctx->buf[] = 0x10325476;
ctx->bits[] = ;
ctx->bits[] = ;
}
void MD5Update(ctx, buf, len) struct MD5Context *ctx; unsigned char *buf; unsigned len;
{
uint32 t;
t = ctx->bits[];
if ((ctx->bits[] = t + ((uint32) len << )) < t)
ctx->bits[]++;
ctx->bits[] += len >> ;
t = (t >> ) & 0x3f;
if (t) {
unsigned char *p = (unsigned char *) ctx->in + t;
t = - t;
if (len < t) {
memcpy(p, buf, len);
return;
}
memcpy(p, buf, t);
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += t;
len -= t;
}
while (len >= ) {
memcpy(ctx->in, buf, );
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
buf += ;
len -= ;
}
memcpy(ctx->in, buf, len);
}
void MD5Final(digest, ctx)
unsigned char digest[]; struct MD5Context *ctx;
{
unsigned count;
unsigned char *p;
count = (ctx->bits[] >> ) & 0x3F;
p = ctx->in + count;
*p++ = 0x80;
count = - - count;
if (count < ) {
memset(p, , count);
byteReverse(ctx->in, );
MD5Transform(ctx->buf, (uint32 *) ctx->in);
memset(ctx->in, , );
} else {
memset(p, , count - );
}
byteReverse(ctx->in, );
((uint32 *) ctx->in)[] = ctx->bits[];
((uint32 *) ctx->in)[] = ctx->bits[];
MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, );
memcpy(digest, ctx->buf, );
memset(ctx, , sizeof(ctx));
} #define F1(x, y, z) (z ^ (x & (y ^ z)))
#define F2(x, y, z) F1(z, x, y)
#define F3(x, y, z) (x ^ y ^ z)
#define F4(x, y, z) (y ^ (x | ~z))
#define MD5STEP(f, w, x, y, z, data, s) ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
void MD5Transform(buf, in)
uint32 buf[]; uint32 in[];
{
register uint32 a, b, c, d;
a = buf[];
b = buf[];
c = buf[];
d = buf[];
MD5STEP(F1, a, b, c, d, in[] + 0xd76aa478, );
MD5STEP(F1, d, a, b, c, in[] + 0xe8c7b756, );
MD5STEP(F1, c, d, a, b, in[] + 0x242070db, );
MD5STEP(F1, b, c, d, a, in[] + 0xc1bdceee, );
MD5STEP(F1, a, b, c, d, in[] + 0xf57c0faf, );
MD5STEP(F1, d, a, b, c, in[] + 0x4787c62a, );
MD5STEP(F1, c, d, a, b, in[] + 0xa8304613, );
MD5STEP(F1, b, c, d, a, in[] + 0xfd469501, );
MD5STEP(F1, a, b, c, d, in[] + 0x698098d8, );
MD5STEP(F1, d, a, b, c, in[] + 0x8b44f7af, );
MD5STEP(F1, c, d, a, b, in[] + 0xffff5bb1, );
MD5STEP(F1, b, c, d, a, in[] + 0x895cd7be, );
MD5STEP(F1, a, b, c, d, in[] + 0x6b901122, );
MD5STEP(F1, d, a, b, c, in[] + 0xfd987193, );
MD5STEP(F1, c, d, a, b, in[] + 0xa679438e, );
MD5STEP(F1, b, c, d, a, in[] + 0x49b40821, );
MD5STEP(F2, a, b, c, d, in[] + 0xf61e2562, );
MD5STEP(F2, d, a, b, c, in[] + 0xc040b340, );
MD5STEP(F2, c, d, a, b, in[] + 0x265e5a51, );
MD5STEP(F2, b, c, d, a, in[] + 0xe9b6c7aa, );
MD5STEP(F2, a, b, c, d, in[] + 0xd62f105d, );
MD5STEP(F2, d, a, b, c, in[] + 0x02441453, );
MD5STEP(F2, c, d, a, b, in[] + 0xd8a1e681, );
MD5STEP(F2, b, c, d, a, in[] + 0xe7d3fbc8, );
MD5STEP(F2, a, b, c, d, in[] + 0x21e1cde6, );
MD5STEP(F2, d, a, b, c, in[] + 0xc33707d6, );
MD5STEP(F2, c, d, a, b, in[] + 0xf4d50d87, );
MD5STEP(F2, b, c, d, a, in[] + 0x455a14ed, );
MD5STEP(F2, a, b, c, d, in[] + 0xa9e3e905, );
MD5STEP(F2, d, a, b, c, in[] + 0xfcefa3f8, );
MD5STEP(F2, c, d, a, b, in[] + 0x676f02d9, );
MD5STEP(F2, b, c, d, a, in[] + 0x8d2a4c8a, );
MD5STEP(F3, a, b, c, d, in[] + 0xfffa3942, );
MD5STEP(F3, d, a, b, c, in[] + 0x8771f681, );
MD5STEP(F3, c, d, a, b, in[] + 0x6d9d6122, );
MD5STEP(F3, b, c, d, a, in[] + 0xfde5380c, );
MD5STEP(F3, a, b, c, d, in[] + 0xa4beea44, );
MD5STEP(F3, d, a, b, c, in[] + 0x4bdecfa9, );
MD5STEP(F3, c, d, a, b, in[] + 0xf6bb4b60, );
MD5STEP(F3, b, c, d, a, in[] + 0xbebfbc70, );
MD5STEP(F3, a, b, c, d, in[] + 0x289b7ec6, );
MD5STEP(F3, d, a, b, c, in[] + 0xeaa127fa, );
MD5STEP(F3, c, d, a, b, in[] + 0xd4ef3085, );
MD5STEP(F3, b, c, d, a, in[] + 0x04881d05, );
MD5STEP(F3, a, b, c, d, in[] + 0xd9d4d039, );
MD5STEP(F3, d, a, b, c, in[] + 0xe6db99e5, );
MD5STEP(F3, c, d, a, b, in[] + 0x1fa27cf8, );
MD5STEP(F3, b, c, d, a, in[] + 0xc4ac5665, );
MD5STEP(F4, a, b, c, d, in[] + 0xf4292244, );
MD5STEP(F4, d, a, b, c, in[] + 0x432aff97, );
MD5STEP(F4, c, d, a, b, in[] + 0xab9423a7, );
MD5STEP(F4, b, c, d, a, in[] + 0xfc93a039, );
MD5STEP(F4, a, b, c, d, in[] + 0x655b59c3, );
MD5STEP(F4, d, a, b, c, in[] + 0x8f0ccc92, );
MD5STEP(F4, c, d, a, b, in[] + 0xffeff47d, );
MD5STEP(F4, b, c, d, a, in[] + 0x85845dd1, );
MD5STEP(F4, a, b, c, d, in[] + 0x6fa87e4f, );
MD5STEP(F4, d, a, b, c, in[] + 0xfe2ce6e0, );
MD5STEP(F4, c, d, a, b, in[] + 0xa3014314, );
MD5STEP(F4, b, c, d, a, in[] + 0x4e0811a1, );
MD5STEP(F4, a, b, c, d, in[] + 0xf7537e82, );
MD5STEP(F4, d, a, b, c, in[] + 0xbd3af235, );
MD5STEP(F4, c, d, a, b, in[] + 0x2ad7d2bb, );
MD5STEP(F4, b, c, d, a, in[] + 0xeb86d391, );
buf[] += a;
buf[] += b;
buf[] += c;
buf[] += d;
}
char* CMd5(const char* s)
{
struct MD5Context md5c;
unsigned char ss[];
char subStr[],resStr[];
int i;
MD5Init( &md5c );
MD5Update( &md5c, s, strlen(s) );
MD5Final( ss, &md5c );
strcpy(resStr,"");
for( i=; i<; i++ )
{
sprintf(subStr, "%02x", ss[i] );
itoa(ss[i],subStr,);
if (strlen(subStr)==) {
strcat(resStr,"");
}
strcat(resStr,subStr);
}
strcat(resStr,"\0");
return resStr;
}
业务lr脚本如下:
Action()
{ //================注册===========================
// web_custom_request("注册",
// "URL=http://192.168.145.130:8080/mobile/api/user/register",
// "Method=POST",
// "TargetFrame=",
// "Resource=0",
// "Referer=",
// "Mode=HTML",
// "EncType=application/json",
// "Body={\"mobile\":\"{mobile}\",\"password\":\"123456\",\"code\":\"3367\",\"platform\":\"windows\",\"username\":\"shon01\"}",
// LAST); //调用md5小写32位加密函数,将密码加密后赋值给paypassword
lr_save_string(CMd5(""),"paypassword"); web_reg_save_param_ex(
"ParamName=get_code",
"LB={\"code\":",
"RB=,\"msg\"",
SEARCH_FILTERS,
LAST);
web_reg_save_param_ex(
"ParamName=get_token",
"LB=\"token\":\"",
"RB=\",\"identity",
SEARCH_FILTERS,
LAST);
//=====================登录=====================
web_custom_request("登录",
"URL=http://192.168.145.130:8080/mobile/api/user/login",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body={\"mobile\":\"18705092505\",\"password\":\"123456\"}",
LAST);
lr_error_message("用户登录成功!%s",lr_eval_string("{get_code}"));
lr_error_message("token:%s",lr_eval_string("{get_token}")); web_reg_save_param_ex(
"ParamName=get_payId",
"LB=payId\":\"",
"RB=\",\"orders",
SEARCH_FILTERS,
LAST);
web_reg_save_param_ex(
"ParamName=value01",
"LB=,\"msg\":\"",
"RB=,\"data",
SEARCH_FILTERS,
LAST);
//中文请求参数转换
lr_convert_string_encoding( "我是肖恩",LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8, "str" );
lr_save_string(lr_eval_string("{str}"),"strvalue");
//====================下订单==============================
web_custom_request("下订单",
"URL=http://192.168.145.130:8080/mobile/api/order/addorder",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body={\"token\":\"{get_token}\",\"getAddrId\":1,\"getCarId\":23,\"payType\":2,\"remark\":\"{strvalue}\",\"price\":88,\"orders\":[{\"getTime\":\"1450921104000\",\"goodss\":[{\"goodsId\":93,\"count\":1},{\"goodsId\":96,\"count\":1}]}],\"invoiceTitle\":\"fapiao\"}",
LAST);
//响应乱码转换
lr_convert_string_encoding(lr_eval_string("{value01}"), LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"BM");
lr_error_message(lr_eval_string("{BM}"));
lr_error_message("payId:%s",lr_eval_string("{get_payId}")); web_reg_save_param_ex(
"ParamName=value03",
"LB=,\"msg\":\"",
"RB=,\"data",
SEARCH_FILTERS,
LAST); //================重置密码========================重置一次之后就不需要再重置了
/*web_custom_request("重置密码",
"URL=http://192.168.145.130:8080/mobile/api/user/resetpaypwd",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body={\"token\":\"{get_token}\",\"password\":\"{paypassword}\"}",
LAST);
lr_convert_string_encoding(lr_eval_string("{value03}"), LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"chong");
lr_error_message(lr_eval_string("{chong}"));
lr_error_message(lr_eval_string("{paypassword}")); */ web_reg_save_param_ex(
"ParamName=value02",
"LB=,\"msg\":\"",
"RB=,\"data",
SEARCH_FILTERS,
LAST);
//=================支付订单============================
web_custom_request("支付订单",
"URL=http://192.168.145.130:8080/mobile/api/pay/pay",
"Method=POST",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body={\"token\":\"{get_token}\",\"payId\":\"{get_payId}\",\"payPwd\":\"{paypassword}\",\"platform\":3}",
LAST);
lr_convert_string_encoding(lr_eval_string("{value02}"), LR_ENC_UTF8,LR_ENC_SYSTEM_LOCALE,"msg");
lr_error_message(lr_eval_string("{msg}")); lr_save_string(lr_eval_string("{get_token}"),"url_token");
//将文本格式的token转换成url的
web_convert_param("url_token", "SourceEncoding=PLAIN",
"TargetEncoding=URL", LAST ); //=====================查看订单列表========================
web_custom_request("查看订单列表",
"URL=http://192.168.145.130:8080/mobile/api/order/getorders?token={url_token}&offset=0&size=15",
"Method=GET",
"TargetFrame=",
"Resource=0",
"Referer=",
"Mode=HTML",
"EncType=application/json",
"Body=",
LAST);
return ;
}
注意:
1、将md5文件放置脚本文件下后要,添加文件,操作如下图:
2、添加md5.h文件之后,在globals.h文件里面要输入#include "md5.h" 引入,如图:
易捷支付完整业务流程的lr脚本编写的更多相关文章
- LR脚本编写时的几个小技巧
参数化空值 如上图所示,当参数化时某个值需要为空值(非空格),直接在参数化文件中空一行/格即可,虽然Parameter List界面上没有显示空的那一行,但并不影响取值. 手工日志跟踪 lr_set_ ...
- loadrunner学习系列---脚本编写(2)
loadrunner学习系列---脚本编写(2) 今天接着翻译http://www.wilsonmar.com/1lrscrīpt.htm上面关于LR脚本编写部分. VUser_Init部分 这里是V ...
- 【Java EE 学习 21 下】【 使用易宝支付接口实现java网上支付功能】
一.网上支付分为两种情况,一种方法是使用直接和银行的支付接口,另外一种方法是使用第三方支付平台和银行对接完成支付. 1.直接和银行对接. 2.使用第三方支付平台 3.常见的第三方支付平台 二.使用易宝 ...
- 易宝支付Demo,生产中封装成简洁的代付接口,不用request如何获取项目运行时的真实路径
最近项目在做融360引流,涉及到了易宝支付的代扣和代付.易宝官方给出的demo只能简单运行,而且都是通过form表单的形式提交,返回XML格式.同时接口代码都写在了JSP中看起来不友好.项目在生成中想 ...
- 自动生成LR脚本且运行
背景:作为一个测试,特别是性能测试,尤其在活动的测试,时间紧,有很多要测的,我们的LR11因为浏览器兼容问题全录制不了脚本了,用浏览器加代理或手机加代理录制,我感觉好麻烦 ,所以就想如果能用脚本把所有 ...
- 易汇金在线支付接口实例。ecshop和shopex,shopnc,iwebshop下完美无错(最新)
最近为客户的一个在线商城做了一个易汇金在线支付的接口.跟大家分享一下. 1 首先可以模仿其他的接口,比如支付宝,财付通等的接口,构建模块功能文件和语言文件. 功能模块构建: /includes/mod ...
- java实现将指定文件夹里所有文件路径输出到指定文件作为参数化文件给lr脚本使用
java实现将指定文件夹里所有文件路径输出到指定文件作为参数化文件给lr脚本使用 import java.io.BufferedReader; import java.io.BufferedWrite ...
- 【SSH网上商城项目实战21】从Demo中看易宝支付的流程
转自: https://blog.csdn.net/eson_15/article/details/51447492 这一节我们先写一个简单点的Demo来测试易宝支付的流程,熟悉这个流程后, ...
- 开发自己的网上支付案例代码(易宝支付php)
1.简单的图解(如上所示) 易宝支付与支付宝是不一样的,但也有类似之处,支付宝是专门为淘宝软件开发的一套机制,资金会在中间支付公司(支付宝)停留,等待顾客确认,当顾客确认后,才会真正扣钱.而易宝支付时 ...
随机推荐
- linux内核期中总结
20135132陈雨鑫 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...
- win10下安装GLPK
认识GLPK GLPK是一个解决线性规划问题的工具.是GNU计划下一个用于解线性规 划(Linear Programming)的工具包.它可以方便的描述线性规划问题,并给出相应解. 因此在linux系 ...
- SpringMVC-RESTRUL___CRUD知识点总结
RESTful风格 <!-- 携带surveyId去后台 --><!-- RESTFUL风格:/xxx/23 --><!-- 接收方式:@PathVariable注解 - ...
- Java面向对象(Eclipse高级、类与接口作为参数返回值)
面向对象 今日内容介绍 u Eclipse常用快捷键操作 u Eclipse文档注释导出帮助文档 u Eclipse项目的jar包导出与使用jar包 u 不同修饰符混合使用细节 u 辨析何时定义变 ...
- centos7编译安装zabbix的错误
[Z3001] connection to database 'zabbix' failed: [2002] Can't connect to local MySQL server through s ...
- PHP预防跨站脚本(XSS)攻击且不影响html代码显示效果
什么是XSS 跨站脚本攻击(Cross Site Scripting),为不和层叠样式表(Cascading Style Sheets, CSS)的缩写混淆,故将跨站脚本攻击缩写为XSS.恶意攻击者往 ...
- zip 与 unzip的简单使用
先看help Copyright (c) - Info-ZIP - Type 'zip "-L"' for software license. Zip ). Usage: zip ...
- [转帖] select、poll、epoll之间的区别总结[整理] + 知乎大神解答 https://blog.csdn.net/qq546770908/article/details/53082870 不过图都裂了.
select.poll.epoll之间的区别总结[整理] + 知乎大神解答 2016年11月08日 15:37:15 阅读数:2569 http://www.cnblogs.com/Anker/p/3 ...
- GUI and Usability Test Scenarios
1 all fields on page (e.g. text box ,radio options, dropdown lists) should be aligned properly2 Nume ...
- python 惰性求值 https://blog.csdn.net/Appleyk/article/details/77334221
为什么调用的不是同一个函数呢 是因为调用函数后,函数的生命周期就结束了,再调用就是另一个函数了