Skip to content

Commit

Permalink
Polishing #2255
Browse files Browse the repository at this point in the history
Add author tag, reformat code.
  • Loading branch information
mp911de committed Nov 22, 2022
1 parent 1f581c2 commit e4229b6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/test/java/io/lettuce/core/RedisURIUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* Unit tests for {@link RedisURI}
*
* @author Mark Paluch
* @author Lei Zhang
*/
class RedisURIUnitTests {

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e4229b6

Please sign in to comment.