DATAREDIS-1145 - Support Sentinel password for Jedis.
We now support password-protected Sentinel configurations when using Jedis. Original Pull Request: #558
This commit is contained in:
committed by
Christoph Strobl
parent
d97c5df130
commit
717a196da0
@@ -18,11 +18,16 @@ package org.springframework.data.redis.connection.jedis;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.redis.RedisTestProfileValueSource;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
|
||||
/**
|
||||
@@ -72,6 +77,26 @@ public class JedisAclIntegrationTests {
|
||||
connectionFactory.destroy();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1145
|
||||
public void shouldConnectSentinelWithAclAuthentication() throws IOException {
|
||||
|
||||
// Note: As per https://github.com/redis/redis/issues/7708, Sentinel does not support ACL authentication yet.
|
||||
|
||||
RedisSentinelConfiguration sentinelConfiguration = new RedisSentinelConfiguration("mymaster",
|
||||
Collections.singleton("localhost:26382"));
|
||||
sentinelConfiguration.setSentinelPassword("foobared");
|
||||
|
||||
JedisConnectionFactory connectionFactory = new JedisConnectionFactory(sentinelConfiguration);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
|
||||
RedisSentinelConnection connection = connectionFactory.getSentinelConnection();
|
||||
|
||||
assertThat(connection.masters()).isNotEmpty();
|
||||
connection.close();
|
||||
|
||||
connectionFactory.destroy();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1046
|
||||
public void shouldConnectStandaloneWithAclAuthenticationAndPooling() {
|
||||
|
||||
|
||||
@@ -18,12 +18,20 @@ package org.springframework.data.redis.connection.lettuce;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import io.lettuce.core.ClientOptions;
|
||||
import io.lettuce.core.protocol.ProtocolVersion;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.data.redis.RedisTestProfileValueSource;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisStaticMasterReplicaConfiguration;
|
||||
|
||||
@@ -76,6 +84,30 @@ public class LettuceAclIntegrationTests {
|
||||
connectionFactory.destroy();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1145
|
||||
public void shouldConnectSentinelWithAuthentication() throws IOException {
|
||||
|
||||
// Note: As per https://github.com/redis/redis/issues/7708, Sentinel does not support ACL authentication yet.
|
||||
|
||||
LettuceClientConfiguration configuration = LettuceClientConfiguration.builder()
|
||||
.clientResources(LettuceTestClientResources.getSharedClientResources())
|
||||
.clientOptions(ClientOptions.builder().protocolVersion(ProtocolVersion.RESP2).build()).build();
|
||||
|
||||
RedisSentinelConfiguration sentinelConfiguration = new RedisSentinelConfiguration("mymaster",
|
||||
Collections.singleton("localhost:26382"));
|
||||
sentinelConfiguration.setSentinelPassword("foobared");
|
||||
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(sentinelConfiguration, configuration);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
|
||||
RedisSentinelConnection connection = connectionFactory.getSentinelConnection();
|
||||
|
||||
assertThat(connection.masters()).isNotEmpty();
|
||||
connection.close();
|
||||
|
||||
connectionFactory.destroy();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-1046
|
||||
@Ignore("https://github.com/lettuce-io/lettuce-core/issues/1406")
|
||||
public void shouldConnectMasterReplicaWithAclAuthentication() {
|
||||
|
||||
Reference in New Issue
Block a user