Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
6bb21e5e
Commit
6bb21e5e
authored
Nov 15, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式并加些打印
parent
1f5b6502
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
DeviceControllerTest.java
.../iot/sixiang/license/controller/DeviceControllerTest.java
+7
-10
No files found.
license/src/test/java/iot/sixiang/license/controller/DeviceControllerTest.java
View file @
6bb21e5e
...
...
@@ -6,7 +6,6 @@ import iot.sixiang.license.util.HmacUtil;
import
iot.sixiang.license.util.sm4.SM4
;
import
iot.sixiang.license.util.sm4.SM4Context
;
import
lombok.SneakyThrows
;
import
org.junit.Assert
;
import
org.junit.jupiter.api.Test
;
import
java.io.ByteArrayInputStream
;
...
...
@@ -54,14 +53,14 @@ public class DeviceControllerTest {
InputStream
inputStream
=
socket
.
getInputStream
();
// 鉴权
sendAndReceive
(
socket
,
outputStream
,
inputStream
,
"auth"
,
authSendBytes
,
true
);
sendAndReceive
(
socket
,
outputStream
,
inputStream
,
"auth"
,
authSendBytes
);
Thread
.
sleep
(
1
00
);
Thread
.
sleep
(
5
00
);
// 鉴权后做动作
String
request
=
"55AA340090000156F43D4D806827D1BB8F78C00D2B5488479CEB172C5D477C4D3023CE7B111621D4AD2C11ACAC4D876A3AC66A82F5F19000EF"
;
byte
[]
actionSendBytes
=
hex2Byte
(
request
);
byte
[]
actionResultBytes
=
sendAndReceive
(
socket
,
outputStream
,
inputStream
,
"action"
,
actionSendBytes
,
false
);
byte
[]
actionResultBytes
=
sendAndReceive
(
socket
,
outputStream
,
inputStream
,
"action"
,
actionSendBytes
);
//String result = "55AA1500A40035414E7DB5B3EDE72BC6BA44203F52EA0000005B";
//String result = "55aa1500a4008926834e684c4c6911b02304b3a0ce9c00000000";
//Assert.assertEquals(bytes2Hex(actionResultBytes), result);
...
...
@@ -72,17 +71,15 @@ public class DeviceControllerTest {
}
@SneakyThrows
private
byte
[]
sendAndReceive
(
Socket
socket
,
OutputStream
outputStream
,
InputStream
inputStream
,
String
tag
,
byte
[]
requestBytes
,
boolean
isAuth
)
{
private
byte
[]
sendAndReceive
(
Socket
socket
,
OutputStream
outputStream
,
InputStream
inputStream
,
String
tag
,
byte
[]
requestBytes
)
{
System
.
out
.
println
(
tag
+
" send:"
+
bytes2Hex
(
requestBytes
));
outputStream
.
write
(
requestBytes
);
outputStream
.
flush
();
byte
[]
bytes
=
new
byte
[
1024
];
int
count
=
inputStream
.
read
(
bytes
);
if
(!
isAuth
)
{
Thread
.
sleep
(
500
);
while
(
count
<
0
)
{
count
=
inputStream
.
read
(
bytes
);
}
while
(
count
<
0
)
{
Thread
.
sleep
(
200
);
count
=
inputStream
.
read
(
bytes
);
}
byte
[]
resultBytes
=
new
byte
[
count
];
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
...
...
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