Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tiku_APP_APITest
Overview
Overview
Details
Activity
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
shuai
tiku_APP_APITest
Commits
6f3c727f
Commit
6f3c727f
authored
Nov 25, 2019
by
Thinkpad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mr@20191125
parent
1adee4ff
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
2247 additions
and
167 deletions
+2247
-167
CaseMakeMr.xls
tiku_App/TestData/CaseMakeMr.xls
+0
-0
DataAllMr.xls
tiku_App/TestData/DataAllMr.xls
+0
-0
addOrEditPhone.java
tiku_App/src/com/offcn/api/tk/app3/addOrEditPhone.java
+169
-0
bindThirdLoginByUserId.java
...App/src/com/offcn/api/tk/app3/bindThirdLoginByUserId.java
+251
-0
bindUserByPhone.java
tiku_App/src/com/offcn/api/tk/app3/bindUserByPhone.java
+189
-0
checkCode.java
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
+26
-94
checkCode_web.java
tiku_App/src/com/offcn/api/tk/app3/checkCode_web.java
+198
-0
editUserName.java
tiku_App/src/com/offcn/api/tk/app3/editUserName.java
+151
-0
getAppInfo.java
tiku_App/src/com/offcn/api/tk/app3/getAppInfo.java
+153
-0
getCode.java
tiku_App/src/com/offcn/api/tk/app3/getCode.java
+52
-72
getCode_web.java
tiku_App/src/com/offcn/api/tk/app3/getCode_web.java
+190
-0
login.java
tiku_App/src/com/offcn/api/tk/app3/login.java
+183
-0
loginByPhoneCode.java
tiku_App/src/com/offcn/api/tk/app3/loginByPhoneCode.java
+181
-0
phoneRegister.java
tiku_App/src/com/offcn/api/tk/app3/phoneRegister.java
+41
-0
recordPushToken.java
tiku_App/src/com/offcn/api/tk/app3/recordPushToken.java
+139
-0
register.java
tiku_App/src/com/offcn/api/tk/app3/register.java
+0
-0
resetpasswd.java
tiku_App/src/com/offcn/api/tk/app3/resetpasswd.java
+167
-0
thirdLogin.java
tiku_App/src/com/offcn/api/tk/app3/thirdLogin.java
+0
-0
uploadUserAvator.java
tiku_App/src/com/offcn/api/tk/app3/uploadUserAvator.java
+156
-0
visitor.java
tiku_App/src/com/offcn/api/tk/app3/visitor.java
+1
-1
No files found.
tiku_App/TestData/CaseMakeMr.xls
View file @
6f3c727f
No preview for this file type
tiku_App/TestData/DataAllMr.xls
View file @
6f3c727f
No preview for this file type
tiku_App/src/com/offcn/api/tk/app3/addOrEditPhone.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 用户绑定或修改手机号
*
* @author puhui
*
*/
public
class
addOrEditPhone
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
phone
;
//手机
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"random"
))
{
phone
=
"1391"
+(
new
Random
().
nextInt
(
9000000
)+
1000000
);
parameter
=
parameter
.
replace
(
"\"phone\":random"
,
"\"phone\":\""
+
phone
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
// System.out.println(jp.getString("message"));
// String msg=StringUtils.decodeUnicode(getMsg(re));
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
phoneNeb
=
phone
;
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_user u "
,
" u.user_id = '"
+
user_id
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
String
act_phone
=
rs_bankcard
.
getString
(
"phone"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"phone"
);
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
if
(
phone
.
length
()<
60
){
if
(!(
phone
.
equals
(
act_phone
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info phone is not in DB;"
;
}
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/bindThirdLoginByUserId.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 个人中心绑定第三方账号接口
*
* @author puhui
*
*/
public
class
bindThirdLoginByUserId
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
open_id
;
//第三方登录openId
public
String
nickname
;
//昵称
public
String
avatar
;
//第三方登录用户头像
public
String
union_id
;
//微信登录的unionId(仅在微信登录时必填)
public
String
login_type
;
//第三方登录类型(当前登录方式:phone手机登录;weibo微博登录;weixin微信登录;qq腾讯登录)
public
String
user_id
;
//用户id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
union_id
=
MapUtil
.
getParameter
(
parameter
,
"union_id"
).
trim
();
open_id
=
MapUtil
.
getParameter
(
parameter
,
"open_id"
).
trim
();
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
union_id
.
equals
(
""
))
&&
union_id
.
equals
(
"code"
))
{
union_id
=
union_id_str
;
parameter
=
parameter
.
replace
(
"\"union_id\":code"
,
"\"union_id\":\""
+
union_id
+
"\""
);
}
if
((!
open_id
.
equals
(
""
))
&&
open_id
.
equals
(
"code"
))
{
open_id
=
open_id_str
;
parameter
=
parameter
.
replace
(
"\"open_id\":code"
,
"\"open_id\":\""
+
open_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
// System.out.println(jp.getString("message"));
// String msg=StringUtils.decodeUnicode(getMsg(re));
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"绑定成功"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_user u "
,
" u.user_id = '"
+
user_id
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
// String act_union_id=rs_bankcard.getString("union_id").equals("null ")?"null":rs_bankcard.getString("nickname");;
String
act_union_id
=
rs_bankcard
.
getString
(
"union_id"
);
String
act_weibo_id
=
rs_bankcard
.
getString
(
"weibo_id"
);
String
act_qq_id
=
rs_bankcard
.
getString
(
"qq_id"
);
String
act_weixin_id
=
rs_bankcard
.
getString
(
"weixin_id"
);
String
act_weibo_nickname
=
rs_bankcard
.
getString
(
"weibo_nickname"
);
String
act_qq_nickname
=
rs_bankcard
.
getString
(
"qq_nickname"
);
String
act_weixin_nickname
=
rs_bankcard
.
getString
(
"weixin_nickname"
);
String
act_weibo_avatar
=
rs_bankcard
.
getString
(
"weibo_avatar"
);
String
act_qq_avatar
=
rs_bankcard
.
getString
(
"qq_avatar"
);
String
act_weixin_avatar
=
rs_bankcard
.
getString
(
"weixin_avatar"
);
String
act_login_type
=
rs_bankcard
.
getString
(
"login_type"
);
String
act_open_id
=
""
;
String
act_nickname
=
""
;
String
act_avatar
=
""
;
if
(
"qq"
.
equals
(
act_login_type
)){
act_open_id
=
act_qq_id
;
act_nickname
=
act_qq_nickname
;
act_avatar
=
act_qq_avatar
;
}
else
if
(
"weibo"
.
equals
(
act_login_type
)){
act_open_id
=
act_weibo_id
;
act_nickname
=
act_weibo_nickname
;
act_avatar
=
act_weibo_avatar
;
}
else
if
(
"weixin"
.
equals
(
act_login_type
)){
act_open_id
=
act_weixin_id
;
act_nickname
=
act_weixin_nickname
;
act_avatar
=
act_weixin_avatar
;
}
// System.out.println((dataPhone.equals(act_phone)));
// System.out.println((dataPhone.equals(phone)));
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
union_id
=
MapUtil
.
getParameter
(
parameter
,
"union_id"
).
trim
();
union_id
=
MapUtil
.
killQuotes
(
union_id
,
"\""
);
open_id
=
MapUtil
.
getParameter
(
parameter
,
"open_id"
).
trim
();
open_id
=
MapUtil
.
killQuotes
(
open_id
,
"\""
);
nickname
=
MapUtil
.
getParameter
(
parameter
,
"nickname"
).
trim
();
nickname
=
MapUtil
.
killQuotes
(
nickname
,
"\""
);
login_type
=
MapUtil
.
getParameter
(
parameter
,
"login_type"
).
trim
();
login_type
=
MapUtil
.
killQuotes
(
login_type
,
"\""
);
avatar
=
MapUtil
.
getParameter
(
parameter
,
"avatar"
).
trim
();
avatar
=
MapUtil
.
killQuotes
(
avatar
,
"\""
);
if
(
union_id
.
length
()<
60
){
if
(!(
union_id
.
equals
(
act_union_id
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info union_id is not in DB;"
;
}
}
if
(
login_type
.
length
()<
60
){
if
(!(
login_type
.
equals
(
act_login_type
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info login_type is not in DB;"
;
}
}
if
(
nickname
.
length
()<
60
){
if
(!(
nickname
.
equals
(
act_nickname
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info nickname is not in DB;"
;
}
}
if
(
avatar
.
length
()<
60
){
if
(!(
avatar
.
equals
(
act_avatar
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info avatar is not in DB;"
;
}
}
if
(
open_id
.
length
()<
60
){
if
(!(
open_id
.
equals
(
act_open_id
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info open_id is not in DB;"
;
}
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/bindUserByPhone.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* .第三方登录接口绑定手机号
*
* @author puhui
*
*/
public
class
bindUserByPhone
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
phone
;
//用户手机号
public
String
code
;
//手机验证码
public
String
login_type
;
//第三方登录方式
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
login_type
=
MapUtil
.
getParameter
(
parameter
,
"login_type"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"绑定成功"
.
equals
(
msg
)){
String
dataPhone
=
jp
.
getString
(
"data.phone"
);
dataPhone
=
MapUtil
.
killQuotes
(
dataPhone
,
"\""
);
String
datalogin_type
=
jp
.
getString
(
"data.login_type"
);
datalogin_type
=
MapUtil
.
killQuotes
(
datalogin_type
,
"\""
);
String
token
=
jp
.
getString
(
"data.token"
);
tk_token
=
MapUtil
.
killQuotes
(
token
,
"\""
);
//保存token
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_user u "
,
" u.user_id = '"
+
user_id
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
phoneNeb
=
phone
;
String
act_phone
=
rs_bankcard
.
getString
(
"phone"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"phone"
);
String
act_login_type
=
rs_bankcard
.
getString
(
"login_type"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"login_type"
);
// if(phone.length()<60){
// if(!(dataPhone.equals(act_phone) && (dataPhone.equals(phone)))){
// result = result && false;
// failReason = failReason + "t_user info phone is not in DB;";
// }
// }
//
// if(login_type.length()<60){
// if(!(datalogin_type.equals(act_login_type) && (datalogin_type.equals(login_type)))){
// result = result && false;
// failReason = failReason + "t_user info system is not in DB;";
// }
// }
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
View file @
6f3c727f
...
...
@@ -20,10 +20,8 @@ import com.offcn.TestUnti.MapUtil;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
...
...
@@ -31,40 +29,39 @@ import net.sf.json.JSONObject;
/**
*
52、校验
验证码
*
校验手机
验证码
*
* @author
mr
* @author
puhui
*
*/
public
class
checkCode
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//
手机号
public
String
code
;
//
手机
验证码
public
String
phone
;
//
用户id
public
String
code
;
//验证码
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
...
...
@@ -72,23 +69,7 @@ public class checkCode extends TK implements API {
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"code"
,
code
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
...
...
@@ -98,7 +79,7 @@ public class checkCode extends TK implements API {
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
()
);
String
json
=
re
.
asString
(
);
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
...
...
@@ -111,83 +92,34 @@ public class checkCode extends TK implements API {
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"
ret
code"
)
+
"."
;
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"
retcode
"
)
+
"."
;
+
jp
.
getString
(
"
msg
"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"验证码发送"
.
equals
(
msg
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
// if (!isProduct) {
//
// try {
// ResultSet rs_bankcard = this.selectFromDB(
// " t_code c ",
// " c.phone = '" + phone + "' ");
// rs_bankcard.last();
//
// if(rs_bankcard.getRow()>=1){
//// code = MapUtil.killQuotes(code, "\"");
//// phone_code=code;
//
//// parameter = MapUtil.getValue("parameter", data);
//
// String act_code=rs_bankcard.getString("code");
//
// if(!act_code.equals(phone_code)){
// result = result && false;
// failReason = failReason + "t_code info code is not in DB;";
// }
//
// }
//
// } catch (Exception e) {
// result = result && false;
// failReason = failReason + "cannot verify t_code info in DB;";
// e.printStackTrace();
// }
// }
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
...
...
tiku_App/src/com/offcn/api/tk/app3/checkCode_web.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 52、校验验证码
*
* @author mr
*
*/
public
class
checkCode_web
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
code
;
//手机验证码
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"code"
,
code
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"验证码发送"
.
equals
(
msg
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
// if (!isProduct) {
//
// try {
// ResultSet rs_bankcard = this.selectFromDB(
// " t_code c ",
// " c.phone = '" + phone + "' ");
// rs_bankcard.last();
//
// if(rs_bankcard.getRow()>=1){
//// code = MapUtil.killQuotes(code, "\"");
//// phone_code=code;
//
//// parameter = MapUtil.getValue("parameter", data);
//
// String act_code=rs_bankcard.getString("code");
//
// if(!act_code.equals(phone_code)){
// result = result && false;
// failReason = failReason + "t_code info code is not in DB;";
// }
//
// }
//
// } catch (Exception e) {
// result = result && false;
// failReason = failReason + "cannot verify t_code info in DB;";
// e.printStackTrace();
// }
// }
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/editUserName.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.util.HashMap
;
import
com.offcn.TestUnti.ListUtil
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
/**
*
* @author wufeifei
* 修改用户名称
*
*/
public
class
editUserName
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
nickname
;
//用户名
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
// TODO Auto-generated method stub
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// TODO Auto-generated method stub
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
nickname
=
MapUtil
.
getParameter
(
parameter
,
"nickname"
).
trim
();
nickname
=
MapUtil
.
killQuotes
(
nickname
,
"\""
);
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// TODO Auto-generated method stub
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
// System.out.println(re.asString());
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
// TODO Auto-generated method stub
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
){
try
{
String
sql
=
"SELECT nickname FROM t_user where user_id ='"
+
user_id
+
"'"
;
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
String
act_nickname
=
rs_bankcard
.
getString
(
"nickname"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"nickname"
);
String
date_nicknameString
=
jp
.
getString
(
"data.nickname"
);
if
(!(
date_nicknameString
.
equals
(
act_nickname
)
&&
date_nicknameString
.
equals
(
nickname
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"nickname is not in DB;"
;
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getAppInfo.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 33-1.获取app版本更新信息
*
* @author puhui
*
*/
public
class
getAppInfo
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
item_id
;
//考试项目id
public
String
subtype_id
;
//练习册类别id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
item_id
=
MapUtil
.
getParameter
(
parameter
,
"item_id"
).
trim
();
subtype_id
=
MapUtil
.
getParameter
(
parameter
,
"subtype_id"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
item_id
.
equals
(
""
))
&&
item_id
.
equals
(
"code"
))
{
item_id
=
"88"
;
parameter
=
parameter
.
replace
(
"\"item_id\":code"
,
"\"item_id\":\""
+
item_id
+
"\""
);
}
if
((!
subtype_id
.
equals
(
""
))
&&
subtype_id
.
equals
(
"code"
))
{
subtype_id
=
"3"
;
parameter
=
parameter
.
replace
(
"\"subtype_id\":code"
,
"\"subtype_id\":\""
+
subtype_id
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getCode.java
View file @
6f3c727f
...
...
@@ -20,10 +20,8 @@ import com.offcn.TestUnti.MapUtil;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
...
...
@@ -31,34 +29,37 @@ import net.sf.json.JSONObject;
/**
*
51、h5
获取验证码
* 获取验证码
*
* @author
mr
* @author
puhui
*
*/
public
class
getCode
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
phone
;
//用户手机号
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"random"
))
{
phone
=
"1391"
+(
new
Random
().
nextInt
(
9000000
)+
1000000
);
parameter
=
parameter
.
replace
(
"\"phone\":random"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
...
...
@@ -66,22 +67,7 @@ public class getCode extends TK implements API {
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
...
...
@@ -91,7 +77,7 @@ public class getCode extends TK implements API {
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
()
);
String
json
=
re
.
asString
(
);
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
...
...
@@ -104,82 +90,76 @@ public class getCode extends TK implements API {
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"
ret
code"
)
+
"."
;
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"
retcode
"
)
+
"."
;
+
jp
.
getString
(
"
msg
"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"验证码发送"
.
equals
(
msg
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
if
(!
isProduct
)
{
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
phoneNeb
=
phone
;
String
data_code
=
jp
.
getString
(
"data.code"
);
phone_code
=
data_code
;
try
{
String
sql
=
"SELECT t.`code` from t_code t WHERE phone = "
+
phone
+
" ORDER BY t.id DESC LIMIT 1"
;
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
// ResultSet rs_bankcard = this.selectFromDB(
// " t_code c ",
// " id = (SELECT MAX(id) FROM t_code WHERE c.phone = '" + phone + "') ");
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_code u "
,
" u.phone = '"
+
phone
+
"'"
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
phone_code
=
act_code
;
// if(!act_code.equals(phone_code)){
// result = result && false;
// failReason = failReason + "t_code info code is not in DB;";
// }
String
act_phone
=
rs_bankcard
.
getString
(
"phone"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"phone"
);
String
act_code
=
rs_bankcard
.
getString
(
"code"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"code"
);
if
(!(
act_phone
.
equals
(
phone
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"phone is not in DB;"
;
}
if
(!(
data_code
.
equals
(
act_code
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"code is not in DB;"
;
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"
cannot verify t_code info
in DB;"
;
failReason
=
failReason
+
"
not find t_code
in DB;"
;
e
.
printStackTrace
();
}
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
...
...
tiku_App/src/com/offcn/api/tk/app3/getCode_web.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 51、h5获取验证码
*
* @author mr
*
*/
public
class
getCode_web
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"验证码发送"
.
equals
(
msg
)){
phone_code
=
jp
.
getString
(
"data.code"
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
if
(!
isProduct
)
{
try
{
String
sql
=
"SELECT t.`code` from t_code t WHERE phone = "
+
phone
+
" ORDER BY t.id DESC LIMIT 1"
;
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
// ResultSet rs_bankcard = this.selectFromDB(
// " t_code c ",
// " id = (SELECT MAX(id) FROM t_code WHERE c.phone = '" + phone + "') ");
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
phone_code
=
act_code
;
// if(!act_code.equals(phone_code)){
// result = result && false;
// failReason = failReason + "t_code info code is not in DB;";
// }
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_code info in DB;"
;
e
.
printStackTrace
();
}
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/login.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.apache.xmlbeans.impl.common.IdentityConstraint.IdState
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
public
class
login
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
passwd
;
//密码(md5加密,32位小写)
// public String system;//手机系统信息
// public String platform;//手机平台
// public String version;//版本号
// public String device_id;//设备号
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
passwd
=
MapUtil
.
getParameter
(
parameter
,
"passwd"
).
trim
();
// system = MapUtil.getParameter(parameter, "system").trim();
// platform = MapUtil.getParameter(parameter, "platform").trim();
// version = MapUtil.getParameter(parameter, "version").trim();
// device_id = MapUtil.getParameter(parameter, "device_id").trim();
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
passwd
=
MapUtil
.
killQuotes
(
passwd
,
"\""
);
// system = MapUtil.killQuotes(system, "\"");
// platform = MapUtil.killQuotes(platform, "\"");
// version = MapUtil.killQuotes(version, "\"");
// device_id = MapUtil.killQuotes(device_id, "\"");
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
// headers.put("Authorization", tk_token);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
tikuString
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
tikuString
=
MapUtil
.
killQuotes
(
tikuString
,
"\""
);
String
signString
=
MapUtil
.
getParameter
(
parameter
,
"sign"
).
trim
();
signString
=
MapUtil
.
killQuotes
(
signString
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
jsonAsMap
.
put
(
"passwd"
,
passwd
);
// jsonAsMap.put("system", system);
// jsonAsMap.put("platform", platform);
// jsonAsMap.put("version", version);
// jsonAsMap.put("device_id", device_id);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
jsonAsMap
.
put
(
"sign"
,
signString
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/loginByPhoneCode.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.system.MyRequest
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 58. 手机号、验证码登陆(中公杯使用)
*
* @author mr
*
*/
public
class
loginByPhoneCode
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
appid
;
//使用平台
public
String
code
;
//验证码
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
appid
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
phone
=
phoneNeb
;
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
tk_token
);
Map
<
String
,
String
>
jsonAsMap
=
new
HashMap
<
String
,
String
>();
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
// String tikuString= MapUtil.getParameter(parameter, "appid").trim();
// tikuString = MapUtil.killQuotes(tikuString, "\"");
// jsonAsMap.put("appid", tikuString);
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
code
=
MapUtil
.
killQuotes
(
code
,
"\""
);
jsonAsMap
.
put
(
"code"
,
code
);
if
(
parameter
.
contains
(
"appid"
)){
appid
=
MapUtil
.
killQuotes
(
appid
,
"\""
);
jsonAsMap
.
put
(
"appid"
,
appid
);
}
String
sign
=
MapUtil
.
getParameter
(
parameter
,
"sign"
).
trim
();
sign
=
MapUtil
.
killQuotes
(
sign
,
"\""
);
jsonAsMap
.
put
(
"sign"
,
sign
);
MyRequest
myRequest
=
new
MyRequest
();
myRequest
.
setUrl
(
Url
);
myRequest
.
setHeaders
(
headers
);
myRequest
.
setFormParameter
(
jsonAsMap
);
myRequest
.
setRequest
(
Request
);
Response
re
=
RequestDataUtils
.
RestAssuredApi
(
data
,
myRequest
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"retcode"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"登录成功"
.
equals
(
msg
)){
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/phoneRegister.java
View file @
6f3c727f
...
...
@@ -164,6 +164,47 @@ public class phoneRegister extends TK implements API {
if
(
"注册成功"
.
equals
(
msg
)){
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
phoneNeb
=
phone
;
String
user_id
=
jp
.
getString
(
"data.userinfo.user_id"
);
user_id
=
MapUtil
.
killQuotes
(
user_id
,
"\""
);
user_idList
.
add
(
user_id
);
String
dataPhone
=
jp
.
getString
(
"data.userinfo.phone"
);
dataPhone
=
MapUtil
.
killQuotes
(
dataPhone
,
"\""
);
String
token
=
jp
.
getString
(
"data.token"
);
tk_token
=
MapUtil
.
killQuotes
(
token
,
"\""
);
//保存token
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_user u "
,
" u.user_id = '"
+
user_id
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
act_phone
=
rs_bankcard
.
getString
(
"phone"
);
if
(
phone
.
length
()<
12
){
if
(!(
dataPhone
.
equals
(
act_phone
)
&&
(
dataPhone
.
equals
(
phone
)))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info phone is not in DB;"
;
}
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
try
{
deleteFromDB
(
"t_user"
,
"phone"
,
phoneNeb
);
...
...
tiku_App/src/com/offcn/api/tk/app3/recordPushToken.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* .记录push token
*
* @author puhui
*
*/
public
class
recordPushToken
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
device_id
;
//用户设备id
public
String
pushtoken
;
//pushtoken
public
String
platform
;
//设备平台Iphone、Android
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
pushtoken
=
MapUtil
.
getParameter
(
parameter
,
"pushtoken"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
pushtoken
.
equals
(
""
))
&&
pushtoken
.
equals
(
"random"
))
{
pushtoken
=
"1391"
+(
new
Random
().
nextInt
(
9000000
)+
1000000
);
parameter
=
parameter
.
replace
(
"\"pushtoken\":random"
,
"\"pushtoken\":\""
+
pushtoken
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
StringUtils
.
decodeUnicode
(
getMsg
(
re
));
String
code
=
getCode
(
re
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
//是否验证数据库
if
(!
isProduct
)
{
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/register.java
0 → 100644
View file @
6f3c727f
This diff is collapsed.
Click to expand it.
tiku_App/src/com/offcn/api/tk/app3/resetpasswd.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 重置密码
*
* @author puhui
*
*/
public
class
resetpasswd
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
system
;
//手机系统
public
String
platform
;
//手机平台
public
String
version
;
//版本号
public
String
device_id
;
//设备id
public
String
passwd
;
//密码
public
String
passcode
;
//密码明文
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phoneNeb
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
Response
re
=
RequestDataUtils
.
Post_token
(
data
,
Url
,
tk_token
);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
re
.
asString
();
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
// System.out.println(jp.getString("message"));
// String msg=StringUtils.decodeUnicode(getMsg(re));
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
jp
.
getString
(
"data"
)!=
null
){
String
custom
=
data
.
get
(
"custom"
).
toString
();
String
[]
ArrayString
=
StringUtils
.
getArrayString
(
custom
,
","
);
if
(!
StringUtils
.
VerificationString
(
jp
.
getString
(
"data"
),
ArrayString
)){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"data"
)
+
"."
;
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
phoneNeb
=
phone
;
//是否验证数据库
if
(!
isProduct
)
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
" t_user u "
,
" u.phone = '"
+
phoneNeb
+
"' "
);
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
String
act_phone
=
rs_bankcard
.
getString
(
"phone"
).
equals
(
"null "
)?
"null"
:
rs_bankcard
.
getString
(
"phone"
);
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
if
(
phone
.
length
()<
60
){
if
(!(
phone
.
equals
(
act_phone
))){
result
=
result
&&
false
;
failReason
=
failReason
+
"t_user info phone is not in DB;"
;
}
}
}
}
catch
(
Exception
e
)
{
result
=
result
&&
false
;
failReason
=
failReason
+
"cannot verify t_user info in DB;"
;
e
.
printStackTrace
();
}
}
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/thirdLogin.java
0 → 100644
View file @
6f3c727f
This diff is collapsed.
Click to expand it.
tiku_App/src/com/offcn/api/tk/app3/uploadUserAvator.java
0 → 100644
View file @
6f3c727f
package
com
.
offcn
.
api
.
tk
.
app3
;
import
io.restassured.path.json.JsonPath
;
import
io.restassured.response.Response
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
org.json.simple.JSONArray
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.MySqlUtil
;
import
com.offcn.TestUnti.RequestDataUtils
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.VerificationMethod
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.TestUnti.ListUtil
;
import
net.sf.json.JSONObject
;
/**
* 41:App用户上传头像接口
*
* @author puhui
*
*/
public
class
uploadUserAvator
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
user_id
;
//用户id
public
String
image
;
//考试项目id
@Override
public
void
initialize
(
HashMap
<
String
,
Object
>
data
)
{
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
cleanUser_FromDB
();
//清除注册用户根据user_id
}
}
@Override
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
user_id
=
MapUtil
.
getParameter
(
parameter
,
"user_id"
).
trim
();
image
=
MapUtil
.
getParameter
(
parameter
,
"image"
).
trim
();
if
((!
user_id
.
equals
(
""
))
&&
user_id
.
equals
(
"code"
))
{
user_id
=
ListUtil
.
getListValue
(
user_idList
,
0
);
parameter
=
parameter
.
replace
(
"\"user_id\":code"
,
"\"user_id\":\""
+
user_id
+
"\""
);
}
if
((!
image
.
equals
(
""
))
&&
image
.
equals
(
"code"
))
{
image
=
"88"
;
parameter
=
parameter
.
replace
(
"\"image\":code"
,
"\"image\":\""
+
image
+
"\""
);
}
data
.
put
(
"parameter"
,
parameter
);
return
data
;
}
@Override
public
Response
SendRequest
(
HashMap
<
String
,
Object
>
data
,
String
Url
,
String
Request
)
{
// Response re = RequestDataUtils.Post_token(data, Url, tk_token);
Map
<
String
,
String
>
m
=
new
HashMap
<
String
,
String
>();
m
.
put
(
"user_id"
,
user_id
);
m
.
put
(
"image"
,
user_id
);
m
.
put
(
"appid"
,
"tiku"
);
m
.
put
(
"sign"
,
TK
.
GetSignValue
(
parameter
));
Response
re
=
RequestDataUtils
.
Post_file2
(
data
,
Url
,
tk_token
,
"image"
,
"1.png"
,
m
);
// Response re = RequestDataUtils.post_form_data(data,tk_token, Url,m);
return
re
;
}
@Override
public
String
handleOutput
(
Response
re
,
HashMap
<
String
,
Object
>
data
)
{
JsonPath
jp
=
re
.
body
().
jsonPath
();
boolean
result
=
true
;
String
failReason
=
""
;
String
json
=
StringUtils
.
decodeUnicode
(
re
.
asString
());
if
((
data
.
get
(
"statusCode"
)
!=
null
)
&&
(!
data
.
get
(
"statusCode"
).
toString
()
.
equals
(
String
.
valueOf
(
re
.
getStatusCode
()))))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"statusCode is expected "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
code
=
jp
.
getString
(
"retcode"
);
if
((
data
.
get
(
"code"
)
!=
null
)
&&
(
code
!=
null
)
&&
(!
code
.
equals
(
data
.
get
(
"code"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
+
data
.
get
(
"msg"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"msg"
)
+
"."
;
}
if
(
data
.
get
(
"custom"
)
!=
null
&&
json
!=
null
){
//如果自定义结果包含多个希望结果,也就是有逗号,那么就切割,包含比较。
if
(
data
.
get
(
"custom"
).
toString
().
contains
(
","
)){
String
[]
strCustomStrings
=
data
.
get
(
"custom"
).
toString
().
split
(
","
);
for
(
int
i
=
0
;
i
<
strCustomStrings
.
length
;
i
++){
if
(!
json
.
contains
(
strCustomStrings
[
i
])){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
strCustomStrings
[
i
]
+
"."
;
break
;
}
}
}
else
{
//如果只有一个希望结果,就直接包含比较。
if
(!
json
.
contains
(
data
.
get
(
"custom"
).
toString
())){
result
=
result
&&
false
;
failReason
=
failReason
+
"custom is expected "
+
data
.
get
(
"custom"
).
toString
()
+
" but actually "
+
data
.
get
(
"custom"
).
toString
()
+
"."
;
}
}
}
if
(
"接口响应成功!"
.
equals
(
msg
)){
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/visitor.java
View file @
6f3c727f
...
...
@@ -31,7 +31,7 @@ import net.sf.json.JSONObject;
/**
*
77.
*
游客模式登录
*
* @author puhui
*
...
...
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