Merge branch '1.5.x'
This commit is contained in:
commit
87c82310cf
|
|
@ -132,7 +132,7 @@ abstract class RedisConnectionConfiguration {
|
||||||
String password = null;
|
String password = null;
|
||||||
if (uri.getUserInfo() != null) {
|
if (uri.getUserInfo() != null) {
|
||||||
password = uri.getUserInfo();
|
password = uri.getUserInfo();
|
||||||
int index = password.lastIndexOf(':');
|
int index = password.indexOf(':');
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
password = password.substring(index + 1);
|
password = password.substring(index + 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2018 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -94,6 +94,28 @@ public class RedisAutoConfigurationJedisTests {
|
||||||
assertThat(cf.isUseSsl()).isTrue();
|
assertThat(cf.isUseSsl()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordInUrlWithColon() {
|
||||||
|
load("spring.redis.url:redis://:pass:word@example:33");
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getHostName())
|
||||||
|
.isEqualTo("example");
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getPort())
|
||||||
|
.isEqualTo(33);
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getPassword())
|
||||||
|
.isEqualTo("pass:word");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordInUrlStartsWithColon() {
|
||||||
|
load("spring.redis.url:redis://user::pass:word@example:33");
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getHostName())
|
||||||
|
.isEqualTo("example");
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getPort())
|
||||||
|
.isEqualTo(33);
|
||||||
|
assertThat(this.context.getBean(JedisConnectionFactory.class).getPassword())
|
||||||
|
.isEqualTo(":pass:word");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRedisConfigurationWithPool() {
|
public void testRedisConfigurationWithPool() {
|
||||||
load("spring.redis.host:foo", "spring.redis.jedis.pool.min-idle:1",
|
load("spring.redis.host:foo", "spring.redis.jedis.pool.min-idle:1",
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,32 @@ public class RedisAutoConfigurationTests {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordInUrlWithColon() {
|
||||||
|
this.contextRunner
|
||||||
|
.withPropertyValues("spring.redis.url:redis://:pass:word@example:33")
|
||||||
|
.run((context) -> {
|
||||||
|
LettuceConnectionFactory cf = context
|
||||||
|
.getBean(LettuceConnectionFactory.class);
|
||||||
|
assertThat(cf.getHostName()).isEqualTo("example");
|
||||||
|
assertThat(cf.getPort()).isEqualTo(33);
|
||||||
|
assertThat(cf.getPassword()).isEqualTo("pass:word");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPasswordInUrlStartsWithColon() {
|
||||||
|
this.contextRunner
|
||||||
|
.withPropertyValues("spring.redis.url:redis://user::pass:word@example:33")
|
||||||
|
.run((context) -> {
|
||||||
|
LettuceConnectionFactory cf = context
|
||||||
|
.getBean(LettuceConnectionFactory.class);
|
||||||
|
assertThat(cf.getHostName()).isEqualTo("example");
|
||||||
|
assertThat(cf.getPort()).isEqualTo(33);
|
||||||
|
assertThat(cf.getPassword()).isEqualTo(":pass:word");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRedisConfigurationWithPool() {
|
public void testRedisConfigurationWithPool() {
|
||||||
this.contextRunner.withPropertyValues("spring.redis.host:foo",
|
this.contextRunner.withPropertyValues("spring.redis.host:foo",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue