maulin-vasavada commented on code in PR #3638:
URL: https://github.com/apache/cassandra/pull/3638#discussion_r1849352962


##########
test/unit/org/apache/cassandra/utils/jmx/JMXSslDisabledEncryptionOptionsTest.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.utils.jmx;
+
+import java.net.InetAddress;
+import java.util.Map;
+import javax.management.remote.rmi.RMIConnectorServer;
+import javax.net.ssl.SSLException;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.distributed.shared.WithProperties;
+import org.apache.cassandra.utils.JMXServerUtils;
+
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.CASSANDRA_CONFIG;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.COM_SUN_MANAGEMENT_JMXREMOTE_SSL;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.COM_SUN_MANAGEMENT_JMXREMOTE_SSL_ENABLED_CIPHER_SUITES;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.COM_SUN_MANAGEMENT_JMXREMOTE_SSL_ENABLED_PROTOCOLS;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.COM_SUN_MANAGEMENT_JMXREMOTE_SSL_NEED_CLIENT_AUTH;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.JAVAX_RMI_SSL_CLIENT_ENABLED_CIPHER_SUITES;
+import static 
org.apache.cassandra.config.CassandraRelevantProperties.JAVAX_RMI_SSL_CLIENT_ENABLED_PROTOCOLS;
+
+/**
+ * Tests for disabling jmx_encryption_options in the cassandra.yaml.
+ */
+public class JMXSslDisabledEncryptionOptionsTest
+{
+    static WithProperties properties;
+
+    @BeforeClass
+    public static void setupDatabaseDescriptor()
+    {
+        properties = new WithProperties().set(CASSANDRA_CONFIG, 
"cassandra-jmx-disabled-sslconfig.yaml");
+        DatabaseDescriptor.daemonInitialization();
+    }
+
+    @AfterClass
+    public static void tearDownDatabaseDescriptor()
+    {
+        properties.close();
+    }
+
+    @After
+    public void resetJmxSslSystemProperties()
+    {
+        COM_SUN_MANAGEMENT_JMXREMOTE_SSL.reset();
+        COM_SUN_MANAGEMENT_JMXREMOTE_SSL_NEED_CLIENT_AUTH.reset();
+        COM_SUN_MANAGEMENT_JMXREMOTE_SSL_ENABLED_PROTOCOLS.reset();
+        COM_SUN_MANAGEMENT_JMXREMOTE_SSL_ENABLED_CIPHER_SUITES.reset();
+        JAVAX_RMI_SSL_CLIENT_ENABLED_PROTOCOLS.reset();
+        JAVAX_RMI_SSL_CLIENT_ENABLED_CIPHER_SUITES.reset();
+    }
+
+    /**
+     * Tests absence of all JMX SSL configurations,
+     * 1. local only JMX server
+     * 2. System properties set for remote JMX SSL
+     * 3. jmx_encryption_options in the cassandra.yaml
+     */
+    @Test
+    public void testAbsenceOfAllJmxSslConfigs() throws SSLException

Review Comment:
   The challenge is because `jmx_encryption_options` get defaults when we don't 
specify it in cassandra.yaml. So I meant to say that - this test validates 
use-case when none of the below are configured-
   
   1. JMX is turned off with `com.sun.management.jmxremote.ssl` system property
   2. system configuration for the JMX
   3. `jmx_encryption_options` in cassandra.yaml
   
   I have tried to rename the method and update the documentation. Please 
review if the next change makes more sense.



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to