실행이 안된는 이유는 jwt.secret.key가 포함 되어 있지 않기 때문입니다.
이를 위해 application.properties를 수정하거나 다른 properties를 repo에 추가하는건 좀 아닌거 같아서 따로 수정을 하지는 않았습니다.
만약 이 프로그램을 돌리고 싶으신 분들이 있다면
jwt.secret.key=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
이렇게 jwt key를 추가한 properties를 사용해 주세요.
저는 application-dev.properties라는 properties파일을 만든뒤 위 key를 추가한 후 아래 명령어를 이용해 실행하였습니다.
gradlew bootRun --args="--spring.config.location=file:.\\application-dev.properties"
IntelliJ 에서 실행 옵션을 어떻게 바꾸는지는 여기를 참고해 주세요.
AuthUserArgumentResolver가 실행 안되는 이유는 등록 되어있지 않았기 때문입니다. 이를 고치기 위해
ArgumentResolverConfig를 추가했습니다.
if (!HttpStatus.OK.equals(responseEntity.getStatusCode())) {
throw new ServerException("날씨 데이터를 가져오는데 실패했습니다. 상태 코드: " + responseEntity.getStatusCode());
} else {
if (weatherArray == null || weatherArray.length == 0) {
throw new ServerException("날씨 데이터가 없습니다.");
}
} if (!HttpStatus.OK.equals(responseEntity.getStatusCode())) {
throw new ServerException("날씨 데이터를 가져오는데 실패했습니다. 상태 코드: " + responseEntity.getStatusCode());
}
if (weatherArray == null || weatherArray.length == 0) {
throw new ServerException("날씨 데이터가 없습니다.");
}Query 문에 적혀있던
@Query("SELECT t FROM Todo t LEFT JOIN FETCH t.user u ORDER BY t.modifiedAt DESC")LEFT JOIN FETCH를
EntityGraph를 이용해 빼냈습니다
@EntityGraph(attributePaths = {"user"})
@Query("SELECT t FROM Todo t ORDER BY t.modifiedAt DESC") boolean matches = passwordEncoder.matches(encodedPassword, rawPassword); boolean matches = passwordEncoder.matches(rawPassword, encodedPassword); public void manager_목록_조회_시_Todo가_없다면_NPE_에러를_던진다() {
...
assertEquals("Manager not found", exception.getMessage()); public void manager_목록_조회_시_Todo가_없다면_에러를_던진다() {
...
assertEquals("Todo not found", exception.getMessage()); ServerException exception = assertThrows(ServerException.class, () -> { InvalidRequestException exception = assertThrows(InvalidRequestException.class, () -> { if (!ObjectUtils.nullSafeEquals(user.getId(), todo.getUser().getId())) {
throw new InvalidRequestException("일정을 생성한 유저만 담당자를 지정할 수 있습니다.");
} if (!ObjectUtils.nullSafeEquals(user.getId(), todo.getUser() == null ? null : todo.getUser().getId())) {
throw new InvalidRequestException("일정을 생성한 유저만 담당자를 지정할 수 있습니다.");
}전에는 todo.getUser().getId() 에서 getUser가 null을 돌려줄 경우 NPE가 발생하여 문제가 있었습니다. 그래서 null을 체크하도록 수정하였습니다.
logging을 위해 AdminInterceptor라는 interceptor를 만들었습니다.
과제에서는 interceptor가 user의 권한까지 체크하도록 요구했지만 이미 JwtFilter에서 권환을 확인하고 있기 때문에 여기서도 체크하는 것은 맞는 거 같지 않이 로깅만 하도록 구현하였습니다.
그리고 요구 조건에는 request와 response의 body를 logging해야 하는데 HttpServletRequest와 HttpServletResponse는 body를 한번 밖에 읽지 못하기 때문에
ContentCachingRequestWrapper로 감싸는 ContentCacheFilter를 만들었습니다.
이로 인해 성능 저하가 있을 거 같지만...
일단 몇만건의 테스트를 하지 않는 이상 실제로 얼마나 영향을 미칠지 모르고, 또 제가 더 나은 아이디어가 없기 때문에... 이렇게 구현하였습니다.