Commit 136d5cab authored by 赵然's avatar 赵然

zr

parent e496df78
...@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest; ...@@ -2,7 +2,10 @@ package http.cases.SingleLotteryTest;
import base.DuibaLog; import base.DuibaLog;
import base.DuibaTestBase; import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.SigninService; import http.service.hd.SigninService;
import io.restassured.http.Cookies;
import io.restassured.internal.assertion.Assertion; import io.restassured.internal.assertion.Assertion;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -10,12 +13,20 @@ import org.testng.Assert; ...@@ -10,12 +13,20 @@ import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import utils.MatcherString; import utils.MatcherString;
import java.util.Map;
import static io.restassured.RestAssured.given;
/** /**
* Created by zhaoran on 2018/6/8. * Created by zhaoran on 2018/6/8.
*/ */
public class 预览单品抽奖_AccessTest extends DuibaTestBase { public class 预览单品抽奖_AccessTest extends DuibaTestBase {
@Autowired @Autowired
SigninService signinService; SigninService signinService;
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
Authorization authorization;
private static DuibaLog logger = DuibaLog.getLogger(); private static DuibaLog logger = DuibaLog.getLogger();
@Test @Test
...@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase { ...@@ -25,6 +36,14 @@ public class 预览单品抽奖_AccessTest extends DuibaTestBase {
logger.info("预览url为:"+url); logger.info("预览url为:"+url);
Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败"); Assert.assertEquals(url.contains("http://activity.m.duibatest.com.cn/autoLogin/autologin?appKey=BDqysEMghRqpDWAaQu9S4rLihHm&uid=duiba-preview-user"), true, "校验是否展示马上使用失败");
//获取预发场景cookie
Response responses = authorization.previewLogin("BDqysEMghRqpDWAaQu9S4rLihHm","3G9A4pn8M2gVQQJbieW3CF8LRHM4");
//打开活动界面
response = singleLotteryService.index_preview("36732","preview","login",responses.getDetailedCookies());
//判断结果
Assert.assertEquals(MatcherString.getString(response.asString(),"<title>(.*?)</title>",1),"自动化_预览单抽","活动页打开异常!");
logger.info("活动页面打开成功");
} }
......
...@@ -89,7 +89,25 @@ public class SingleLotteryService { ...@@ -89,7 +89,25 @@ public class SingleLotteryService {
} }
return response; return response;
} }
public Response index_preview(String atcId,String type,String from,Cookies cookies) throws Exception {
Map<String,String> map = new HashMap<>();
map.put("id",atcId);
map.put("type",type);
map.put("from",from);
map.put("spm","18714.1.1.1");
logger.info("请求/singleLottery/index接口,id=" + atcId);
Response response = given().cookies(cookies).params(map).get("https://activity.m.duibatest.com.cn" + "/singleLottery/index");
try{
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动页打开异常");
}catch(Exception e){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/singleLottery/index接口失败,返回信息:"+response.asString());
}
return response;
}
//访问开发者自有手动开奖 //访问开发者自有手动开奖
public Response index_sd(String atcId) throws Exception { public Response index_sd(String atcId) throws Exception {
Map<String,String> map = new HashMap<>(); Map<String,String> map = new HashMap<>();
......
...@@ -173,6 +173,20 @@ public class Authorization { ...@@ -173,6 +173,20 @@ public class Authorization {
return response; return response;
} }
public Response previewLogin(String appKey,String appSecret){
CreditTool tool=new CreditTool(appKey, appSecret);
Map params=new HashMap();
params.put("uid","duiba-preview-user");
String url=tool.buildUrlWithSign("http://activity.m.duibatest.com.cn/autoLogin/autologin?",params);
logger.info("dafuweng免登陆url为:"+url);
Response response=given().redirects().follow(false).get(url);
logger.info("dafuweng免登陆,响应数据:"+response.asString());
logger.info("dafuweng免登陆,响应状态码:"+response.getStatusCode());
return response;
}
public Map generateSignAutoLogin(String appKey, int uid){ public Map generateSignAutoLogin(String appKey, int uid){
String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5"; String url = "http://activity.m.duibatest.com.cn/test/generateSign?appKey=" + appKey + "&uid=" + uid + "&vip=5";
Response response = given().get(url); Response response = given().get(url);
......
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