|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
19 | 19 | import static org.junit.Assume.*;
|
20 | 20 |
|
| 21 | +import io.lettuce.core.ClientOptions; |
| 22 | +import io.lettuce.core.protocol.ProtocolVersion; |
| 23 | + |
| 24 | +import java.io.IOException; |
| 25 | +import java.util.Collections; |
| 26 | + |
21 | 27 | import org.junit.Before;
|
22 | 28 | import org.junit.Ignore;
|
23 | 29 | import org.junit.Test;
|
24 | 30 |
|
25 | 31 | import org.springframework.data.redis.RedisTestProfileValueSource;
|
26 | 32 | import org.springframework.data.redis.connection.RedisConnection;
|
| 33 | +import org.springframework.data.redis.connection.RedisSentinelConfiguration; |
| 34 | +import org.springframework.data.redis.connection.RedisSentinelConnection; |
27 | 35 | import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
28 | 36 | import org.springframework.data.redis.connection.RedisStaticMasterReplicaConfiguration;
|
29 | 37 |
|
@@ -76,6 +84,30 @@ public void shouldConnectStandaloneWithAclAuthentication() {
|
76 | 84 | connectionFactory.destroy();
|
77 | 85 | }
|
78 | 86 |
|
| 87 | + @Test // DATAREDIS-1145 |
| 88 | + public void shouldConnectSentinelWithAuthentication() throws IOException { |
| 89 | + |
| 90 | + // Note: As per https://github.com/redis/redis/issues/7708, Sentinel does not support ACL authentication yet. |
| 91 | + |
| 92 | + LettuceClientConfiguration configuration = LettuceClientConfiguration.builder() |
| 93 | + .clientResources(LettuceTestClientResources.getSharedClientResources()) |
| 94 | + .clientOptions(ClientOptions.builder().protocolVersion(ProtocolVersion.RESP2).build()).build(); |
| 95 | + |
| 96 | + RedisSentinelConfiguration sentinelConfiguration = new RedisSentinelConfiguration("mymaster", |
| 97 | + Collections.singleton("localhost:26382")); |
| 98 | + sentinelConfiguration.setSentinelPassword("foobared"); |
| 99 | + |
| 100 | + LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(sentinelConfiguration, configuration); |
| 101 | + connectionFactory.afterPropertiesSet(); |
| 102 | + |
| 103 | + RedisSentinelConnection connection = connectionFactory.getSentinelConnection(); |
| 104 | + |
| 105 | + assertThat(connection.masters()).isNotEmpty(); |
| 106 | + connection.close(); |
| 107 | + |
| 108 | + connectionFactory.destroy(); |
| 109 | + } |
| 110 | + |
79 | 111 | @Test // DATAREDIS-1046
|
80 | 112 | @Ignore("https://github.com/lettuce-io/lettuce-core/issues/1406")
|
81 | 113 | public void shouldConnectMasterReplicaWithAclAuthentication() {
|
|
0 commit comments