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
2250347a
Commit
2250347a
authored
Jan 09, 2025
by
以墨为白
🎧
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
148b3928
e0869171
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
src/test/java/com/zksy/szpt/MainTestX.java
src/test/java/com/zksy/szpt/MainTestX.java
+87
-0
No files found.
src/test/java/com/zksy/szpt/MainTestX.java
0 → 100644
View file @
2250347a
package
com
.
zksy
.
szpt
;
import
cn.hutool.crypto.digest.DigestUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.zksy.szpt.domain.dto.SzptClockInDTO
;
import
com.zksy.szpt.service.AppStoreService
;
import
com.zksy.szpt.util.EncryptUtil
;
import
com.zksy.szpt.util.SignatureUtil
;
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
reactor.core.publisher.Mono
;
import
javax.annotation.Resource
;
@SpringBootTest
()
public
class
MainTestX
{
String
nonce
=
"2"
;
String
timestampStr
=
"21"
;
String
appId
=
"1872576325743943682"
;
@Resource
private
ObjectMapper
objectMapper
;
@Resource
private
AppStoreService
appStoreService
;
/**
* 任务完成情况
*/
@Test
@DisplayName
(
"考勤"
)
public
void
szptClockInTest
()
{
timestampStr
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
nonce
=
String
.
valueOf
(
System
.
currentTimeMillis
()
/
1000
);
String
secretKey
=
this
.
appStoreService
.
getAppSecretByAppKey
(
appId
);
Assertions
.
assertNotNull
(
secretKey
,
"appId不存在"
);
//断言appId存在,为空直接抛出异常不进行下一步测试,提高测试效率
//请求参数
SzptClockInDTO
szptClockInDTO
=
new
SzptClockInDTO
();
szptClockInDTO
.
setId
(
100
);
szptClockInDTO
.
setCsid
(
"123456"
);
szptClockInDTO
.
setSbqd
(
"123456"
);
szptClockInDTO
.
setXbqt
(
"123456"
);
szptClockInDTO
.
setXcqk
(
"1"
);
szptClockInDTO
.
setSbsj
(
"1"
);
szptClockInDTO
.
setSbr
(
"123456"
);
szptClockInDTO
.
setQdr
(
"123456"
);
szptClockInDTO
.
setQdrlxdh
(
"123456"
);
szptClockInDTO
.
setQddkdd
(
"1"
);
szptClockInDTO
.
setQddkzp
(
"1"
);
szptClockInDTO
.
setQtdkdd
(
"1"
);
szptClockInDTO
.
setQtdkzp
(
"1"
);
szptClockInDTO
.
setGkdj
(
"1"
);
String
json
=
null
;
try
{
json
=
objectMapper
.
writeValueAsString
(
szptClockInDTO
);
}
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/index/addSzptClockIn"
)
.
header
(
SignatureUtil
.
APPID
,
appId
)
.
header
(
SignatureUtil
.
NONCE
,
nonce
)
.
header
(
SignatureUtil
.
TIMESTAMP
,
timestampStr
)
.
header
(
SignatureUtil
.
SIGNATURE
,
generatedSignature
)
.
body
(
Mono
.
just
(
szptClockInDTO
),
SzptClockInDTO
.
class
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
block
();
System
.
out
.
println
(
response
);
}
}
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