Skip to content

Commit

Permalink
test(be) #640: 테스트코드 버그가 Redis 설정 때문인지 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
devbattery committed Dec 16, 2024
1 parent 11da3cc commit 48b1f5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,35 @@

import com.foodymoody.be.auth.domain.RefreshTokenStorage;
import com.foodymoody.be.common.util.ids.MemberId;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class RedisRefreshTokenStorage implements RefreshTokenStorage {

private static final String REFRESH_PREFIX = "jwt:refresh:";
private static final String BLACKLIST_PREFIX = "jwt:blacklist:";

private final RedisTemplate<String, String> template;
private final ConcurrentHashMap<String, String> refreshTokens = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Long> blacklist = new ConcurrentHashMap<>();

@Override
public void saveRefreshToken(MemberId memberId, String refreshToken) {
template.opsForValue().set(REFRESH_PREFIX + memberId.getValue(), refreshToken);
refreshTokens.put(memberId.getValue(), refreshToken);
}

@Override
public String findByMemberId(String memberId) {
return template.opsForValue().get(REFRESH_PREFIX + memberId);
return refreshTokens.get(memberId);
}

@Override
public void addBlacklist(String token, long exp) {
template.opsForValue().set(BLACKLIST_PREFIX + token, String.valueOf(exp));
blacklist.put(token, exp);
}

@Override
public boolean isBlacklist(String token) {
return !Objects.isNull(template.opsForValue().get(BLACKLIST_PREFIX + token));
return blacklist.containsKey(token);
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ void when_deleteMember_then_success() {
팔로우한다(회원아티_액세스토큰, 푸반_아이디, new RequestSpecBuilder().build());
팔로우한다(회원푸반_액세스토큰, 아티_아이디, new RequestSpecBuilder().build());

// 피드 등록하는 부분 추가 (푸반이 탈퇴를 하니, 푸반 토큰으로 등록 안 하면 오류 안 생김)
// 피드를_등록한다(회원아티_액세스토큰, 피드_이미지_업로드_후_id_리스트를_반환한다(회원아티_액세스토큰, spec));
// 피드를_등록한다(회원푸반_액세스토큰, 피드_이미지_업로드_후_id_리스트를_반환한다(회원푸반_액세스토큰, spec));
// 피드 등록하는 부분 추가
피드를_등록한다(회원아티_액세스토큰, 피드_이미지_업로드_후_id_리스트를_반환한다(회원아티_액세스토큰, spec));
피드를_등록한다(회원푸반_액세스토큰, 피드_이미지_업로드_후_id_리스트를_반환한다(회원푸반_액세스토큰, spec));

// when
var response = 회원탈퇴한다(회원푸반_액세스토큰, spec);
Expand Down

0 comments on commit 48b1f5d

Please sign in to comment.