Skip to content

Commit

Permalink
feat:[kakao-tech-campus-2nd-step3#24]- add jwtTestUtils
Browse files Browse the repository at this point in the history
토큰 테스트를 위한 별도의 유틸 클래스 생성
  • Loading branch information
yooonwodyd committed Oct 4, 2024
1 parent e3d7758 commit 2183a14
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/java/com/helpmeCookies/e2e/JwtTestUtils.java
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);
}
}

0 comments on commit 2183a14

Please sign in to comment.