geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensde...@apache.org
Subject [2/3] incubator-geode git commit: GEODE-17: Adding ManagerMBean security test
Date Wed, 16 Mar 2016 21:16:40 GMT
GEODE-17: Adding ManagerMBean security 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/1ffacdc8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/1ffacdc8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/1ffacdc8

Branch: refs/heads/feature/GEODE-17-2
Commit: 1ffacdc8d0f7d3f1650a67e2266123ef4adb8bbc
Parents: 35e63b8
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Wed Mar 16 14:10:29 2016 -0700
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Wed Mar 16 14:16:25 2016 -0700

----------------------------------------------------------------------
 .../ManagerMBeanAuthorizationJUnitTest.java     | 29 ++++++++++----------
 .../internal/security/cacheServer.json          |  3 +-
 2 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1ffacdc8/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
index d3add7a..ab22f96 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/security/ManagerMBeanAuthorizationJUnitTest.java
@@ -16,13 +16,10 @@
  */
 package com.gemstone.gemfire.management.internal.security;
 
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.distributed.internal.locks.DLockService;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.management.ManagerMXBean;
+import com.gemstone.gemfire.management.internal.beans.ManagerMBean;
 import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
-import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
@@ -30,7 +27,11 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.Mockito.mock;
 
 @Category(IntegrationTest.class)
 public class ManagerMBeanAuthorizationJUnitTest {
@@ -46,18 +47,16 @@ public class ManagerMBeanAuthorizationJUnitTest {
   public MBeanServerConnectionRule connectionRule = new MBeanServerConnectionRule(jmxManagerPort);
 
   @BeforeClass
-  public static void beforeClassSetUp() {
-    Cache cache = CacheFactory.getAnyInstance();
+  public static void beforeClassSetup() throws Exception {
+    // Create a mock ManagerMBean that we will use to call against.
+    ObjectName managerMBeanName = ObjectName.getInstance("GemFire", "mock", "Manager");
+    ManagerMXBean bean = mock(ManagerMBean.class);
+    ManagementFactory.getPlatformMBeanServer().registerMBean(bean, managerMBeanName);
   }
 
   @Before
   public void setUp() throws Exception {
-    managerMXBean = connectionRule.getProxyMBean(ManagerMXBean.class);
-  }
-
-  @AfterClass
-  public static void afterClassTeardown() {
-    DLockService.destroyAll();
+    managerMXBean = connectionRule.getProxyMBean(ManagerMXBean.class, "GemFire:mock=Manager");
   }
 
   @Test
@@ -71,13 +70,13 @@ public class ManagerMBeanAuthorizationJUnitTest {
   @Test
   @JMXConnectionConfiguration(user = "user", password = "1234567")
   public void testSomeAccess() throws Exception {
-//    assertThatThrownBy(() -> managerMXBean.becomeLockGrantor()).isInstanceOf(SecurityException.class);
-//    managerMXBean.getMemberCount();
+    assertThatThrownBy(() -> managerMXBean.start()).isInstanceOf(SecurityException.class);
+    managerMXBean.getPulseURL();
   }
 
   @Test
   @JMXConnectionConfiguration(user = "stranger", password = "1234567")
   public void testNoAccess() throws Exception {
-//    assertThatThrownBy(() -> managerMXBean.becomeLockGrantor()).isInstanceOf(SecurityException.class);
+    assertThatThrownBy(() -> managerMXBean.start()).isInstanceOf(SecurityException.class);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/1ffacdc8/geode-core/src/test/resources/com/gemstone/gemfire/management/internal/security/cacheServer.json
----------------------------------------------------------------------
diff --git a/geode-core/src/test/resources/com/gemstone/gemfire/management/internal/security/cacheServer.json
b/geode-core/src/test/resources/com/gemstone/gemfire/management/internal/security/cacheServer.json
index 95037e5..20376b8 100644
--- a/geode-core/src/test/resources/com/gemstone/gemfire/management/internal/security/cacheServer.json
+++ b/geode-core/src/test/resources/com/gemstone/gemfire/management/internal/security/cacheServer.json
@@ -44,7 +44,8 @@
     {
       "name": "something",
       "operationsAllowed": [
-        "JMX:GET"
+        "JMX:GET",
+        "MANAGER:SET_PULSE_URL"
       ]
     },
     {


Mime
View raw message