Merge branch '1.5.x'

This commit is contained in:
Stephane Nicoll 2018-01-30 10:42:45 +01:00
commit 87c82310cf
3 changed files with 50 additions and 2 deletions

View File

@ -132,7 +132,7 @@ abstract class RedisConnectionConfiguration {
String password = null;
if (uri.getUserInfo() != null) {
password = uri.getUserInfo();
int index = password.lastIndexOf(':');
int index = password.indexOf(':');
if (index >= 0) {
password = password.substring(index + 1);
}

View File

@ -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");
* you may not use this file except in compliance with the License.
@ -94,6 +94,28 @@ public class RedisAutoConfigurationJedisTests {
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
public void testRedisConfigurationWithPool() {
load("spring.redis.host:foo", "spring.redis.jedis.pool.min-idle:1",

View File

@ -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
public void testRedisConfigurationWithPool() {
this.contextRunner.withPropertyValues("spring.redis.host:foo",