yifan-c commented on code in PR #148: URL: https://github.com/apache/cassandra-sidecar/pull/148#discussion_r1854663728
########## server/src/test/integration/org/apache/cassandra/sidecar/cluster/locator/CqlSessionProviderIntegrationTest.java: ########## @@ -0,0 +1,172 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.sidecar.cluster.locator; + +import java.util.Collections; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.extension.ExtendWith; + +import com.datastax.driver.core.Session; +import io.vertx.ext.web.client.WebClient; +import io.vertx.junit5.VertxExtension; +import io.vertx.junit5.VertxTestContext; +import org.apache.cassandra.sidecar.common.response.ConnectedClientStatsResponse; +import org.apache.cassandra.sidecar.common.response.data.ClientConnectionEntry; +import org.apache.cassandra.sidecar.config.SslConfiguration; +import org.apache.cassandra.sidecar.config.yaml.KeyStoreConfigurationImpl; +import org.apache.cassandra.sidecar.config.yaml.SslConfigurationImpl; +import org.apache.cassandra.sidecar.testing.IntegrationTestBase; +import org.apache.cassandra.testing.CassandraIntegrationTest; +import org.apache.cassandra.testing.ConfigurableCassandraTestContext; +import software.amazon.awssdk.utils.ImmutableMap; + +import static org.apache.cassandra.sidecar.testing.IntegrationTestModule.ADMIN_IDENTITY; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assumptions.assumeThat; + +/** + * Test for authenticated {@link org.apache.cassandra.sidecar.cluster.CQLSessionProviderImpl} + */ +@ExtendWith(VertxExtension.class) +class CqlSessionProviderIntegrationTest extends IntegrationTestBase +{ + private static final int MIN_VERSION_WITH_MTLS = 5; + + @CassandraIntegrationTest(buildCluster = false) + void testWithUsernamePassword(VertxTestContext context, ConfigurableCassandraTestContext cassandraContext) throws Exception + { + cassandraContext.configureAndStartCluster(builder -> { + builder.appendConfig(config -> config.set("authenticator", "org.apache.cassandra.auth.PasswordAuthenticator")); + }); + sidecarTestContext.refreshInstancesConfig(); + waitForSchemaReady(30, TimeUnit.SECONDS); + retrieveClientStats(context, "cassandra", false); + } + + @CassandraIntegrationTest(buildCluster = false) + void testWithSSLOnly(VertxTestContext context, ConfigurableCassandraTestContext cassandraContext) throws Exception + { + cassandraContext.configureAndStartCluster(builder -> { + builder.appendConfig(config -> + // dot-separated options are not supported in 4.0 + config.set("client_encryption_options", ImmutableMap.of("enabled", "true", + "require_client_auth", "false", + "keystore", serverKeystorePath.toAbsolutePath().toString(), + "keystore_password", serverKeystorePassword))); + }); + sidecarTestContext.setSslConfiguration(sslConfigWithTruststore()); + waitForSchemaReady(30, TimeUnit.SECONDS); + // we enable only SSL and do not set any authenticator, hence username is "anonymous" + retrieveClientStats(context, "anonymous", true); + } + + @CassandraIntegrationTest(buildCluster = false) + void testWithMTLS(VertxTestContext context, ConfigurableCassandraTestContext cassandraContext) throws Exception + { + // mTLS authentication was added in Cassandra starting 5.0 version + assumeThat(cassandraContext.version.major) Review Comment: nice assertj feature -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

