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
2e6f7f8d
Commit
2e6f7f8d
authored
Oct 25, 2019
by
Thinkpad
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
10.25
parent
1fc27db3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
905 additions
and
46 deletions
+905
-46
CaseMakeMr.xls
tiku_App/TestData/CaseMakeMr.xls
+0
-0
DataAllMr.xls
tiku_App/TestData/DataAllMr.xls
+0
-0
checkCode.java
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
+31
-31
checkUserPhoneIfExist.java
..._App/src/com/offcn/api/tk/app3/checkUserPhoneIfExist.java
+166
-0
department.java
tiku_App/src/com/offcn/api/tk/app3/department.java
+168
-0
getCode.java
tiku_App/src/com/offcn/api/tk/app3/getCode.java
+13
-14
office.java
tiku_App/src/com/offcn/api/tk/app3/office.java
+162
-0
phoneRegister.java
tiku_App/src/com/offcn/api/tk/app3/phoneRegister.java
+184
-0
position.java
tiku_App/src/com/offcn/api/tk/app3/position.java
+168
-0
TK.java
tiku_App/src/com/offcn/process/TK.java
+13
-1
No files found.
tiku_App/TestData/CaseMakeMr.xls
View file @
2e6f7f8d
No preview for this file type
tiku_App/TestData/DataAllMr.xls
View file @
2e6f7f8d
No preview for this file type
tiku_App/src/com/offcn/api/tk/app3/checkCode.java
View file @
2e6f7f8d
...
@@ -53,7 +53,7 @@ public class checkCode extends TK implements API {
...
@@ -53,7 +53,7 @@ public class checkCode extends TK implements API {
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
public
HashMap
<
String
,
Object
>
handleInput
(
HashMap
<
String
,
Object
>
data
)
{
// 获取parameter对应的内容
// 获取parameter对应的内容
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
phone
=
MapUtil
.
getParameter
(
parameter
,
"phone"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
code
=
MapUtil
.
getParameter
(
parameter
,
"code"
).
trim
();
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
if
((!
phone
.
equals
(
""
))
&&
phone
.
equals
(
"code"
))
{
...
@@ -61,7 +61,7 @@ public class checkCode extends TK implements API {
...
@@ -61,7 +61,7 @@ public class checkCode extends TK implements API {
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
parameter
=
parameter
.
replace
(
"\"phone\":code"
,
"\"phone\":\""
+
phone
+
"\""
);
}
}
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
if
((!
code
.
equals
(
""
))
&&
code
.
equals
(
"code"
))
{
code
=
phone_code
;
code
=
phone_code
;
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
parameter
=
parameter
.
replace
(
"\"code\":code"
,
"\"code\":\""
+
code
+
"\""
);
}
}
...
@@ -157,35 +157,35 @@ public class checkCode extends TK implements API {
...
@@ -157,35 +157,35 @@ public class checkCode extends TK implements API {
System
.
out
.
println
(
phone_code
);
System
.
out
.
println
(
phone_code
);
//是否验证数据库
//是否验证数据库
if
(!
isProduct
)
{
//
if (!isProduct) {
//
try
{
//
try {
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
//
ResultSet rs_bankcard = this.selectFromDB(
" t_code c "
,
//
" t_code c ",
" c.phone = '"
+
phone
+
"' "
);
//
" c.phone = '" + phone + "' ");
rs_bankcard
.
last
();
//
rs_bankcard.last();
//
if
(
rs_bankcard
.
getRow
()>=
1
){
//
if(rs_bankcard.getRow()>=1){
// code = MapUtil.killQuotes(code, "\"");
//
//
code = MapUtil.killQuotes(code, "\"");
// phone_code=code;
//
//
phone_code=code;
//
// parameter = MapUtil.getValue("parameter", data);
//
//
parameter = MapUtil.getValue("parameter", data);
//
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
//
String act_code=rs_bankcard.getString("code");
//
if
(!
act_code
.
equals
(
phone_code
)){
//
if(!act_code.equals(phone_code)){
result
=
result
&&
false
;
//
result = result && false;
failReason
=
failReason
+
"t_code info code is not in DB;"
;
//
failReason = failReason + "t_code info code is not in DB;";
}
//
}
//
}
//
}
//
}
catch
(
Exception
e
)
{
//
} catch (Exception e) {
result
=
result
&&
false
;
//
result = result && false;
failReason
=
failReason
+
"cannot verify t_code info in DB;"
;
//
failReason = failReason + "cannot verify t_code info in DB;";
e
.
printStackTrace
();
//
e.printStackTrace();
}
//
}
}
//
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
}
}
...
...
tiku_App/src/com/offcn/api/tk/app3/checkUserPhoneIfExist.java
0 → 100644
View file @
2e6f7f8d
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
;
/**
* 73.检测手机号是否已注册
*
* @author mr
*
*/
public
class
checkUserPhoneIfExist
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
(
"appid"
,
"tiku"
);
if
(
parameter
.
contains
(
"phone"
)){
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
}
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
(
"0"
.
equals
(
code
)){
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/department.java
0 → 100644
View file @
2e6f7f8d
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
;
/**
* 79.获取用人司局
*
* @author mr
*
*/
public
class
department
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
office_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
);
office_id
=
MapUtil
.
getParameter
(
parameter
,
"office_id"
).
trim
();
if
((!
office_id
.
equals
(
""
))
&&
office_id
.
equals
(
"code"
))
{
office_id
=
L_office_id
;
parameter
=
parameter
.
replace
(
"\"office_id\":code"
,
"\"office_id\":\""
+
office_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
,
"\""
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
// office_id = MapUtil.killQuotes(office_id, "\"");
jsonAsMap
.
put
(
"office_id"
,
office_id
);
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
(
"0"
.
equals
(
code
)){
// List<String> list=jp.getList("data.departments.list");
// if (list!=null && list.size()>0 && list.get(0)!=null) {
// L_office_id=jp.getString("data.offices.list[0].id[0]");
// System.out.println(L_office_id);
// }
L_department_id
=
jp
.
getString
(
"data.departments.list.id"
);
System
.
out
.
println
(
L_department_id
);
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/getCode.java
View file @
2e6f7f8d
...
@@ -153,23 +153,22 @@ public class getCode extends TK implements API {
...
@@ -153,23 +153,22 @@ public class getCode extends TK implements API {
if
(!
isProduct
)
{
if
(!
isProduct
)
{
try
{
try
{
ResultSet
rs_bankcard
=
this
.
selectFromDB
(
String
sql
=
"SELECT t.`code` from t_code t WHERE phone = "
+
phone
+
" ORDER BY t.id DESC LIMIT 1"
;
" t_code c "
,
ResultSet
rs_bankcard
=
this
.
sqlFromDB
(
sql
);
" c.phone = '"
+
phone
+
"' "
);
// ResultSet rs_bankcard = this.selectFromDB(
// " t_code c ",
// " id = (SELECT MAX(id) FROM t_code WHERE c.phone = '" + phone + "') ");
rs_bankcard
.
last
();
rs_bankcard
.
last
();
if
(
rs_bankcard
.
getRow
()>=
1
){
if
(
rs_bankcard
.
getRow
()>=
1
){
// code = MapUtil.killQuotes(code, "\"");
// phone_code=code;
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
// parameter = MapUtil.getValue("parameter", data);
phone_code
=
act_code
;
String
act_code
=
rs_bankcard
.
getString
(
"code"
);
if
(!
act_code
.
equals
(
phone_code
)){
//
if(!act_code.equals(phone_code)){
result
=
result
&&
false
;
//
result = result && false;
failReason
=
failReason
+
"t_code info code is not in DB;"
;
//
failReason = failReason + "t_code info code is not in DB;";
}
//
}
}
}
...
...
tiku_App/src/com/offcn/api/tk/app3/office.java
0 → 100644
View file @
2e6f7f8d
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
;
/**
* 78. 获取招录机关(v1 . 78)
*
* @author mr
*
*/
public
class
office
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
exam_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
);
exam_id
=
MapUtil
.
getParameter
(
parameter
,
"exam_id"
).
trim
();
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
);
exam_id
=
MapUtil
.
killQuotes
(
exam_id
,
"\""
);
jsonAsMap
.
put
(
"exam_id"
,
exam_id
);
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
)){
List
<
String
>
list
=
jp
.
getList
(
"data.offices.list"
);
if
(
list
!=
null
&&
list
.
size
()>
0
&&
list
.
get
(
0
)!=
null
)
{
L_office_id
=
jp
.
getString
(
"data.offices.list[0].id[0]"
);
System
.
out
.
println
(
L_office_id
);
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/phoneRegister.java
0 → 100644
View file @
2e6f7f8d
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
;
/**
* 57. 手机号(无密码)注册(中公杯使用)
*
* @author mr
*
*/
public
class
phoneRegister
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
phone
;
//手机号
public
String
user_from
;
//用户来源
public
String
appid
;
//使用平台
@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
();
user_from
=
MapUtil
.
getParameter
(
parameter
,
"user_from"
).
trim
();
appid
=
MapUtil
.
getParameter
(
parameter
,
"appid"
).
trim
();
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
);
phone
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
jsonAsMap
.
put
(
"phone"
,
phone
);
if
(
parameter
.
contains
(
"user_from"
)){
user_from
=
MapUtil
.
killQuotes
(
user_from
,
"\""
);
jsonAsMap
.
put
(
"user_from"
,
user_from
);
}
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.setParameter(parameter);
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
=
MapUtil
.
killQuotes
(
phone
,
"\""
);
phoneNeb
=
phone
;
if
(!
isProduct
&&
data
.
get
(
"CleanDB"
).
toString
().
contains
(
"Y"
))
{
try
{
deleteFromDB
(
"t_user"
,
"phone"
,
phoneNeb
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/api/tk/app3/position.java
0 → 100644
View file @
2e6f7f8d
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
;
/**
* 79.获取用人司局
*
* @author mr
*
*/
public
class
position
extends
TK
implements
API
{
public
String
parameter
;
//参数集合
public
String
office_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
);
office_id
=
MapUtil
.
getParameter
(
parameter
,
"office_id"
).
trim
();
if
((!
office_id
.
equals
(
""
))
&&
office_id
.
equals
(
"code"
))
{
office_id
=
L_office_id
;
parameter
=
parameter
.
replace
(
"\"office_id\":code"
,
"\"office_id\":\""
+
office_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
,
"\""
);
jsonAsMap
.
put
(
"appid"
,
tikuString
);
// office_id = MapUtil.killQuotes(office_id, "\"");
jsonAsMap
.
put
(
"office_id"
,
office_id
);
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
(
"0"
.
equals
(
code
)){
// List<String> list=jp.getList("data.departments.list");
// if (list!=null && list.size()>0 && list.get(0)!=null) {
// L_office_id=jp.getString("data.offices.list[0].id[0]");
// System.out.println(L_office_id);
// }
L_department_id
=
jp
.
getString
(
"data.departments.list.id"
);
System
.
out
.
println
(
L_department_id
);
conn
=
ConnectionsMap
.
get
(
"tk"
);
}
}
if
(
result
)
return
"Pass"
;
else
return
"Fail:"
+
failReason
;
}
}
tiku_App/src/com/offcn/process/TK.java
View file @
2e6f7f8d
...
@@ -72,6 +72,9 @@ public class TK extends BasicsGM{
...
@@ -72,6 +72,9 @@ public class TK extends BasicsGM{
// tiku3接口数据
// tiku3接口数据
public
static
String
L_shelf_id
=
""
;
//书架id
public
static
String
L_shelf_id
=
""
;
//书架id
public
static
String
nwn_record_id
=
""
;
//nwn使用的 试卷使用记录id
public
static
String
nwn_record_id
=
""
;
//nwn使用的 试卷使用记录id
public
static
String
L_office_id
=
""
;
//招录机关id
public
static
String
L_department_id
=
""
;
//用人司局id
...
@@ -179,7 +182,16 @@ public class TK extends BasicsGM{
...
@@ -179,7 +182,16 @@ public class TK extends BasicsGM{
Arrays
.
sort
(
arr
);
Arrays
.
sort
(
arr
);
parameter
=
Arrays
.
toString
(
arr
);
parameter
=
Arrays
.
toString
(
arr
);
parameter
=
parameter
.
toString
().
replace
(
", "
,
"&"
);
parameter
=
parameter
.
toString
().
replace
(
", "
,
"&"
);
parameter
=(
parameter
.
substring
(
1
,
parameter
.
length
()-
1
))+
"&123456"
;
if
(
parameter
.
contains
(
"cup"
)){
parameter
=(
parameter
.
substring
(
1
,
parameter
.
length
()-
1
))+
"&838296179"
;
}
else
{
parameter
=(
parameter
.
substring
(
1
,
parameter
.
length
()-
1
))+
"&123456"
;
}
return
MD5keyUtil
.
getMD5Str
(
parameter
);
return
MD5keyUtil
.
getMD5Str
(
parameter
);
}
}
...
...
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