forked from kakao-tech-campus-2nd-step3/Team9_BE
-
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.
feat:[kakao-tech-campus-2nd-step3#24]- add jwtTestUtils
토큰 테스트를 위한 별도의 유틸 클래스 생성
- Loading branch information
1 parent
e3d7758
commit 2183a14
Showing
1 changed file
with
23 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.helpmeCookies.e2e; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
|
||
import com.helpmeCookies.global.jwt.JwtProvider; | ||
import com.helpmeCookies.global.jwt.JwtToken; | ||
import com.helpmeCookies.global.jwt.JwtUser; | ||
|
||
|
||
public class JwtTestUtils { | ||
|
||
public static JwtToken generateValidToken(JwtProvider jwtProvider, Long userId, String username, String role) { | ||
JwtUser jwtUser = JwtUser.builder() | ||
.id(userId) | ||
.username(username) | ||
.authorities(List.of(new SimpleGrantedAuthority("ROLE_" + role))) | ||
.build(); | ||
|
||
return jwtProvider.createToken(jwtUser); | ||
} | ||
} |