Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
136d5cab
Commit
136d5cab
authored
Dec 07, 2018
by
赵然
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
zr
parent
e496df78
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
预览单品抽奖_AccessTest.java
.../java/http/cases/SingleLotteryTest/预览单品抽奖_AccessTest.java
+19
-0
SingleLotteryService.java
...test/java/http/service/Activity/SingleLotteryService.java
+18
-0
Authorization.java
src/test/java/http/service/Authorization.java
+14
-0
No files found.
src/test/java/http/cases/SingleLotteryTest/预览单品抽奖_AccessTest.java
View file @
136d5cab
...
@@ -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
(
"活动页面打开成功"
);
}
}
...
...
src/test/java/http/service/Activity/SingleLotteryService.java
View file @
136d5cab
...
@@ -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
<>();
...
...
src/test/java/http/service/Authorization.java
View file @
136d5cab
...
@@ -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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment