Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Nov 19, 2024
1 parent 5120e01 commit dbfa069
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions java/integTest/src/test/java/glide/cluster/ClusterClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@
package glide.cluster;

import static glide.TestConfiguration.SERVER_VERSION;
import static glide.TestUtilities.commonClientConfig;
import static glide.TestUtilities.commonClusterClientConfig;
import static glide.TestUtilities.getRandomString;
import static glide.api.BaseClient.OK;
import static glide.api.models.configuration.RequestRoutingConfiguration.SimpleMultiNodeRoute.ALL_NODES;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import glide.api.GlideClient;
import glide.api.GlideClusterClient;
import glide.api.models.configuration.ServerCredentials;
import glide.api.models.exceptions.ClosingException;
import glide.api.models.exceptions.ConnectionException;
import glide.api.models.exceptions.RequestException;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import lombok.SneakyThrows;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

@Timeout(30) // seconds
public class ClusterClientTests {
Expand Down Expand Up @@ -175,10 +167,12 @@ public void closed_client_throws_ExecutionException_with_ClosingException_as_cau
@SneakyThrows
@Test
public void test_update_connection_password() {
GlideClusterClient adminClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
GlideClusterClient adminClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
String pwd = UUID.randomUUID().toString();

try (GlideClusterClient testClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
try (GlideClusterClient testClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
// validate that we can use the client
assertNotNull(testClient.info().get());

Expand Down Expand Up @@ -207,15 +201,16 @@ public void test_update_connection_password() {
@Test
public void test_update_connection_password_auth_non_valid_pass() {
// Test Client fails on call to updateConnectionPassword with invalid parameters
try (GlideClusterClient testClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
try (GlideClusterClient testClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
var emptyPasswordException =
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword("", true).get());
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword("", true).get());
assertInstanceOf(RequestException.class, emptyPasswordException.getCause());

var noPasswordException =
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(true).get());
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(true).get());
assertInstanceOf(RequestException.class, noPasswordException.getCause());
}
}
Expand All @@ -225,14 +220,15 @@ public void test_update_connection_password_auth_non_valid_pass() {
public void test_update_connection_password_no_server_auth() {
var pwd = UUID.randomUUID().toString();

try (GlideClusterClient testClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
try (GlideClusterClient testClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
// validate that we can use the client
assertNotNull(testClient.info().get());

// Test that immediate re-authentication fails when no server password is set.
var exception =
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(pwd, true).get());
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(pwd, true).get());
assertInstanceOf(RequestException.class, exception.getCause());
}
}
Expand All @@ -242,7 +238,8 @@ public void test_update_connection_password_no_server_auth() {
public void test_update_connection_password_long() {
var pwd = RandomStringUtils.randomAlphabetic(1000);

try (GlideClusterClient testClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
try (GlideClusterClient testClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
// validate that we can use the client
assertNotNull(testClient.info().get());

Expand All @@ -258,8 +255,10 @@ public void test_replace_password_immediateAuth_wrong_password() {
var pwd = UUID.randomUUID().toString();
var notThePwd = UUID.randomUUID().toString();

GlideClusterClient adminClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
try (GlideClusterClient testClient = GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
GlideClusterClient adminClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get();
try (GlideClusterClient testClient =
GlideClusterClient.createClient(commonClusterClientConfig().build()).get()) {
// validate that we can use the client
assertNotNull(testClient.info().get());

Expand All @@ -268,8 +267,8 @@ public void test_replace_password_immediateAuth_wrong_password() {

// Test that re-authentication fails when using wrong password.
var exception =
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(pwd, true).get());
assertThrows(
ExecutionException.class, () -> testClient.updateConnectionPassword(pwd, true).get());
assertInstanceOf(RequestException.class, exception.getCause());

// But using something else password returns OK
Expand Down

0 comments on commit dbfa069

Please sign in to comment.