-
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.
refresh token을 검증하는 validateToken 메서드를 추가하라
올바른 토큰인지 아닌지 검증하는 validateToken 메서드를 추가했습니다
- Loading branch information
Showing
2 changed files
with
6 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 |
---|---|---|
|
@@ -12,6 +12,7 @@ describe('TokenIssuer class', () => { | |
let connect: Connection | ||
let tokenIssuer: TokenIssuer | ||
let memberRepository: MemberRepository | ||
let jwtProvider: JwtProvider | ||
|
||
const REFRESH_TOKEN = | ||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjoxLCJpYXQiOjE2OTQ1MjI0NzUsImV4cCI6MTY5NTczMjA3NSwic3ViIjoiUkVGUkVTSCJ9.A2PfZdj91q6MIapXrvTB6bUd7blhqrrDY2yh0eYdGPY' | ||
|
@@ -33,12 +34,14 @@ describe('TokenIssuer class', () => { | |
|
||
tokenIssuer = module.get<TokenIssuer>(TokenIssuer) | ||
memberRepository = module.get<MemberRepository>(MemberRepository) | ||
jwtProvider = module.get<JwtProvider>(JwtProvider) | ||
}) | ||
|
||
describe('createAccessTokenByRefreshToken method', () => { | ||
context('refreshToken이 주어지면', () => { | ||
beforeEach(() => { | ||
memberRepository.findMemberByRefreshToken = jest.fn().mockResolvedValue(MEMBER) | ||
jwtProvider.validateToken = jest.fn().mockResolvedValue('[email protected]') | ||
}) | ||
it('accessToken과 accessTokenExpireTime을 갱신해야 한다', async () => { | ||
const member = await tokenIssuer.createAccessTokenByRefreshToken(REFRESH_TOKEN, NOW) | ||
|
@@ -54,6 +57,7 @@ describe('TokenIssuer class', () => { | |
context('refreshToken이 찾을 수 없거나 올바르지 않으면', () => { | ||
beforeEach(() => { | ||
memberRepository.findMemberByRefreshToken = jest.fn().mockResolvedValue(undefined) | ||
jwtProvider.validateToken = jest.fn().mockResolvedValue('[email protected]') | ||
}) | ||
it('MemberNotFoundException를 던져야 한다', async () => { | ||
expect(tokenIssuer.createAccessTokenByRefreshToken(REFRESH_TOKEN, NOW)).rejects.toThrow( | ||
|
@@ -65,6 +69,7 @@ describe('TokenIssuer class', () => { | |
context('refreshToken의 유효기간이 만료 되면', () => { | ||
beforeEach(() => { | ||
memberRepository.findMemberByRefreshToken = jest.fn().mockResolvedValue(MEMBER) | ||
jwtProvider.validateToken = jest.fn().mockResolvedValue('[email protected]') | ||
}) | ||
it('TokenExpiredException를 던져야 한다', async () => { | ||
expect(tokenIssuer.createAccessTokenByRefreshToken(REFRESH_TOKEN, EXPIRED_TIME)).rejects.toThrow( | ||
|
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