Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
szpt
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
以墨为白
szpt
Commits
167f70dd
Commit
167f70dd
authored
Jan 10, 2025
by
wangjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug
parent
549330dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
274 deletions
+34
-274
src/test/java/com/zksy/szpt/MainTest.java
src/test/java/com/zksy/szpt/MainTest.java
+32
-272
src/test/java/com/zksy/szpt/TestHttpUtil.java
src/test/java/com/zksy/szpt/TestHttpUtil.java
+2
-2
No files found.
src/test/java/com/zksy/szpt/MainTest.java
View file @
167f70dd
...
@@ -29,8 +29,6 @@ public class MainTest {
...
@@ -29,8 +29,6 @@ public class MainTest {
String
nonce
=
"2"
;
String
nonce
=
"2"
;
String
timestampStr
=
"21"
;
String
timestampStr
=
"21"
;
String
appId
=
"1872576325743943682"
;
String
appId
=
"1872576325743943682"
;
String
appSecret
=
"2"
;
@Resource
@Resource
private
ObjectMapper
objectMapper
;
private
ObjectMapper
objectMapper
;
...
@@ -41,47 +39,18 @@ public class MainTest {
...
@@ -41,47 +39,18 @@ public class MainTest {
/**
/**
* 任务完成情况
* 任务完成情况
*/
*/
//
@Test
@Test
@DisplayName
(
"任务完成情况"
)
@DisplayName
(
"任务完成情况"
)
public
void
xxRwwcqkTest
()
{
public
void
xxRwwcqkTest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
// String secretKey = this.appStoreService.getAppSecretByAppKey(appId);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
Assertions
.
assertNotNull
(
appId
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
//请求参数
XxRwwcqkDTO
xxRwwcqkDTO
=
new
XxRwwcqkDTO
();
XxRwwcqkDTO
xxRwwcqkDTO
=
new
XxRwwcqkDTO
();
xxRwwcqkDTO
.
setRwid
(
"1234"
);
xxRwwcqkDTO
.
setRwid
(
"1234
5678
"
);
xxRwwcqkDTO
.
setXxyid
(
"12345"
);
xxRwwcqkDTO
.
setXxyid
(
"12345
6785
"
);
xxRwwcqkDTO
.
setShrid
(
"12345"
);
xxRwwcqkDTO
.
setShrid
(
"12345
6785
"
);
xxRwwcqkDTO
.
setWczt
(
"1"
);
xxRwwcqkDTO
.
setWczt
(
"1"
);
xxRwwcqkDTO
.
setBmzt
(
"1"
);
xxRwwcqkDTO
.
setBmzt
(
"1"
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/index/addXxRwwcqk", xxRwwcqkDTO, XxRwwcqkDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/index/updateXxRwwcqk"
,
xxRwwcqkDTO
,
XxRwwcqkDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
xxRwwcqkDTO
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
appSecret
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/index/addXxRwwcqk"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
xxRwwcqkDTO
),
XxRwwcqkDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
/**
/**
...
@@ -90,43 +59,14 @@ public class MainTest {
...
@@ -90,43 +59,14 @@ public class MainTest {
@Test
@Test
@DisplayName
(
"账户信息"
)
@DisplayName
(
"账户信息"
)
public
void
zhxxtest
()
{
public
void
zhxxtest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
//请求参数
XxZhxxDTO
dto
=
new
XxZhxxDTO
();
XxZhxxDTO
dto
=
new
XxZhxxDTO
();
dto
.
setZhid
(
"1234"
);
dto
.
setZhid
(
"1234
5678
"
);
dto
.
setXxyid
(
"11"
);
dto
.
setXxyid
(
"11"
);
dto
.
setZt
(
"2"
);
dto
.
setZt
(
"2"
);
dto
.
setClbz
(
"2"
);
dto
.
setClbz
(
"2"
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxZhxx/add", dto, XxZhxxDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxZhxx/update"
,
dto
,
XxZhxxDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhxx/add"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxZhxxDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
/**
/**
...
@@ -135,43 +75,14 @@ public class MainTest {
...
@@ -135,43 +75,14 @@ public class MainTest {
@Test
@Test
@DisplayName
(
"账户积分变更"
)
@DisplayName
(
"账户积分变更"
)
public
void
test1
()
{
public
void
test1
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
//请求参数
XxZhjfbgDTO
dto
=
new
XxZhjfbgDTO
();
XxZhjfbgDTO
dto
=
new
XxZhjfbgDTO
();
// dto.setZhid("1234");
// dto.setZhid("1234
5678
");
dto
.
setDhid
(
"1234"
);
dto
.
setDhid
(
"1234
5678
"
);
dto
.
setQbid
(
"2"
);
dto
.
setQbid
(
"2"
);
dto
.
setBgsj
(
new
Date
());
dto
.
setBgsj
(
new
Date
());
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxZhjfbg/add", dto, XxZhjfbgDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxZhjfbg/update"
,
dto
,
XxZhjfbgDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxZhjfbg/add"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxZhjfbgDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
...
@@ -224,46 +135,17 @@ public class MainTest {
...
@@ -224,46 +135,17 @@ public class MainTest {
@Test
@Test
@DisplayName
(
"义警任务"
)
@DisplayName
(
"义警任务"
)
public
void
test4
()
{
public
void
test4
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
//请求参数
XxYjrwDTO
dto
=
new
XxYjrwDTO
();
XxYjrwDTO
dto
=
new
XxYjrwDTO
();
// dto.setZhid("1234");
// dto.setZhid("1234
5678
");
dto
.
setRwid
(
"123456"
);
dto
.
setRwid
(
"123456
7856
"
);
dto
.
setRwbt
(
"1"
);
dto
.
setRwbt
(
"1"
);
dto
.
setRwnr
(
"11111"
);
dto
.
setRwnr
(
"11111"
);
dto
.
setGzrs
(
1L
);
dto
.
setGzrs
(
1L
);
dto
.
setSfsh
(
1
);
dto
.
setSfsh
(
1
);
dto
.
setWcrs
(
1L
);
dto
.
setWcrs
(
1L
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxYjrw/add", dto, XxYjrwDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxYjrw/update"
,
dto
,
XxYjrwDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxYjrw/update"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxYjrwDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
/**
/**
...
@@ -272,179 +154,57 @@ public class MainTest {
...
@@ -272,179 +154,57 @@ public class MainTest {
@Test
@Test
@DisplayName
(
"义警队伍代码"
)
@DisplayName
(
"义警队伍代码"
)
public
void
test5
()
{
public
void
test5
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
// Assertions.fail(secretKey);
//请求参数
//请求参数
XxYjdwdmDTO
dto
=
new
XxYjdwdmDTO
();
XxYjdwdmDTO
dto
=
new
XxYjdwdmDTO
();
// dto.setZhid("1234");
// dto.setZhid("1234
5678
");
dto
.
setDwlx
(
Integer
.
valueOf
(
1
));
dto
.
setDwlx
(
Integer
.
valueOf
(
1
));
dto
.
setId
(
"1234"
);
dto
.
setId
(
"1234
5678
"
);
dto
.
setMchid
(
"11111"
);
dto
.
setMchid
(
"11111"
);
dto
.
setZt
(
"1"
);
dto
.
setZt
(
"1"
);
dto
.
setYjdwmc
(
"test"
);
dto
.
setYjdwmc
(
"test"
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxYjdwdm/add", dto, XxYjdwdmDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxYjdwdm/update"
,
dto
,
XxYjdwdmDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxYjdwdm/add"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxYjdwdmDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
@Test
@Test
@DisplayName
(
"社会信息员队伍"
)
@DisplayName
(
"社会信息员队伍"
)
public
void
test6
()
{
public
void
test6
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDwDTO
dto
=
new
XxShxxyDwDTO
();
XxShxxyDwDTO
dto
=
new
XxShxxyDwDTO
();
dto
.
setId
(
"1234"
);
dto
.
setId
(
"12345678"
);
dto
.
setDwdm
(
"1234"
);
dto
.
setDwdm
(
"12345678"
);
dto
.
setShxxyid
(
"1234"
);
dto
.
setShxxyid
(
"12345678"
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxShxxyDw/add", dto, XxShxxyDwDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxShxxyDw/update"
,
dto
,
XxShxxyDwDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxyDw/add"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxShxxyDw
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
@Test
@Test
@DisplayName
(
"社会信息员"
)
@DisplayName
(
"社会信息员"
)
public
void
test7
()
{
public
void
test7
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
XxShxxyDTO
dto
=
new
XxShxxyDTO
();
XxShxxyDTO
dto
=
new
XxShxxyDTO
();
dto
.
setXxyid
(
"1234"
);
dto
.
setXxyid
(
"1234
5678
"
);
dto
.
setZt
(
"1"
);
dto
.
setZt
(
"1"
);
dto
.
setSbfszt
(
"1"
);
dto
.
setSbfszt
(
"1"
);
dto
.
setShrid
(
"1"
);
dto
.
setShrid
(
"1"
);
String
json
=
null
;
// TestHttpUtil.signatureAndRequest("/rest/xxShxxy/add", dto, XxShxxyDTO.class);
try
{
TestHttpUtil
.
signatureAndRequest
(
"/rest/xxShxxy/update"
,
dto
,
XxShxxyDTO
.
class
);
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
json
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
String
response
=
webClient
.
post
().
uri
(
"/rest/xxShxxy/add"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
XxShxxyDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
@Test
@Test
@DisplayName
(
"删除服务"
)
@DisplayName
(
"删除服务"
)
public
void
testdelete
()
{
public
void
testdelete
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
UUID
.
randomUUID
().
toString
();
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
String
json
=
null
;
List
<
String
>
ids
=
new
ArrayList
<>();
List
<
String
>
ids
=
new
ArrayList
<>();
ids
.
add
(
"1234"
);
ids
.
add
(
"1234
5678
"
);
ids
.
add
(
"12345"
);
ids
.
add
(
"12345
6785
"
);
CommonDelParamDTO
dto
=
new
CommonDelParamDTO
();
CommonDelParamDTO
dto
=
new
CommonDelParamDTO
();
dto
.
setIds
(
ids
);
dto
.
setIds
(
ids
);
try
{
json
=
objectMapper
.
writeValueAsString
(
dto
);
}
catch
(
JsonProcessingException
e
)
{
Assertions
.
fail
(
"json序列化失败"
);
}
//请求体加密
String
json1
=
EncryptUtil
.
getInstance
().
AESEncode
(
json
,
secretKey
);
//签名appId+nonce+timestampStr+aes(body)
String
data
=
String
.
format
(
"%s%s%s%s"
,
appId
,
nonce
,
timestampStr
,
json1
);
String
generatedSignature
=
DigestUtil
.
md5Hex
(
data
);
//请求
WebClient
webClient
=
WebClient
.
builder
()
.
baseUrl
(
"http://localhost:8086"
)
.
defaultHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
// String url="xxShxxyDw/delete";
// String url="xxShxxyDw/delete";
// String url="xxShxxy/delete";
// String url="xxShxxy/delete";
// String url="xxYjdwdm/delete";
// String url="xxYjdwdm/delete";
// String url="xxYjrw/delete";
// String url="xxYjrw/delete";
//
// String url="xxZhjfbg/delete";
// String url="xxZhjfbg/delete";
//
String
url
=
"xxZhxx/delete"
;
String
url
=
"xxZhxx/delete"
;
TestHttpUtil
.
signatureAndRequest
(
"/rest/"
+
url
,
dto
,
CommonDelParamDTO
.
class
);
String
response
=
webClient
.
post
().
uri
(
"/rest/"
+
url
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
dto
),
CommonDelDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
}
}
src/test/java/com/zksy/szpt/TestHttpUtil.java
View file @
167f70dd
...
@@ -25,7 +25,7 @@ public class TestHttpUtil {
...
@@ -25,7 +25,7 @@ public class TestHttpUtil {
Assertions
.
assertNotNull
(
path
,
"path不能为空"
);
Assertions
.
assertNotNull
(
path
,
"path不能为空"
);
Assertions
.
assertNotNull
(
source
,
"请求参数不能为空"
);
Assertions
.
assertNotNull
(
source
,
"请求参数不能为空"
);
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
());
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
String
json
=
null
;
String
json
=
null
;
try
{
try
{
...
@@ -60,7 +60,7 @@ public class TestHttpUtil {
...
@@ -60,7 +60,7 @@ public class TestHttpUtil {
Assertions
.
assertNotNull
(
path
,
"path不能为空"
);
Assertions
.
assertNotNull
(
path
,
"path不能为空"
);
Assertions
.
assertNotNull
(
source
,
"请求参数不能为空"
);
Assertions
.
assertNotNull
(
source
,
"请求参数不能为空"
);
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
());
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
appSecret
=
DigestUtil
.
md5Hex
(
appSecret
);
String
json
=
null
;
String
json
=
null
;
try
{
try
{
...
...
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