-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: user cache. fix: use jwt expire.
- Loading branch information
Showing
3 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package fun.sast.evento.lark; | ||
|
||
import fun.sast.evento.lark.api.security.Permission; | ||
import fun.sast.evento.lark.domain.event.entity.User; | ||
import fun.sast.evento.lark.infrastructure.auth.JWTService; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.cache.CacheManager; | ||
|
||
@SpringBootTest | ||
public class UserTest { | ||
|
||
@Autowired | ||
JWTService jwtService; | ||
@Autowired | ||
CacheManager cacheManager; | ||
|
||
@Test | ||
void generateUser(){ | ||
User user = new User(); | ||
user.setUserId("B00000000"); | ||
user.setPermission(Permission.LOGIN.getNum()); | ||
|
||
String token = jwtService.generate(new JWTService.Payload<>(user)); | ||
System.out.println(token); | ||
|
||
cacheManager.getCache("user").put("B00000000", token); | ||
} | ||
|
||
@Test | ||
void generateAdmin(){ | ||
User user = new User(); | ||
user.setUserId("B00000001"); | ||
user.setPermission(Permission.ADMIN.getNum()); | ||
|
||
String token = jwtService.generate(new JWTService.Payload<>(user)); | ||
System.out.println(token); | ||
|
||
cacheManager.getCache("user").put("B00000001", token); | ||
} | ||
} |