Commit 6fc0a7b0 authored by Su-Yi's avatar Su-Yi

修改tku、新增管理后台工具类

parent ab1403cd
package com.kjj.qa.cases; package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*; import static com.kjj.qa.config.BasicConfig.*;
import static io.restassured.RestAssured.given;
import com.kjj.qa.utils.ManagerUtil;
import com.kjj.qa.utils.NetworkUtil; import com.kjj.qa.utils.NetworkUtil;
import io.restassured.http.ContentType;
import io.restassured.http.Cookies; import io.restassured.http.Cookies;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.testng.Assert; import org.testng.Assert;
...@@ -232,74 +236,6 @@ public class Pay { ...@@ -232,74 +236,6 @@ public class Pay {
public static void tearDown() throws IOException{ public static void tearDown() throws IOException{
apiCount += 9; apiCount += 9;
} }
/*
@Test (description = "测试",priority = 11)
public void 测试() throws IOException {
switchvip();
}
//切换vip
private static void switchvip() {
// 拿到sellerId
Response response = network.getResponse(USER_INFO);
String sellerId = response.jsonPath().getString("data.sellerId");
//1.先进入SSO登录框 登入管理后台
network.host = SSO_HOST;
Map<String, Object> loginParams = new HashMap<String, Object>();
loginParams.put("email","lihaohong");
loginParams.put("password","duiba123456");
loginParams.put("loginTimeout",1);
loginParams.put("redirect","https://kjj-mng.duibatest.com.cn");
loginParams.put("systemId",201);
response = network.postResponse(loginParams,SSO_DOLOGIN);
Cookies cookies = response.getDetailedCookies();
network.agentCookies.putAll(response.getCookies());
System.out.println(response.headers());
String redirectPath = response.jsonPath().getString("redirect");
long ssoStamp = Long.parseLong(redirectPath.substring(redirectPath.length()-13));
// 2.登录成功,切到管理后台
network.host = MANAGER_HOST;
Map<String, Object> params = new HashMap<String, Object>();
params.put("redirect",MANAGER_HOST);
params.put("ssoStamp",ssoStamp);
response = network.getResponse(params,SSO_INDEX);
response.body().prettyPrint();
System.out.println("头部:"+ response.headers());
System.out.println("登录后cookies:"+ response.getDetailedCookies());
System.out.println("cookies:" + network.agentCookies);
// cookies = response.getCookies();
// network.agentCookies.putAll(cookies);
// System.out.println("coookies:"+ network.agentCookies);
// 3.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
// 4.切换vip
Map<String, Object> switchVipParams = new HashMap<String, Object>();
switchVipParams.put("reason","1");
switchVipParams.put("sellerId",sellerId);
switchVipParams.put("userVersion",2);
switchVipParams.put("vipType",2);
switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis());
response = network.getResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
// 5.切换公司为空
changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
}
*/
} }
...@@ -82,9 +82,7 @@ public class SellerCard { ...@@ -82,9 +82,7 @@ public class SellerCard {
Map<String, Object> params = new HashMap<String, Object>(); Map<String, Object> params = new HashMap<String, Object>();
params.put("scid", scid); params.put("scid", scid);
Response response = network.getResponse(params, SELLERCARD_PERSONALPROFILE); Response response = network.getResponse(params, SELLERCARD_PERSONALPROFILE);
String intro = response.jsonPath().getString("data.personalIntro"); //个人介绍
int exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限 int exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限
// Assert.assertEquals(intro,"我在行业内深耕多年,经验丰富,具备过硬的专业素质,深受客户喜爱和支持。","个人介绍-获取介绍不匹配");
Assert.assertEquals(exprLength, 0, network.message(params, SELLERCARD_PERSONALPROFILE,"个人介绍-获取工作年限不匹配")); Assert.assertEquals(exprLength, 0, network.message(params, SELLERCARD_PERSONALPROFILE,"个人介绍-获取工作年限不匹配"));
...@@ -106,7 +104,7 @@ public class SellerCard { ...@@ -106,7 +104,7 @@ public class SellerCard {
//查看修改后的专业介绍 //查看修改后的专业介绍
response = network.getResponse(params, SELLERCARD_PERSONALPROFILE); response = network.getResponse(params, SELLERCARD_PERSONALPROFILE);
intro = response.jsonPath().getString("data.personalIntro"); //个人介绍 String intro = response.jsonPath().getString("data.personalIntro"); //个人介绍
exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限 exprLength = response.jsonPath().getInt("data.exprLength"); //工作年限
boolean isChooseGoodAtDefault = response.jsonPath().getBoolean("data.goodAtMajor.find {it.code == '16'}.choose"); boolean isChooseGoodAtDefault = response.jsonPath().getBoolean("data.goodAtMajor.find {it.code == '16'}.choose");
Assert.assertEquals(intro, "我在行业内整挺好!", network.message(params, SELLERCARD_PERSONALPROFILE,"修改个人介绍失败")); Assert.assertEquals(intro, "我在行业内整挺好!", network.message(params, SELLERCARD_PERSONALPROFILE,"修改个人介绍失败"));
......
...@@ -6,11 +6,11 @@ public class BasicConfig { ...@@ -6,11 +6,11 @@ public class BasicConfig {
// *************** 配置信息,每次重新配置以下信息就ok *************** // *************** 配置信息,每次重新配置以下信息就ok ***************
// 是否推送 // 是否推送
public static final boolean isPushReport = true; //true public static final boolean isPushReport = false; //true
// 用户微信昵称 // 用户微信昵称
public static final String WECHAT_NAME = "小疙瘩人寿"; //true public static final String WECHAT_NAME = "小疙瘩人寿"; //true
// 用户tku // 用户tku
public static final String AGENT_TKU = "T3gM31f18jAW2MCeE8iyG6ZRjTSJXb2zMDShzwbxiB1QfXDaVp8vuhk96sY6hxUTTo5qLE2jpAM4ihPTsG"; public static final String AGENT_TKU = "T3gM31f18jAW2PQLkx71aadPw9vYVqDzZH1zp832TqJmfAXmL8dYB7nRw1DdgnfCVCTDoTLhJP6uxtu9xn";
// *************** 钉钉机器人 *************** // *************** 钉钉机器人 ***************
// 线上-告警群 // 线上-告警群
......
package com.kjj.qa.utils;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
import org.apache.commons.math3.ml.neuralnet.Network;
import static com.kjj.qa.config.BasicConfig.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.qa.config.BasicConfig.SSO_DOLOGIN;
import static com.kjj.qa.config.BasicConfig.SSO_HOST;
import static io.restassured.RestAssured.given;
public class ManagerUtil {
private static final NetworkUtil network = NetworkUtil.getInstance();
public static void ssologin(){
network.host = SSO_HOST;
//1.先进入SSO登录框 登入管理后台
Map<String, Object> loginParams = new HashMap<String, Object>();
loginParams.put("email","lihaohong");
loginParams.put("password","duiba123456");
loginParams.put("loginTimeout",1);
loginParams.put("redirect",MANAGER_HOST);
loginParams.put("systemId",201);
Response response = network.postResponse(loginParams,SSO_DOLOGIN);
Map<String, String> ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies); //存入cookies
// 2.登录客集集管理后台
String redirectUrl = response.jsonPath().getString("redirect");//获取重定向地址
response = network.getManagerCookies(redirectUrl);
ssoCookies = response.getCookies();
network.agentCookies.putAll(ssoCookies);
network.agentHeaders.put("X-Csrf-Token",ssoCookies.get("csrf_token"));
}
//切换vip
public static void switchvip() {
network.host = HOST;
// 1.拿到sellerId
Response response = network.getResponse(USER_INFO);
String sellerId = response.jsonPath().getString("data.sellerId");
System.out.println(network.agentCookies);
network.host = MANAGER_HOST;
// 2.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
// 3.切换为保险版vip
Map<String, Object> switchVipParams = new HashMap<String, Object>();
switchVipParams.put("reason","1");
switchVipParams.put("sellerId",sellerId);
switchVipParams.put("userVersion",2);
switchVipParams.put("vipType",2);
switchVipParams.put("vipStartDate",System.currentTimeMillis());
switchVipParams.put("vipEndDate",System.currentTimeMillis() + 1000*3600*24*365L);
response = network.postResponse(switchVipParams,MANAGER_UPDATETYPEORDATE);
response.body().prettyPrint();
// 4.切换公司为空
changeParams.remove("companyId",6); //去掉公司
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
response.body().prettyPrint();
network.host = HOST;
}
public static void main(String[] args) throws IOException {
ssologin();
switchvip();
}
}
...@@ -112,6 +112,15 @@ public class NetworkUtil { ...@@ -112,6 +112,15 @@ public class NetworkUtil {
.post(host + path); .post(host + path);
} }
// 管理后台
public Response getManagerCookies(String path){
return given().
cookies(agentCookies).
redirects().
follow(false).
get(path);
}
// post 钉钉机器人 // post 钉钉机器人
public Response dingTalkRobot(Map<String, Object> params) { public Response dingTalkRobot(Map<String, Object> params) {
String jsonStr = JSONObject.toJSONString(params); String jsonStr = JSONObject.toJSONString(params);
......
This diff is collapsed.
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