Commit e70932e5 authored by Su-Yi's avatar Su-Yi

Merge branch 'master' into test/20200708-test

# Conflicts:
#	target/test-classes/com/kjj/qa/cases/Article.class
#	target/test-classes/com/kjj/qa/cases/Novice.class
#	target/test-classes/com/kjj/qa/config/BasicConfig.class
#	target/test-classes/com/kjj/qa/utils/NetworkUtil.class
parents 17f5c240 3fa3e9a7
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;
...@@ -10,6 +14,7 @@ import org.testng.annotations.Test; ...@@ -10,6 +14,7 @@ import org.testng.annotations.Test;
import java.io.IOException; import java.io.IOException;
import java.net.CookieStore;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -232,52 +237,5 @@ public class Pay { ...@@ -232,52 +237,5 @@ public class Pay {
apiCount += 9; apiCount += 9;
} }
//切换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();
System.out.println(cookies);
// 2.登录成功,切到管理后台
// network.host = MANAGER_HOST;
// 3.切换公司为客集集
Map<String, Object> changeParams = new HashMap<String, Object>();
changeParams.put("id",sellerId);
changeParams.put("companyId",6);
response = network.getResponse(changeParams,MANAGER_CHANGECOMPANY);
// 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,"修改个人介绍失败"));
......
...@@ -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 = "T3gM31f18jAW2MCeE8iyG6ZRjTSJXb2zMDShzwbxiB1QfXDaWAXtDDZxwdjpfuyTDCHS5SP8KgvsECQm5o"; 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