Commit 87c82310 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge branch '1.5.x'

parents 1bf5768b 11f700aa
......@@ -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);
}
......
/*
* 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",
......
......@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment