From e4229b6abe806b4bbdb147ca24077c0540461751 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 22 Nov 2022 08:48:18 +0100 Subject: [PATCH] Polishing #2255 Add author tag, reformat code. --- src/test/java/io/lettuce/core/RedisURIUnitTests.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/java/io/lettuce/core/RedisURIUnitTests.java b/src/test/java/io/lettuce/core/RedisURIUnitTests.java index 62f9d0fea1..dc2a682448 100644 --- a/src/test/java/io/lettuce/core/RedisURIUnitTests.java +++ b/src/test/java/io/lettuce/core/RedisURIUnitTests.java @@ -35,6 +35,7 @@ * Unit tests for {@link RedisURI} * * @author Mark Paluch + * @author Lei Zhang */ class RedisURIUnitTests { @@ -194,20 +195,21 @@ void socketAltUriTest() { @Test void escapeCharacterParsingTest() throws UnsupportedEncodingException { + String password = "abc@#d"; String translatedPassword = URLEncoder.encode(password, StandardCharsets.UTF_8.name()); // redis sentinel - String uri = "redis-sentinel://"+translatedPassword+"@h1:1234,h2:1234,h3:1234/0?sentinelMasterId=masterId"; + String uri = "redis-sentinel://" + translatedPassword + "@h1:1234,h2:1234,h3:1234/0?sentinelMasterId=masterId"; RedisURI redisURI = RedisURI.create(uri); assertThat(redisURI.getSentinels().get(0).getHost()).isEqualTo("h1"); - assertThat(String.valueOf(redisURI.getCredentialsProvider().resolveCredentials().block().getPassword())).isEqualTo(password); + assertThat(redisURI.getPassword()).isEqualTo(password.toCharArray()); // redis standalone - uri = "redis://"+translatedPassword+"@h1:1234/0"; + uri = "redis://" + translatedPassword + "@h1:1234/0"; redisURI = RedisURI.create(uri); assertThat(redisURI.getHost()).isEqualTo("h1"); - assertThat(String.valueOf(redisURI.getCredentialsProvider().resolveCredentials().block().getPassword())).isEqualTo(password); + assertThat(redisURI.getPassword()).isEqualTo(password.toCharArray()); } @Test