Commit 9cab393d authored by Su-Yi's avatar Su-Yi

加入boss和支付的用例

parent dc7b8e48
...@@ -124,117 +124,12 @@ public class Pay { ...@@ -124,117 +124,12 @@ public class Pay {
Assert.assertEquals(userVersion,changeVersion,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为尊享版")); Assert.assertEquals(userVersion,changeVersion,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为尊享版"));
} }
@Test (description = "邀请码/分销码_付费页",priority = 6)
public void 分销码_付费页() throws IOException {
//用户绑定分销关系
// 绑定一个上级为保险版的会员,scId和inviterSid可以在用户分享的链接里拿到
Map<String, Object> distributeParams = new HashMap<String, Object>();
distributeParams.put("inviterSid","1861"); //销售ID:1861加密后 会员邀请好友付费时,传此参数
distributeParams.put("fromStr",1); //文章来源: 6文章访客转化 1会员邀请
distributeParams.put("accessSource",22); //支付来源:客集集
Response distributeResponse = network.getResponse(distributeParams, PAY_DISTRIBUTE);
String result = distributeResponse.jsonPath().getString("desc");
Assert.assertEquals(result,"OK",network.message(distributeParams, PAY_DISTRIBUTE,"绑定分销状态:绑定失败")); //判断返回的微信调起参数中appId是否正确
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
Response userVersionResponse = network.getResponse(params,VERSION_INFO);
int userVersion = userVersionResponse.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型,version应该类型为2
Assert.assertEquals(userVersion,2,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本不是上级对应的版本"));
//获取当前用户可用优惠码
Response promoCodeResponse = network.getResponse(params,PAY_GETPROMOCODE);
String promoCode = promoCodeResponse.jsonPath().getString("data");
Assert.assertEquals(promoCode,null,network.message(params, PAY_GETPROMOCODE,"是否优惠判断:判断错误,当前有优惠"));
//获取付费价格
// Response actualPayMoneyResponse = network.getResponse("/kjy/mp/combo/list/v2?code=");
// String actualPayMoney = actualPayMoneyResponse.jsonPath().getString("data[0].actualPayMoney");
// Assert.assertEquals(actualPayMoney,"486","获取付费价格:价格不是486");
}
@Test (description = "邀请码/分销码_待支付",priority = 7)
public void 分销码_待支付() throws IOException {
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
Response userVersionResponse = network.getResponse(params,VERSION_INFO);
int userVersion = userVersionResponse.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型 1保险 2通用
Assert.assertEquals(userVersion,2,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本不是上级对应的版本"));
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion",userVersion);
payParams.put("comboId","Kj21MTU");
payParams.put("oaId","1");
payParams.put("paySource","2");
payParams.put("sellerFrom","");
Response orderAppId = network.postResponse(payParams,PAY_ORDERCREATE);
String appId = orderAppId.jsonPath().getString("data.appId");
Assert.assertEquals(appId,"wxcb8c36279dd7dff2",network.message(payParams, PAY_ORDERCREATE,"拉起支付:拉起微信支付失败")); //判断返回的微信调起参数中appId是否正确
}
// @Test (description = "邀请码/分销码_成功支付",priority = 8)
// public void 分销码_成功支付() throws IOException {
//
// }
@Test (description = "邀请码/分销码_取消支付",priority = 9)
public void 分销码_取消支付() throws IOException {
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
Response userVersionResponse = network.getResponse(params,VERSION_INFO);
int userVersion = userVersionResponse.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
Assert.assertEquals(userVersion,2,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本不是上级对应的版本"));
//创建支付
Map<String, Object> payParams = new HashMap<String, Object>();
payParams.put("userVersion",userVersion);
payParams.put("comboId","Kj21MTU");
payParams.put("oaId","1");
payParams.put("paySource","2");
payParams.put("sellerFrom","");
Response orderAppId = network.postResponse(payParams,PAY_ORDERCREATE);
String tradeNo = orderAppId.jsonPath().getString("data.tradeNo");
//会员类型版本判断
Map<String, Object> cancelParams = new HashMap<String, Object>();
cancelParams.put("tradeNo",tradeNo);
Response resultResponse = network.getResponse(cancelParams,PAY_ORDERCANCEL);
String result = resultResponse.jsonPath().getString("desc");
Assert.assertEquals(result,"OK",network.message(cancelParams, PAY_ORDERCANCEL,"取消支付:取消支付失败")); //判断返回的微信调起参数中appId是否正确
}
@Test (description = "邀请码/分销码_切换会员类型为尊享版",priority = 10)
public void 分销码_切换为保险版会员类型并成功付款() throws IOException {
//会员类型版本判断
Map<String, Object> params = new HashMap<String, Object>();
params.put("t",System.currentTimeMillis());
Response userVersionResponse = network.getResponse(params,VERSION_INFO);
int userVersion = userVersionResponse.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之;
//切换版本
//切换版本
Map<String, Object> versionParams = new HashMap<String, Object>();
versionParams.put("targetVersion",changeVersion);
Response resultResponse = network.postResponse(versionParams,PAY_VERSIONEXCHANGE);
String result = resultResponse.jsonPath().getString("desc");
Assert.assertEquals(result,"OK",network.message(versionParams, PAY_VERSIONEXCHANGE,"会员类型切换:切换失败")); //判断返回的微信调起参数中appId是否正确
// //会员类型再次判断
params.put("t",System.currentTimeMillis());
userVersionResponse = network.getResponse(params,VERSION_INFO);
userVersion = userVersionResponse.jsonPath().getInt("data.find {it.openType == 1}.userVersion"); // 找出开启状态的版本类型
Assert.assertEquals(userVersion,changeVersion,network.message(params, VERSION_INFO,"会员类型版本判断:判断错误,此版本为尊享版"));
}
@AfterClass @AfterClass
public static void tearDown() throws IOException{ public static void tearDown() throws IOException{
apiCount += 9; apiCount += 6;
// 切换为保险版vip
ManagerUtil.switchvip(ManagerUtil.getSellerId());
} }
} }
......
...@@ -10,7 +10,7 @@ public class BasicConfig { ...@@ -10,7 +10,7 @@ public class BasicConfig {
// 用户微信昵称 // 用户微信昵称
public static final String WECHAT_NAME = "小疙瘩人寿"; //true public static final String WECHAT_NAME = "小疙瘩人寿"; //true
// 用户tku // 用户tku
public static final String AGENT_TKU = "T3gM31f18jAW2PQLkx71aadPw9vYVqDzZH1zp832TqJmfAXmL8dYB7nRw1DdgnfCVCTDoTLhJP6uxtu9xn"; public static final String AGENT_TKU = "T3gM31f18jAW2PQnVGBZzmH7FTj3R1RTGbfyTFzhTJoVNy5wqd7SJEgs4N8WxzCCuUZ99hovXei3GrWux7";
// *************** 钉钉机器人 *************** // *************** 钉钉机器人 ***************
// 线上-告警群 // 线上-告警群
...@@ -225,4 +225,6 @@ public class BasicConfig { ...@@ -225,4 +225,6 @@ public class BasicConfig {
public static final String MANAGER_UPDATETYPEORDATE = "/kjy/manager/seller/updateTypeOrDate"; public static final String MANAGER_UPDATETYPEORDATE = "/kjy/manager/seller/updateTypeOrDate";
public static final String MANAGER_SETINTERALSELLER = "/kjy/manager/seller/setInternalSeller"; public static final String MANAGER_SETINTERALSELLER = "/kjy/manager/seller/setInternalSeller";
public static final String MANAGER_ADMININFO = "/kjy/manager/admin/info";
} }
package com.kjj.qa.utils; package com.kjj.qa.utils;
import com.alibaba.fastjson.JSONArray;
import io.restassured.http.Cookies; import io.restassured.http.Cookies;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.math3.ml.neuralnet.Network; import org.apache.commons.math3.ml.neuralnet.Network;
import static com.kjj.qa.config.BasicConfig.*; import static com.kjj.qa.config.BasicConfig.*;
...@@ -18,9 +20,21 @@ public class ManagerUtil { ...@@ -18,9 +20,21 @@ public class ManagerUtil {
private static final NetworkUtil network = NetworkUtil.getInstance(); private static final NetworkUtil network = NetworkUtil.getInstance();
// 登录管理后台 // 登录管理后台
public static void ssologin(){ public static void ssoLogin(){
// 请求下后台的管理员信息接口
network.host = MANAGER_HOST;
Response response = network.getResponse(MANAGER_ADMININFO);
String actualType = "application/json;charset=UTF-8";
String exceptType = response.headers().getValue("Content-Type");
// 判断请求接口后 后台的Csrf-Token是否失效,若两个值相等则有效,反之
if (actualType.equals(exceptType)){
return;
}
// 1.先进入SSO登录框 登入管理后台
network.host = SSO_HOST; network.host = SSO_HOST;
//1.先进入SSO登录框 登入管理后台
Map<String, Object> loginParams = new HashMap<String, Object>(); Map<String, Object> loginParams = new HashMap<String, Object>();
loginParams.put("email","lihaohong"); loginParams.put("email","lihaohong");
loginParams.put("password","duiba123456"); loginParams.put("password","duiba123456");
...@@ -28,7 +42,7 @@ public class ManagerUtil { ...@@ -28,7 +42,7 @@ public class ManagerUtil {
loginParams.put("redirect",MANAGER_HOST); loginParams.put("redirect",MANAGER_HOST);
loginParams.put("systemId",201); loginParams.put("systemId",201);
Response response = network.postResponse(loginParams,SSO_DOLOGIN); response = network.postResponse(loginParams,SSO_DOLOGIN);
Map<String, String> ssoCookies = response.getCookies(); Map<String, String> ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies); //存入cookies network.agentCookies.putAll(ssoCookies); //存入cookies
...@@ -38,19 +52,21 @@ public class ManagerUtil { ...@@ -38,19 +52,21 @@ public class ManagerUtil {
ssoCookies = response.getCookies(); ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies); network.agentCookies.putAll(ssoCookies);
network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token")); network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token"));
network.host = MANAGER_HOST;
} }
// 拿到sellerId // 拿到sellerId
public static String getSellerId (){ public static String getSellerId (){
network.host = HOST; network.host = HOST;
Response response = network.getResponse(USER_INFO); Response response = network.getResponse(USER_INFO);
return response.jsonPath().getString("data.sellerId"); return response.jsonPath().getString("data.sellerId");
} }
// 切换vip // 切换vip
public static void switchvip(String sellerId) { public static void switchvip(String sellerId) {
network.host = MANAGER_HOST; // 登录下,检验是否失效
ssoLogin();
// 1.切换公司为客集集 // 1.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>(); Map<String, Object> changeParams = new HashMap<String, Object>();
...@@ -68,33 +84,38 @@ public class ManagerUtil { ...@@ -68,33 +84,38 @@ public class ManagerUtil {
switchVipParams.put("vipStartDate",System.currentTimeMillis()); switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L); switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L);
response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE); response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
response.body().prettyPrint();
// 3.切换公司为空 // 3.切换公司为空
changeParams.remove("companyId",6); //去掉公司 changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY); response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
network.agentHeaders.remove("X-Csrf-Token");
network.host = HOST; network.host = HOST;
} }
// 切换为内部人员 // 切换为内部人员 isInternalSeller 传1代表内部人员 传0代表非内部人员
public static void switchInsider(String sellerId){ public static void switchInsider(String sellerId,int isInternalSeller){
network.host = MANAGER_HOST; // 登录下,检验是否失效
ssoLogin();
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("id",sellerId); params.put("id",sellerId);
params.put("internalSeller",1);//1 内部 0 非内部 params.put("internalSeller",isInternalSeller);//
Response response = network.getResponse(params,MANAGER_SETINTERALSELLER); Response response = network.getResponse(params,MANAGER_SETINTERALSELLER);
response.body().prettyPrint(); response.body().prettyPrint();
network.agentHeaders.remove("X-Csrf-Token");
network.agentCookies.remove("sso_ticket");
network.agentCookies.remove("device_no");
network.agentCookies.remove("csrf_token");
network.host = HOST;
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String sellerId = getSellerId(); String sellerId = getSellerId();
ssologin(); switchInsider(sellerId,1);
switchvip(sellerId); switchvip(sellerId);
switchInsider(sellerId);
} }
} }
...@@ -6,16 +6,16 @@ ...@@ -6,16 +6,16 @@
<!-- <class name="com.kjj.qa.cases.Home"/>--> <!-- <class name="com.kjj.qa.cases.Home"/>-->
<!-- </classes>--> <!-- </classes>-->
<!-- </test>--> <!-- </test>-->
<!-- <test preserve-order="true" name="支付">-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.Pay"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="新手任务">--> <!-- <test preserve-order="true" name="新手任务">-->
<!-- <classes>--> <!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.Novice"/>--> <!-- <class name="com.kjj.qa.cases.Novice"/>-->
<!-- </classes>--> <!-- </classes>-->
<!-- </test>--> <!-- </test>-->
<test preserve-order="true" name="支付">
<classes>
<class name="com.kjj.qa.cases.Pay"/>
</classes>
</test>
<test preserve-order="true" name="名片"> <test preserve-order="true" name="名片">
<classes> <classes>
<class name="com.kjj.qa.cases.SellerCard"/> <class name="com.kjj.qa.cases.SellerCard"/>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment