diff --git a/src/test/java/io/lettuce/core/cluster/RedisClusterStreamingCredentialsProviderlIntegrationTests.java b/src/test/java/io/lettuce/core/cluster/RedisClusterStreamingCredentialsProviderlIntegrationTests.java index 388969386..8d80516bf 100644 --- a/src/test/java/io/lettuce/core/cluster/RedisClusterStreamingCredentialsProviderlIntegrationTests.java +++ b/src/test/java/io/lettuce/core/cluster/RedisClusterStreamingCredentialsProviderlIntegrationTests.java @@ -12,8 +12,6 @@ import io.lettuce.core.protocol.Command; import io.lettuce.test.CanConnect; import io.lettuce.test.CliParser; -import io.lettuce.test.WithPassword; -import io.lettuce.test.condition.RedisConditions; import io.lettuce.test.resource.FastShutdown; import io.lettuce.test.resource.TestClientResources; import io.lettuce.test.settings.TestSettings; @@ -142,25 +140,28 @@ void nodeSelectionApiShouldWork() { @Test void shouldPerformNodeConnectionReauth() { - try (StatefulRedisClusterConnection connection = redisClient.connect()) { - connection.getPartitions() - .forEach(partition -> createTestUser(connection.getConnection(partition.getNodeId()).sync())); + StatefulRedisClusterConnection connection = redisClient.connect(); + connection.getPartitions() + .forEach(partition -> createTestUser(connection.getConnection(partition.getNodeId()).sync())); - credentialsProvider.emitCredentials(TestSettings.aclUsername(), - TestSettings.aclPassword().toString().toCharArray()); + credentialsProvider.emitCredentials(TestSettings.aclUsername(), + TestSettings.aclPassword().toString().toCharArray()); - Executions pingResponses = connection.sync().all().commands().ping(); - assertThat(pingResponses).hasSize(3).contains("PONG"); + // Verify each node's authenticated username matches the updated credentials + connection.getPartitions().forEach(partition -> { + StatefulRedisConnection userConn = connection.getConnection(partition.getNodeId()); + assertThat(userConn.sync().aclWhoami()).isEqualTo(TestSettings.aclUsername()); + }); - // Verify each node's authenticated username matches the updated credentials - connection.getPartitions().forEach(partition -> { - String authenticatedUser = connection.getConnection(partition.getNodeId()).sync().aclWhoami(); - assertThat(authenticatedUser).isEqualTo(TestSettings.aclUsername()); - }); + // re-auth with the default credentials + credentialsProvider.emitCredentials(TestSettings.username(), + TestSettings.password().toString().toCharArray()); - connection.getPartitions() - .forEach(partition -> deleteTestUser(connection.getConnection(partition.getNodeId()).sync())); - } + connection.getPartitions().forEach(partition -> { + deleteTestUser(connection.getConnection(partition.getNodeId()).sync()); + }); + + connection.close(); } public static void createTestUser(RedisCommands commands) {