GEODE-420: fixed more tests. Renamed some configuration properties, ssl-http-service-alias -> ssl-http-alias Added SSLConfigurationFactoryTest.java
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/daf025ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/daf025ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/daf025ce Branch: refs/heads/develop Commit: daf025ce63c4ca5249a76e511abb0111c927b58c Parents: 8754dae Author: Udo Kohlmeyer <[email protected]> Authored: Thu Aug 18 07:24:11 2016 +1000 Committer: Udo Kohlmeyer <[email protected]> Committed: Thu Aug 18 07:24:11 2016 +1000 ---------------------------------------------------------------------- .../controllers/RestAPIsWithSSLDUnitTest.java | 32 ++++++++++++-------- .../distributed/ConfigurationProperties.java | 16 +++++----- .../internal/AbstractDistributionConfig.java | 1 + .../internal/DistributionConfig.java | 2 +- .../internal/DistributionConfigJUnitTest.java | 2 +- .../net/SSLConfigurationFactoryTest.java | 22 ++++++++++++-- 6 files changed, 51 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java index 1d91016..f1a4d5b 100644 --- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java +++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java @@ -33,7 +33,6 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Properties; - import javax.net.ssl.SSLContext; import org.apache.commons.lang.StringUtils; @@ -52,9 +51,14 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import com.gemstone.gemfire.test.junit.categories.DistributedTest; - -import com.gemstone.gemfire.cache.*; +import com.gemstone.gemfire.cache.AttributesFactory; +import com.gemstone.gemfire.cache.Cache; +import com.gemstone.gemfire.cache.CacheFactory; +import com.gemstone.gemfire.cache.DataPolicy; +import com.gemstone.gemfire.cache.Region; +import com.gemstone.gemfire.cache.RegionAttributes; +import com.gemstone.gemfire.cache.RegionFactory; +import com.gemstone.gemfire.cache.RegionShortcut; import com.gemstone.gemfire.cache.client.ClientCache; import com.gemstone.gemfire.cache.client.ClientCacheFactory; import com.gemstone.gemfire.cache.client.ClientRegionShortcut; @@ -71,6 +75,7 @@ import com.gemstone.gemfire.test.dunit.Host; import com.gemstone.gemfire.test.dunit.IgnoredException; import com.gemstone.gemfire.test.dunit.NetworkUtils; import com.gemstone.gemfire.test.dunit.VM; +import com.gemstone.gemfire.test.junit.categories.DistributedTest; import com.gemstone.gemfire.test.junit.runners.CategoryWithParameterizedRunnerFactory; import com.gemstone.gemfire.util.test.TestUtil; @@ -95,8 +100,6 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { return Arrays.asList("/geode", "/gemfire-api"); } - private File jks; - public RestAPIsWithSSLDUnitTest() { super(); } @@ -286,6 +289,10 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { } } + /** + * @Deprecated once the legacy SSL properties have been removed we need to remove this logic. + */ + @Deprecated() private Properties configureSSL(Properties props, Properties sslProperties, boolean clusterLevel) { if (clusterLevel) { @@ -318,6 +325,8 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { sslPropertyConverter(sslProperties, props, SSL_TRUSTSTORE_PASSWORD, null); sslPropertyConverter(sslProperties, props, SSL_HTTP_SERVICE_ALIAS, null); sslPropertyConverter(sslProperties, props, SSL_ENABLED_COMPONENTS, null); + sslPropertyConverter(sslProperties, props, SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION, null); + sslPropertyConverter(sslProperties, props, SSL_DEFAULT_ALIAS, null); } return props; } @@ -420,15 +429,11 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { // Host checking is disabled here , as tests might run on multiple hosts and // host entries can not be assumed - SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - return HttpClients.custom().setSSLSocketFactory(sslsf).build(); + return HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).build(); } - // private void validateConnection(String restEndpoint, String algo) { - // validateConnection(restEndpoint, algo, new Properties()); - // } - private void validateConnection(String restEndpoint, String algo, Properties properties) { try { @@ -492,6 +497,7 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { props.setProperty(SSL_KEYSTORE_TYPE, "JKS"); props.setProperty(SSL_ENABLED_COMPONENTS, SSLEnabledComponents.HTTP_SERVICE); props.setProperty(SSL_HTTP_SERVICE_ALIAS, "httpservicekey"); + props.setProperty(SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION, "true"); String restEndpoint = startInfraWithSSL(props, false); validateConnection(restEndpoint, "SSL", props); } @@ -506,6 +512,7 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { props.setProperty(SSL_TRUSTSTORE_PASSWORD, "password"); props.setProperty(SSL_KEYSTORE_TYPE, "JKS"); props.setProperty(SSL_ENABLED_COMPONENTS, SSLEnabledComponents.HTTP_SERVICE); + props.setProperty(SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION, "true"); props.setProperty(SSL_HTTP_SERVICE_ALIAS, "httpservicekey"); props.setProperty(INVALID_CLIENT_ALIAS, "someAlias"); String restEndpoint = startInfraWithSSL(props, false); @@ -656,6 +663,7 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase { props.setProperty(SSL_KEYSTORE_TYPE, "JKS"); props.setProperty(SSL_PROTOCOLS, "SSL"); props.setProperty(SSL_REQUIRE_AUTHENTICATION, "true"); + props.setProperty(SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION, "true"); props.setProperty(SSL_ENABLED_COMPONENTS, SSLEnabledComponents.HTTP_SERVICE); String restEndpoint = startInfraWithSSL(props, false); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java index fdb3bf6..34953a0 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/ConfigurationProperties.java @@ -591,15 +591,15 @@ public interface ConfigurationProperties { */ String HTTP_SERVICE_PORT = "http-service-port"; /** - * The static String definition of the <i>"ssl-http-service-alias"</i> property - * <a name="ssl-http-service-alias"/a></p> + * The static String definition of the <i>"ssl-http-alias"</i> property + * <a name="ssl-http-alias"/a></p> * <U>Description</U>: This property is to be used if a specific key is to be used for the SSL communications for the HTTP service. * </p> * <U><i>Optional</i></U> * <U>Default</U>: "" </p> * <U>Since</U>: Geode 1.0 */ - String SSL_HTTP_SERVICE_ALIAS = "ssl-http-service-alias"; + String SSL_HTTP_SERVICE_ALIAS = "ssl-http-alias"; /** * The static String definition of the <i>"http-service-ssl-ciphers"</i> property * <a name="http-service-ssl-ciphers"/a></p> @@ -822,15 +822,15 @@ public interface ConfigurationProperties { */ String JMX_MANAGER_UPDATE_RATE = "jmx-manager-update-rate"; /** - * The static String definition of the <i>"ssl-jmx-manager-alias"</i> property - * <a name="ssl-jmx-manager-alias"/a></p> + * The static String definition of the <i>"ssl-jmx-alias"</i> property + * <a name="ssl-jmx-alias"/a></p> * <U>Description</U>: This property is to be used if a specific key is to be used for the SSL communications for the jmx manager. * </p> * <U><i>Optional</i></U> * <U>Default</U>: "" </p> * <U>Since</U>: Geode 1.0 */ - String SSL_JMX_MANAGER_ALIAS = "ssl-jmx-manager-alias"; + String SSL_JMX_MANAGER_ALIAS = "ssl-jmx-alias"; /** * The static String definition of the <i>"jmx-manager-ssl-ciphers"</i> property * <a name="jmx-manager-ssl-ciphers"/a></p> @@ -1759,12 +1759,12 @@ public interface ConfigurationProperties { */ String SSL_DEFAULT_ALIAS = "ssl-default-alias"; /** - * The static String definition of the <i>"ssl-http-service-require-authentication"</i> property + * The static String definition of the <i>"ssl-http-require-authentication"</i> property * * <U>Description</U>If false allows client side's http connection to be authenticated without a 2-way SSL authentication. * </p> * <U>Default</U>: "false"</p> * <U>Since</U>: Geode 1.0 */ - String SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION = "ssl-http-service-require-authentication"; + String SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION = "ssl-http-require-authentication"; } http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java index 282a239..571d4ba 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/AbstractDistributionConfig.java @@ -957,6 +957,7 @@ public abstract class AbstractDistributionConfig extends AbstractConfig implemen m.put(SSL_TRUSTSTORE, "Location of the Java keystore file containing the collection of trusted certificates."); m.put(SSL_TRUSTSTORE_PASSWORD, "Password to unlock the truststore."); m.put(SSL_DEFAULT_ALIAS, "The default certificate alias to be used in a multi-key keystore"); + m.put(SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION, "This property determines is the HTTP service with use mutual ssl authentication."); dcAttDescriptions = Collections.unmodifiableMap(m); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java ---------------------------------------------------------------------- diff --git a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java index 8e2a60b..3f60778 100644 --- a/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java +++ b/geode-core/src/main/java/com/gemstone/gemfire/distributed/internal/DistributionConfig.java @@ -4552,7 +4552,7 @@ public interface DistributionConfig extends Config, LogConfig { * property. */ @ConfigAttributeSetter(name = SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION) - void setSSLHTTPRequireAuthentication(boolean requiresAuthenatication); + void setSSLHTTPRequireAuthentication(boolean requiresAuthentication); /** * The name of the {@link ConfigurationProperties#SSL_HTTP_SERVICE_REQUIRE_AUTHENTICATION} property http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java index aa65a41..56b35ea 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/DistributionConfigJUnitTest.java @@ -78,7 +78,7 @@ public class DistributionConfigJUnitTest { @Test public void testGetAttributeNames() { String[] attNames = AbstractDistributionConfig._getAttNames(); - assertEquals(attNames.length, 154); + assertEquals(attNames.length, 155); List boolList = new ArrayList(); List intList = new ArrayList(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/daf025ce/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SSLConfigurationFactoryTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SSLConfigurationFactoryTest.java b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SSLConfigurationFactoryTest.java index 067333e..0b70c8f 100644 --- a/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SSLConfigurationFactoryTest.java +++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/net/SSLConfigurationFactoryTest.java @@ -1,3 +1,19 @@ +/* + * 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 com.gemstone.gemfire.internal.net; import static com.gemstone.gemfire.distributed.ConfigurationProperties.*; @@ -8,17 +24,19 @@ import java.util.Properties; import org.apache.commons.lang.StringUtils; import org.junit.After; import org.junit.Test; +import org.junit.experimental.categories.Category; import com.gemstone.gemfire.distributed.internal.DistributionConfig; import com.gemstone.gemfire.distributed.internal.DistributionConfigImpl; import com.gemstone.gemfire.internal.admin.SSLConfig; import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase; +import com.gemstone.gemfire.test.junit.categories.UnitTest; +@Category(UnitTest.class) public class SSLConfigurationFactoryTest extends JUnit4DistributedTestCase { @After - public void tearDownTest() - { + public void tearDownTest() { SSLConfigurationFactory.close(); }
