Защита стенда и управление секретами через OpenBao
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.example.mtusi_messenger.cache;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class UserCacheTest {
|
||||
|
||||
@Test
|
||||
void shouldEvictJsonNullAndReturnCacheMiss() {
|
||||
UUID userId = UUID.randomUUID();
|
||||
String key = "messenger:user:" + userId;
|
||||
StringRedisTemplate redis = mock(StringRedisTemplate.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
ValueOperations<String, String> values = mock(ValueOperations.class);
|
||||
when(redis.opsForValue()).thenReturn(values);
|
||||
when(values.get(key)).thenReturn("null");
|
||||
UserCache cache = new UserCache(redis, new ObjectMapper(), 300);
|
||||
|
||||
assertTrue(cache.find(userId).isEmpty());
|
||||
verify(redis).delete(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user