Skip to content

Commit

Permalink
[PDS-81] feat: 로그인 실패 코드 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
chaerlo127 committed Nov 24, 2023
1 parent 319371d commit b42e4e9
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.example.pladialmserver.user.service;

import com.example.pladialmserver.global.exception.BaseException;
import com.example.pladialmserver.global.exception.BaseResponseCode;
import com.example.pladialmserver.global.utils.JwtUtil;
import com.example.pladialmserver.user.dto.TokenDto;
import com.example.pladialmserver.user.dto.request.EmailPWReq;
Expand All @@ -23,6 +25,7 @@

import static com.example.pladialmserver.user.service.model.TestUserInfo.*;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
Expand Down Expand Up @@ -72,6 +75,21 @@ void login(){
verify(jwtUtil, times(1)).createToken(any(Long.class), any(Role.class));
verify(passwordEncoder, times(1)).encode(any(String.class));
}
@Test
@DisplayName("[실패] 로그인")
void loginFail(){
// given
User user = setUpUser(1L, Role.ADMIN, setUpDepartment(), setUpAffiliation(), passwordEncoder.encode(PASSWORD));
EmailPWReq req = setUpEmailPWReq("[email protected]", "asdf1234!");
// when
doThrow(new BaseException(BaseResponseCode.USER_NOT_FOUND)).when(userRepository).findByEmailAndIsEnable(req.getEmail(), true);
// then
BaseException exception = assertThrows(BaseException.class, () -> {
userService.login(req);
});
assertThat(exception.getBaseResponseCode()).isEqualTo(BaseResponseCode.USER_NOT_FOUND);
}


@Test
void getUserName() {
Expand Down

0 comments on commit b42e4e9

Please sign in to comment.