Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
cadd900e
Commit
cadd900e
authored
Aug 27, 2021
by
giaogiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login单元测试
parent
a974a9de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
42 deletions
+45
-42
bootstrap/src/test/java/io/geekidea/springbootplus/test/LoginTest.java
+45
-42
No files found.
bootstrap/src/test/java/io/geekidea/springbootplus/test/LoginTest.java
View file @
cadd900e
...
@@ -59,45 +59,48 @@ public class LoginTest {
...
@@ -59,45 +59,48 @@ public class LoginTest {
if
(
mySign
.
equals
(
sign
))
{
if
(
mySign
.
equals
(
sign
))
{
System
.
out
.
println
(
"一致"
+
mySign
);
System
.
out
.
println
(
"一致"
+
mySign
);
// return null;
// return null;
//
}
else
{
// }
System
.
out
.
println
(
"不一致"
+
mySign
);
//
return
null
;
// // 判断client是否存在
// ImClient client = imClientService.getOne(new QueryWrapper<ImClient>().lambda()
}
// .eq(ImClient::getFkAppid, imApplication.getId())
// .eq(ImClient::getClientId, clientId));
// 判断client是否存在
//
ImClient
client
=
imClientService
.
getOne
(
new
QueryWrapper
<
ImClient
>().
lambda
()
// if (client == null) {
.
eq
(
ImClient:
:
getFkAppid
,
imApplication
.
getId
())
// System.out.println("不存在");
.
eq
(
ImClient:
:
getClientId
,
clientId
));
//
// ImClient imClient = new ImClient();
if
(
client
==
null
)
{
// imClient.setId(new Snowflake(1L, 1L).nextId());
System
.
out
.
println
(
"不存在"
);
// imClient.setFkAppid(imApplication.getId());
// imClient.setClientId(clientId);
ImClient
imClient
=
new
ImClient
();
// imClientService.save(imClient);
imClient
.
setId
(
new
Snowflake
(
1L
,
1L
).
nextId
());
//
imClient
.
setFkAppid
(
imApplication
.
getId
());
// } else {
imClient
.
setClientId
(
clientId
);
// System.out.println("存在");
imClientService
.
save
(
imClient
);
// }
//
}
else
{
// // 生成token
System
.
out
.
println
(
"存在"
);
// String generateToken = JwtUtil.generateToken(clientId, appKey, imApplication.getAppSecret(), Duration.ofDays(99999));
}
//
// // 保存redis
// 生成token
// redisTemplate.opsForValue().set("client:" + imApplication.getAppKey() + ":" + clientId, generateToken);
String
generateToken
=
JwtUtil
.
generateToken
(
clientId
,
appKey
,
imApplication
.
getAppSecret
(),
Duration
.
ofDays
(
99999
));
// return generateToken;
// }
// 保存redis
//
redisTemplate
.
opsForValue
().
set
(
"client:"
+
imApplication
.
getAppKey
()
+
":"
+
clientId
,
generateToken
);
// @Test
return
generateToken
;
// public void test() throws Exception {
}
// // 时间戳
// String timestamp = "1629274899016";
@Test
// String clientId = "aaaaa2";
public
void
test
()
throws
Exception
{
// String sign = "a404fe25d383eb154b3b527f7213b35a";
// 时间戳
//
String
timestamp
=
"1629274899016"
;
//
String
clientId
=
"aaaaa2"
;
// String appKey = "QNtP3EjtLw26ekt0";
String
sign
=
"a404fe25d383eb154b3b527f7213b35a"
;
// String token = getToken(timestamp, clientId, appKey, sign);
// System.out.println("token:\n" + token);
// }
String
appKey
=
"QNtP3EjtLw26ekt0"
;
//}
String
token
=
getToken
(
timestamp
,
clientId
,
appKey
,
sign
);
System
.
out
.
println
(
"token:\n"
+
token
);
}
}
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