geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [1/2] incubator-geode git commit: GEODE-1647: add more unit test
Date Wed, 20 Jul 2016 23:05:45 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 7c2e21933 -> 50aedb1fc


GEODE-1647: add more unit test


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/50aedb1f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/50aedb1f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/50aedb1f

Branch: refs/heads/develop
Commit: 50aedb1fc025f10219f2067967eafddab32d02c5
Parents: 16b7356
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Wed Jul 20 09:42:24 2016 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Wed Jul 20 16:04:31 2016 -0700

----------------------------------------------------------------------
 .../security/GeodeSecurityUtilTest.java         | 57 ++++++++++++++++++++
 1 file changed, 57 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/50aedb1f/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
index a26f06a..272b04f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/security/GeodeSecurityUtilTest.java
@@ -17,9 +17,13 @@
 package com.gemstone.gemfire.internal.security;
 
 
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
 import static org.assertj.core.api.Java6Assertions.*;
 import static org.junit.Assert.*;
 
+import java.util.Properties;
+
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -28,6 +32,12 @@ import com.gemstone.gemfire.test.junit.categories.UnitTest;
 
 @Category(UnitTest.class)
 public class GeodeSecurityUtilTest {
+  Properties properties;
+  @Before
+  public void before(){
+    properties = new Properties();
+    GeodeSecurityUtil.initSecurity(properties);
+  }
 
   @Test
   public void testGetObjectFromConstructor(){
@@ -61,6 +71,53 @@ public class GeodeSecurityUtilTest {
       .isInstanceOf(GemFireSecurityException.class);
   }
 
+  @Test
+  public void testInitialSecurityFlags() {
+    // initial state of GeodeSecurityUtil
+    assertFalse(GeodeSecurityUtil.isClientSecurityRequired());
+    assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+    assertFalse(GeodeSecurityUtil.isPeerSecurityRequired());
+  }
+
+  @Test
+  public void testInitWithSecurityManager() {
+    properties.setProperty(SECURITY_MANAGER, "org.apache.geode.security.templates.SampleSecurityManager");
+    GeodeSecurityUtil.initSecurity(properties);
+    assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+    assertTrue(GeodeSecurityUtil.isIntegratedSecurity());
+    assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+  }
+
+  @Test
+  public void testInitWithClientAuthenticator()
+  {
+    properties.setProperty(SECURITY_CLIENT_AUTHENTICATOR, "org.abc.test");
+    GeodeSecurityUtil.initSecurity(properties);
+    assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+    assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+    assertFalse(GeodeSecurityUtil.isPeerSecurityRequired());
+  }
+
+  @Test
+  public void testInitWithPeerAuthenticator()
+  {
+    properties.setProperty(SECURITY_PEER_AUTHENTICATOR, "org.abc.test");
+    GeodeSecurityUtil.initSecurity(properties);
+    assertFalse(GeodeSecurityUtil.isClientSecurityRequired());
+    assertFalse(GeodeSecurityUtil.isIntegratedSecurity());
+    assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+  }
+
+  @Test
+  public void testInitWithShiroAuthenticator()
+  {
+    properties.setProperty(SECURITY_SHIRO_INIT, "shiro.ini");
+    GeodeSecurityUtil.initSecurity(properties);
+    assertTrue(GeodeSecurityUtil.isClientSecurityRequired());
+    assertTrue(GeodeSecurityUtil.isIntegratedSecurity());
+    assertTrue(GeodeSecurityUtil.isPeerSecurityRequired());
+  }
+
   private static class Factories{
     public static String getString(){
       return new String();


Mime
View raw message