You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ji...@apache.org on 2016/04/25 04:34:27 UTC
[2/2] incubator-geode git commit: GEODE-17: fix test failures due to
security configuration with no setter specified
GEODE-17: fix test failures due to security configuration with no setter specified
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/7e9d2494
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/7e9d2494
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/7e9d2494
Branch: refs/heads/feature/GEODE-17-2
Commit: 7e9d2494dabb9e592fc4d4119bcefcafee3e37ad
Parents: 047bf8b
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Sun Apr 24 19:32:36 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Sun Apr 24 19:32:36 2016 -0700
----------------------------------------------------------------------
.../internal/AbstractDistributionConfig.java | 23 +++++++++++++++-----
.../internal/DistributionConfigJUnitTest.java | 14 ++++++++++++
2 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d2494/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 e8dafb8..e1881e3 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
@@ -519,6 +519,13 @@ public abstract class AbstractDistributionConfig
return;
}
+ // special case: log-level and security-log-level attributes are String type, but the setter accepts int
+ if(attName.equalsIgnoreCase(LOG_LEVEL_NAME) || attName.equalsIgnoreCase(SECURITY_LOG_LEVEL_NAME)){
+ if(attValue instanceof String) {
+ attValue = LogWriterImpl.levelNameToCode((String) attValue);
+ }
+ }
+
if (attName.startsWith(SECURITY_PREFIX_NAME)) {
this.setSecurity(attName,attValue.toString());
}
@@ -527,13 +534,19 @@ public abstract class AbstractDistributionConfig
this.setSSLProperty(attName, attValue.toString());
}
- // special case: log-level and security-log-level attributes are String type, but the setter accepts int
- if(attName.equalsIgnoreCase(LOG_LEVEL_NAME) || attName.equalsIgnoreCase(SECURITY_LOG_LEVEL_NAME)){
- attValue = LogWriterImpl.levelNameToCode((String)attValue);
- }
-
Method setter = setters.get(attName);
if (setter == null) {
+ // if we cann't find the defined setter, look for two more special cases
+ if (attName.startsWith(SECURITY_PREFIX_NAME)) {
+ this.setSecurity(attName,(String)attValue);
+ getAttSourceMap().put(attName, source);
+ return;
+ }
+ if (attName.startsWith(SSL_SYSTEM_PROPS_NAME) || attName.startsWith(SYS_PROP_NAME)) {
+ this.setSSLProperty(attName, (String) attValue);
+ getAttSourceMap().put(attName, source);
+ return;
+ }
throw new InternalGemFireException(LocalizedStrings.AbstractDistributionConfig_UNHANDLED_ATTRIBUTE_NAME_0.toLocalizedString(attName));
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/7e9d2494/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 3e7008d..31acc47 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
@@ -330,6 +330,20 @@ public class DistributionConfigJUnitTest {
assertEquals(config.getSecurityProps().size(), 3);
}
+ @Test
+ public void testSecurityPropsWithNoSetter(){
+ Properties props = new Properties();
+ props.put(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, JSONAuthorization.class.getName() + ".create");
+ props.put(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, JSONAuthorization.class.getName() + ".create");
+ props.put(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "config");
+ // add another non-security property to verify it won't get put in the security properties
+ props.put(DistributionConfig.ACK_WAIT_THRESHOLD_NAME, 2);
+ props.put("security-username", "testName");
+
+ DistributionConfig config = new DistributionConfigImpl(props);
+ assertEquals(config.getSecurityProps().size(), 4);
+ }
+
public final static Map<Class<?>, Class<?>> classMap = new HashMap<Class<?>, Class<?>>();
static {