geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [13/50] [abbrv] incubator-geode git commit: GEODE-17: fix test failures due to security configuration with no setter specified
Date Tue, 03 May 2016 21:52:02 GMT
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-1255
Commit: 7e9d2494dabb9e592fc4d4119bcefcafee3e37ad
Parents: 047bf8b
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Sun Apr 24 19:32:36 2016 -0700
Committer: Jinmei Liao <jiliao@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 {


Mime
View raw message