You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ud...@apache.org on 2016/08/10 19:41:09 UTC
[23/50] [abbrv] incubator-geode git commit: GEODE-1570: add rest
security test harness and rearranged the tests
GEODE-1570: add rest security test harness and rearranged the tests
rearranged the tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/88247e32
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/88247e32
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/88247e32
Branch: refs/heads/feature/GEODE-420
Commit: 88247e32132c4a0f2de00db51b57d6e3fe48b5f2
Parents: fa36a0c
Author: Jinmei Liao <ji...@pivotal.io>
Authored: Tue Aug 2 11:10:16 2016 -0700
Committer: Jinmei Liao <ji...@pivotal.io>
Committed: Thu Aug 4 08:59:32 2016 -0700
----------------------------------------------------------------------
.../internal/web/RestSecurityDUnitTest.java | 80 +++++
...ractIntegratedClientAuthDistributedTest.java | 141 --------
.../security/AbstractSecureServerDUnitTest.java | 150 +++++++++
.../security/IntegratedClientAuthDUnitTest.java | 2 +-
...tedClientContainsKeyAuthDistributedTest.java | 2 +-
...entDestroyInvalidateAuthDistributedTest.java | 2 +-
...dClientDestroyRegionAuthDistributedTest.java | 2 +-
...lientExecuteFunctionAuthDistributedTest.java | 2 +-
...xecuteRegionFunctionAuthDistributedTest.java | 2 +-
...tegratedClientGetAllAuthDistributedTest.java | 2 +-
...tGetClientPRMetaDataAuthDistributedTest.java | 2 +-
...ientPartitionAttrCmdAuthDistributedTest.java | 2 +-
...gratedClientGetEntryAuthDistributedTest.java | 2 +-
...tegratedClientGetPutAuthDistributedTest.java | 2 +-
...tedClientRegionClearAuthDistributedTest.java | 2 +-
...ientRegisterInterestAuthDistributedTest.java | 2 +-
...ratedClientRemoveAllAuthDistributedTest.java | 2 +-
...IntegratedClientSizeAuthDistributedTest.java | 2 +-
...ntUnregisterInterestAuthDistributedTest.java | 2 +-
...urityNoShowValue1PostProcessorDUnitTest.java | 86 -----
...ntegratedSecurityPostProcessorDUnitTest.java | 126 --------
.../NoShowValue1PostProcessorDUnitTest.java | 86 +++++
.../gemfire/security/PDXPostProcessor.java | 45 +++
.../security/PDXPostProcessorDUnitTest.java | 233 +++++++++++++
.../security/PostProcessorDUnitTest.java | 126 ++++++++
.../security/CQPDXPostProcessorDUnitTest.java | 116 +++++++
.../security/CQPostProcessorDunitTest.java | 2 +-
.../ClientQueryAuthDistributedTest.java | 2 +-
.../security/PDXPostProcessorDUnitTest.java | 323 -------------------
29 files changed, 854 insertions(+), 694 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestSecurityDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestSecurityDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestSecurityDUnitTest.java
new file mode 100644
index 0000000..57b70d6
--- /dev/null
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/RestSecurityDUnitTest.java
@@ -0,0 +1,80 @@
+package com.gemstone.gemfire.rest.internal.web;
+
+import static org.junit.Assert.*;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.security.AbstractSecureServerDUnitTest;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ DistributedTest.class, SecurityTest.class})
+public class RestSecurityDUnitTest extends AbstractSecureServerDUnitTest {
+ private String endPoint = null;
+ public RestSecurityDUnitTest(){
+ int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(2);
+ this.jmxPort = ports[0];
+ this.restPort = ports[1];
+ endPoint = "http://localhost:"+restPort+"/gemfire-api/v1";
+ }
+ @Test
+ public void test(){
+ client1.invoke(()->{
+ JSONArray response = doGet("/servers");
+ assertEquals(response.length(), 1);
+ assertEquals(response.get(0), "http://localhost:"+this.restPort);
+ });
+ }
+
+
+ private JSONArray doGet(String uri) {
+ HttpGet get = new HttpGet(endPoint + uri);
+ get.addHeader("Content-Type", "application/json");
+ get.addHeader("Accept", "application/json");
+ CloseableHttpClient httpclient = HttpClients.createDefault();
+ CloseableHttpResponse response;
+
+ try {
+ response = httpclient.execute(get);
+ HttpEntity entity = response.getEntity();
+ InputStream content = entity.getContent();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(
+ content));
+ String line;
+ StringBuffer str = new StringBuffer();
+ while ((line = reader.readLine()) != null) {
+ str.append(line);
+ }
+
+ //validate the satus code
+ assertEquals(response.getStatusLine().getStatusCode(), 200);
+ return new JSONArray(str.toString());
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ fail(" Rest Request should not have thrown ClientProtocolException!");
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(" Rest Request should not have thrown IOException!");
+ } catch (JSONException e) {
+ e.printStackTrace();
+ fail(" Rest Request should not have thrown JSONException!");
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
deleted file mode 100644
index 65cc98f..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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.security;
-
-import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static org.assertj.core.api.Assertions.*;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Properties;
-
-import org.apache.geode.security.templates.SampleSecurityManager;
-import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
-import org.junit.Before;
-
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.Region;
-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;
-import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
-
-public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTestCase {
-
- protected static final String REGION_NAME = "AuthRegion";
-
- protected VM client1 = null;
- protected VM client2 = null;
- protected VM client3 = null;
- protected int serverPort;
- protected Class postProcessor = null;
- protected boolean pdxPersistent = false;
- protected int jmxPort = 0;
- protected Map<String, Object> values;
-
- public AbstractIntegratedClientAuthDistributedTest(){
- values = new HashMap();
- for(int i=0; i<5; i++){
- values.put("key"+i, "value"+i);
- }
- }
-
- @Before
- public void before() throws Exception {
- final Host host = Host.getHost(0);
- this.client1 = host.getVM(1);
- this.client2 = host.getVM(2);
- this.client3 = host.getVM(3);
-
- Properties props = new Properties();
- props.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
- props.setProperty(SECURITY_MANAGER, SampleSecurityManager.class.getName());
- props.setProperty(LOCATORS, "");
- props.setProperty(MCAST_PORT, "0");
- if (postProcessor!=null) {
- props.setProperty(SECURITY_POST_PROCESSOR, postProcessor.getName());
- }
- props.setProperty(SECURITY_LOG_LEVEL, "finest");
-
- props.setProperty("security-pdx", pdxPersistent+"");
- if(jmxPort>0){
- props.put(JMX_MANAGER, "true");
- props.put(JMX_MANAGER_START, "true");
- props.put(JMX_MANAGER_PORT, String.valueOf(jmxPort));
- }
-
- getSystem(props);
-
- CacheFactory cf = null;
- cf = new CacheFactory();
- cf.setPdxPersistent(pdxPersistent);
- cf.setPdxReadSerialized(pdxPersistent);
- Cache cache = getCache(cf);
-
- Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
-
- CacheServer server1 = cache.addCacheServer();
- server1.setPort(0);
- server1.start();
-
- this.serverPort = server1.getPort();
-
- for(Entry entry:values.entrySet()){
- region.put(entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- public void preTearDownCacheTestCase() throws Exception {
- Invoke.invokeInEveryVM(()->closeCache());
- closeCache();
- }
-
- public static void assertNotAuthorized(ThrowingCallable shouldRaiseThrowable, String permString) {
- assertThatThrownBy(shouldRaiseThrowable).hasMessageContaining(permString);
- }
-
- protected Properties createClientProperties(String userName, String password) {
- Properties props = new Properties();
- props.setProperty(UserPasswordAuthInit.USER_NAME, userName);
- props.setProperty(UserPasswordAuthInit.PASSWORD, password);
- props.setProperty(LOCATORS, "");
- props.setProperty(MCAST_PORT, "0");
- props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
- props.setProperty(SECURITY_LOG_LEVEL, "finest");
- return props;
- }
-
- protected ClientCache createClientCache(String username, String password, int serverPort){
- ClientCache cache = new ClientCacheFactory(createClientProperties(username, password))
- .setPoolSubscriptionEnabled(true)
- .addPoolServer("localhost", serverPort)
- .create();
-
- cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
- return cache;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractSecureServerDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractSecureServerDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractSecureServerDUnitTest.java
new file mode 100644
index 0000000..4f0e260
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractSecureServerDUnitTest.java
@@ -0,0 +1,150 @@
+/*
+ * 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.security;
+
+import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+import static org.assertj.core.api.Assertions.*;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import org.apache.geode.security.templates.SampleSecurityManager;
+import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
+import org.junit.Before;
+
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.Region;
+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;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.Invoke;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
+
+public class AbstractSecureServerDUnitTest extends JUnit4CacheTestCase {
+
+ protected static final String REGION_NAME = "AuthRegion";
+
+ protected VM client1 = null;
+ protected VM client2 = null;
+ protected VM client3 = null;
+ protected int serverPort;
+
+ // child classes can customize these parameters
+ protected Class postProcessor = null;
+ protected boolean pdxPersistent = false;
+ protected int jmxPort = 0;
+ protected int restPort = 0;
+ protected Map<String, Object> values;
+
+ public AbstractSecureServerDUnitTest(){
+ values = new HashMap();
+ for(int i=0; i<5; i++){
+ values.put("key"+i, "value"+i);
+ }
+ }
+
+ @Before
+ public void before() throws Exception {
+ final Host host = Host.getHost(0);
+ this.client1 = host.getVM(1);
+ this.client2 = host.getVM(2);
+ this.client3 = host.getVM(3);
+
+ Properties props = new Properties();
+ props.setProperty(SampleSecurityManager.SECURITY_JSON, "com/gemstone/gemfire/management/internal/security/clientServer.json");
+ props.setProperty(SECURITY_MANAGER, SampleSecurityManager.class.getName());
+ props.setProperty(LOCATORS, "");
+ props.setProperty(MCAST_PORT, "0");
+ if (postProcessor!=null) {
+ props.setProperty(SECURITY_POST_PROCESSOR, postProcessor.getName());
+ }
+ props.setProperty(SECURITY_LOG_LEVEL, "finest");
+
+ props.setProperty("security-pdx", pdxPersistent+"");
+ if(jmxPort>0){
+ props.put(JMX_MANAGER, "true");
+ props.put(JMX_MANAGER_START, "true");
+ props.put(JMX_MANAGER_PORT, String.valueOf(jmxPort));
+ }
+
+ if(restPort>0){
+ props.setProperty(START_DEV_REST_API, "true");
+ props.setProperty(HTTP_SERVICE_BIND_ADDRESS, "localhost");
+ props.setProperty(HTTP_SERVICE_PORT, restPort+"");
+ }
+
+ getSystem(props);
+
+ CacheFactory cf = null;
+ cf = new CacheFactory();
+ cf.setPdxPersistent(pdxPersistent);
+ cf.setPdxReadSerialized(pdxPersistent);
+ Cache cache = getCache(cf);
+
+ Region region = cache.createRegionFactory(RegionShortcut.REPLICATE).create(REGION_NAME);
+
+ CacheServer server1 = cache.addCacheServer();
+ server1.setPort(0);
+ server1.start();
+
+ this.serverPort = server1.getPort();
+
+ for(Entry entry:values.entrySet()){
+ region.put(entry.getKey(), entry.getValue());
+ }
+ }
+
+ @Override
+ public void preTearDownCacheTestCase() throws Exception {
+ Invoke.invokeInEveryVM(()->closeCache());
+ closeCache();
+ }
+
+ public static void assertNotAuthorized(ThrowingCallable shouldRaiseThrowable, String permString) {
+ assertThatThrownBy(shouldRaiseThrowable).hasMessageContaining(permString);
+ }
+
+ protected Properties createClientProperties(String userName, String password) {
+ Properties props = new Properties();
+ props.setProperty(UserPasswordAuthInit.USER_NAME, userName);
+ props.setProperty(UserPasswordAuthInit.PASSWORD, password);
+ props.setProperty(LOCATORS, "");
+ props.setProperty(MCAST_PORT, "0");
+ props.setProperty(SECURITY_CLIENT_AUTH_INIT, UserPasswordAuthInit.class.getName() + ".create");
+ props.setProperty(SECURITY_LOG_LEVEL, "finest");
+ return props;
+ }
+
+ protected ClientCache createClientCache(String username, String password, int serverPort){
+ ClientCache cache = new ClientCacheFactory(createClientProperties(username, password))
+ .setPoolSubscriptionEnabled(true)
+ .addPoolServer("localhost", serverPort)
+ .create();
+
+ cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+ return cache;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
index e6e7f13..0f53cbc 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientAuthDUnitTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientAuthDUnitTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientAuthDUnitTest extends AbstractSecureServerDUnitTest {
@Test
public void authWithCorrectPasswordShouldPass() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
index 7aa958e..336cf87 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientContainsKeyAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientContainsKeyAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientContainsKeyAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testContainsKey() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyInvalidateAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyInvalidateAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyInvalidateAuthDistributedTest.java
index febc608..e811d86 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyInvalidateAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyInvalidateAuthDistributedTest.java
@@ -30,7 +30,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientDestroyInvalidateAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientDestroyInvalidateAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testDestroyInvalidate() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyRegionAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyRegionAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyRegionAuthDistributedTest.java
index 8f81c18..adb7c0b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyRegionAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientDestroyRegionAuthDistributedTest.java
@@ -29,7 +29,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientDestroyRegionAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientDestroyRegionAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testDestroyRegion() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteFunctionAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteFunctionAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteFunctionAuthDistributedTest.java
index 5af9f4c..bf4b027 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteFunctionAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteFunctionAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientExecuteFunctionAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientExecuteFunctionAuthDistributedTest extends AbstractSecureServerDUnitTest {
private final static Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteRegionFunctionAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteRegionFunctionAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteRegionFunctionAuthDistributedTest.java
index 3665f63..08425a0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteRegionFunctionAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientExecuteRegionFunctionAuthDistributedTest.java
@@ -29,7 +29,7 @@ import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
public class IntegratedClientExecuteRegionFunctionAuthDistributedTest
- extends AbstractIntegratedClientAuthDistributedTest {
+ extends AbstractSecureServerDUnitTest {
private final static Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
index 955f716..1931633 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientGetAllAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientGetAllAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testGetAll() {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPRMetaDataAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPRMetaDataAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPRMetaDataAuthDistributedTest.java
index 6a5f963..2f2a013 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPRMetaDataAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPRMetaDataAuthDistributedTest.java
@@ -32,7 +32,7 @@ import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
public class IntegratedClientGetClientPRMetaDataAuthDistributedTest
- extends AbstractIntegratedClientAuthDistributedTest {
+ extends AbstractSecureServerDUnitTest {
@Test
@Ignore("This is not a supported client message")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest.java
index 679eea6..b18ca98 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
public class IntegratedClientGetClientPartitionAttrCmdAuthDistributedTest
- extends AbstractIntegratedClientAuthDistributedTest {
+ extends AbstractSecureServerDUnitTest {
@Test
@Ignore("This is not a supported client message")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
index 746dbb1..656659e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetEntryAuthDistributedTest.java
@@ -29,7 +29,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientGetEntryAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientGetEntryAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testGetEntry() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetPutAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetPutAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetPutAuthDistributedTest.java
index 630e340..01509ad 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetPutAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetPutAuthDistributedTest.java
@@ -34,7 +34,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientGetPutAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientGetPutAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testGetPutAuthorization() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegionClearAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegionClearAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegionClearAuthDistributedTest.java
index 1e63f53..3c5a2ef 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegionClearAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegionClearAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientRegionClearAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientRegionClearAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testRegionClear() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegisterInterestAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegisterInterestAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegisterInterestAuthDistributedTest.java
index 0036a38..8e67ead 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegisterInterestAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRegisterInterestAuthDistributedTest.java
@@ -31,7 +31,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientRegisterInterestAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientRegisterInterestAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testRegisterInterest() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRemoveAllAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRemoveAllAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRemoveAllAuthDistributedTest.java
index 8eb4ebf..357ed98 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRemoveAllAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientRemoveAllAuthDistributedTest.java
@@ -32,7 +32,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientRemoveAllAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientRemoveAllAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testRemoveAll() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
index 6aa3d68..8ca6995 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientSizeAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientSizeAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientSizeAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
@Ignore("This is not a supported client message")
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientUnregisterInterestAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientUnregisterInterestAuthDistributedTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientUnregisterInterestAuthDistributedTest.java
index e6152ee..14edeb4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientUnregisterInterestAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientUnregisterInterestAuthDistributedTest.java
@@ -28,7 +28,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedClientUnregisterInterestAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class IntegratedClientUnregisterInterestAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testUnregisterInterest() throws InterruptedException {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
deleted file mode 100644
index ce090f1..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityNoShowValue1PostProcessorDUnitTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.security;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.Pool;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-
-@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedSecurityNoShowValue1PostProcessorDUnitTest extends AbstractIntegratedClientAuthDistributedTest {
-
- public IntegratedSecurityNoShowValue1PostProcessorDUnitTest(){
- this.postProcessor = NoShowValue1PostProcessor.class;
- }
-
- @Test
- public void testPostProcess(){
- List<String> keys = new ArrayList<>();
- keys.add("key1");
- keys.add("key2");
-
- client1.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- // post process for get
- assertEquals("value3", region.get("key3"));
-
- assertNull(region.get("key1"));
-
- // post processs for getAll
- Map values = region.getAll(keys);
- assertEquals(2, values.size());
- assertEquals("value2", values.get("key2"));
- assertNull(values.get("key1"));
-
- // post process for query
- String query = "select * from /AuthRegion";
- SelectResults result = region.query(query);
- System.out.println("query result: "+result);
- assertEquals(5, result.size());
- assertTrue(result.contains("value0"));
- assertFalse(result.contains("value1"));
- assertTrue(result.contains("value2"));
- assertTrue(result.contains("value3"));
- assertTrue(result.contains("value4"));
-
- Pool pool = PoolManager.find(region);
- result = (SelectResults)pool.getQueryService().newQuery(query).execute();
- System.out.println("query result: "+result);
- assertTrue(result.contains("value0"));
- assertFalse(result.contains("value1"));
- assertTrue(result.contains("value2"));
- assertTrue(result.contains("value3"));
- assertTrue(result.contains("value4"));
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
deleted file mode 100644
index b3fb16e..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedSecurityPostProcessorDUnitTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * 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.security;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.geode.security.templates.SamplePostProcessor;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import com.gemstone.gemfire.cache.EntryEvent;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
-import com.gemstone.gemfire.cache.client.Pool;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-
-@Category({ DistributedTest.class, SecurityTest.class })
-public class IntegratedSecurityPostProcessorDUnitTest extends AbstractIntegratedClientAuthDistributedTest {
-
- public IntegratedSecurityPostProcessorDUnitTest(){
- this.postProcessor = SamplePostProcessor.class;
- }
-
- @Test
- public void testPostProcessRegionGet(){
- List<String> keys = new ArrayList<>();
- keys.add("key1");
- keys.add("key2");
-
- client1.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- // post process for get
- Object value = region.get("key3");
- assertEquals("super-user/AuthRegion/key3/value3", value);
-
- // post processs for getAll
- Map values = region.getAll(keys);
- assertEquals(2, values.size());
- assertEquals("super-user/AuthRegion/key1/value1", values.get("key1"));
- assertEquals("super-user/AuthRegion/key2/value2", values.get("key2"));
- });
- }
-
- @Test
- public void testPostProcessQuery(){
- client1.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- // post process for query
- String query = "select * from /AuthRegion";
- SelectResults result = region.query(query);
- assertEquals(5, result.size());
-
- assertTrue(result.contains("super-user/null/null/value0"));
- assertTrue(result.contains("super-user/null/null/value1"));
- assertTrue(result.contains("super-user/null/null/value2"));
- assertTrue(result.contains("super-user/null/null/value3"));
- assertTrue(result.contains("super-user/null/null/value4"));
-
- Pool pool = PoolManager.find(region);
- result = (SelectResults)pool.getQueryService().newQuery(query).execute();
- assertTrue(result.contains("super-user/null/null/value0"));
- assertTrue(result.contains("super-user/null/null/value1"));
- assertTrue(result.contains("super-user/null/null/value2"));
- assertTrue(result.contains("super-user/null/null/value3"));
- assertTrue(result.contains("super-user/null/null/value4"));
- });
- }
-
- @Test
- public void testRegisterInterestPostProcess(){
- client1.invoke(()->{
- ClientCache cache = new ClientCacheFactory(createClientProperties("super-user", "1234567"))
- .setPoolSubscriptionEnabled(true)
- .addPoolServer("localhost", serverPort)
- .create();
-
- ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
- factory.addCacheListener(new CacheListenerAdapter() {
- @Override
- public void afterUpdate(EntryEvent event) {
- assertEquals("super-user/AuthRegion/key1/value2", event.getSerializedNewValue().getDeserializedValue());
- }
- });
-
- Region region = factory.create(REGION_NAME);
- region.put("key1", "value1");
- region.registerInterest("key1");
- });
-
- client2.invoke(()->{
- ClientCache cache = createClientCache("dataUser", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- region.put("key1", "value2");
- });
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessorDUnitTest.java
new file mode 100644
index 0000000..5d071a8
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/NoShowValue1PostProcessorDUnitTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.security;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+public class NoShowValue1PostProcessorDUnitTest extends AbstractSecureServerDUnitTest {
+
+ public NoShowValue1PostProcessorDUnitTest(){
+ this.postProcessor = NoShowValue1PostProcessor.class;
+ }
+
+ @Test
+ public void testPostProcess(){
+ List<String> keys = new ArrayList<>();
+ keys.add("key1");
+ keys.add("key2");
+
+ client1.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ // post process for get
+ assertEquals("value3", region.get("key3"));
+
+ assertNull(region.get("key1"));
+
+ // post processs for getAll
+ Map values = region.getAll(keys);
+ assertEquals(2, values.size());
+ assertEquals("value2", values.get("key2"));
+ assertNull(values.get("key1"));
+
+ // post process for query
+ String query = "select * from /AuthRegion";
+ SelectResults result = region.query(query);
+ System.out.println("query result: "+result);
+ assertEquals(5, result.size());
+ assertTrue(result.contains("value0"));
+ assertFalse(result.contains("value1"));
+ assertTrue(result.contains("value2"));
+ assertTrue(result.contains("value3"));
+ assertTrue(result.contains("value4"));
+
+ Pool pool = PoolManager.find(region);
+ result = (SelectResults)pool.getQueryService().newQuery(query).execute();
+ System.out.println("query result: "+result);
+ assertTrue(result.contains("value0"));
+ assertFalse(result.contains("value1"));
+ assertTrue(result.contains("value2"));
+ assertTrue(result.contains("value3"));
+ assertTrue(result.contains("value4"));
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessor.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessor.java b/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessor.java
new file mode 100644
index 0000000..7a93076
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessor.java
@@ -0,0 +1,45 @@
+package com.gemstone.gemfire.security;
+
+import static org.junit.Assert.assertTrue;
+
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Properties;
+
+import org.apache.geode.security.PostProcessor;
+
+import com.gemstone.gemfire.pdx.SimpleClass;
+import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl;
+
+public class PDXPostProcessor implements PostProcessor{
+ public static byte[] BYTES = {1,0};
+
+ private boolean pdx = false;
+ private int count = 0;
+
+ public void init(Properties props){
+ pdx = Boolean.parseBoolean(props.getProperty("security-pdx"));
+ count = 0;
+ }
+ @Override
+ public Object processRegionValue(final Principal principal,
+ final String regionName,
+ final Object key,
+ final Object value) {
+ count ++;
+ if(value instanceof byte[]){
+ assertTrue(Arrays.equals(BYTES, (byte[])value));
+ }
+ else if(pdx){
+ assertTrue(value instanceof PdxInstanceImpl);
+ }
+ else {
+ assertTrue(value instanceof SimpleClass);
+ }
+ return value;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
new file mode 100644
index 0000000..2a5727c
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
@@ -0,0 +1,233 @@
+/*
+ * 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.security;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.concurrent.TimeUnit;
+
+import com.jayway.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.cache.EntryEventImpl;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.management.cli.Result.Status;
+import com.gemstone.gemfire.management.internal.cli.CliUtil;
+import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
+import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
+import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
+import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
+import com.gemstone.gemfire.pdx.SimpleClass;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class PDXPostProcessorDUnitTest extends AbstractSecureServerDUnitTest {
+ private static byte[] BYTES = PDXPostProcessor.BYTES;
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> parameters(){
+ Object[][] params = {{true}, {false}};
+ return Arrays.asList(params);
+ }
+
+ public PDXPostProcessorDUnitTest(boolean pdxPersistent){
+ this.postProcessor = PDXPostProcessor.class;
+ this.pdxPersistent = pdxPersistent;
+ this.jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
+ values = new HashMap();
+ }
+
+ @Test
+ public void testRegionGet(){
+ client2.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ // put in a value that's a domain object
+ region.put("key1", new SimpleClass(1, (byte) 1));
+ // put in a byte value
+ region.put("key2", BYTES);
+ });
+
+ client1.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ // post process for get the client domain object
+ Object value = region.get("key1");
+ assertTrue(value instanceof SimpleClass);
+
+ // post process for get the raw byte value
+ value = region.get("key2");
+ assertTrue(Arrays.equals(BYTES, (byte[])value));
+ });
+
+ // this makes sure PostProcessor is getting called
+ PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
+ assertEquals(pp.getCount(), 2);
+ }
+
+ @Test
+ public void testQuery(){
+ client2.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ // put in a value that's a domain object
+ region.put("key1", new SimpleClass(1, (byte) 1));
+ region.put("key2", BYTES);
+ });
+
+ client1.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ // post process for query
+ String query = "select * from /AuthRegion";
+ SelectResults result = region.query(query);
+
+ Iterator itr = result.iterator();
+ while (itr.hasNext()) {
+ Object obj = itr.next();
+ if(obj instanceof byte[]){
+ assertTrue(Arrays.equals(BYTES, (byte[])obj));
+ }
+ else{
+ assertTrue(obj instanceof SimpleClass);
+ }
+ }
+ });
+
+ // this makes sure PostProcessor is getting called
+ PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
+ assertEquals(pp.getCount(), 2);
+ }
+
+ @Test
+ public void testRegisterInterest(){
+ client1.invoke(()->{
+ ClientCache cache = new ClientCacheFactory(createClientProperties("super-user", "1234567"))
+ .setPoolSubscriptionEnabled(true)
+ .addPoolServer("localhost", serverPort)
+ .create();
+
+ ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
+ factory.addCacheListener(new CacheListenerAdapter() {
+ @Override
+ public void afterUpdate(EntryEvent event) {
+ Object key = event.getKey();
+ Object value = ((EntryEventImpl) event).getDeserializedValue();
+ if(key.equals("key1")) {
+ assertTrue(value instanceof SimpleClass);
+ }
+ else if(key.equals("key2")){
+ assertTrue(Arrays.equals(BYTES, (byte[])value));
+ }
+ }
+ });
+
+ Region region = factory.create(REGION_NAME);
+ region.put("key1", "value1");
+ region.registerInterest("key1");
+ region.registerInterest("key2");
+ });
+
+ client2.invoke(()->{
+ ClientCache cache = createClientCache("dataUser", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ // put in a value that's a domain object
+ region.put("key1", new SimpleClass(1, (byte) 1));
+ region.put("key2", BYTES);
+ });
+
+ // wait for events to fire
+ Awaitility.await().atMost(1, TimeUnit.SECONDS);
+ PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
+ assertEquals(pp.getCount(), 2);
+ }
+
+ @Test
+ public void testGfshCommand(){
+ // have client2 input some domain data into the region
+ client2.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ // put in a value that's a domain object
+ region.put("key1", new SimpleClass(1, (byte) 1));
+ // put in a byte value
+ region.put("key2", BYTES);
+ });
+
+ client1.invoke(()->{
+ CliUtil.isGfshVM = true;
+ String shellId = getClass().getSimpleName();
+ HeadlessGfsh gfsh = new HeadlessGfsh(shellId, 30, "gfsh_files");
+
+ // connect to the jmx server
+ final CommandStringBuilder connectCommand = new CommandStringBuilder(CliStrings.CONNECT);
+ connectCommand.addOption(CliStrings.CONNECT__USERNAME, "dataUser");
+ connectCommand.addOption(CliStrings.CONNECT__PASSWORD, "1234567");
+
+ String endpoint = "localhost[" + jmxPort + "]";
+ connectCommand.addOption(CliStrings.CONNECT__JMX_MANAGER, endpoint);
+
+ gfsh.executeCommand(connectCommand.toString());
+ CommandResult result = (CommandResult) gfsh.getResult();
+
+ // get command
+ gfsh.executeCommand("get --key=key1 --region=AuthRegion");
+ result = (CommandResult) gfsh.getResult();
+ assertEquals(result.getStatus(), Status.OK);
+ if(pdxPersistent)
+ assertTrue(result.getContent().toString().contains("com.gemstone.gemfire.pdx.internal.PdxInstanceImpl"));
+ else
+ assertTrue(result.getContent().toString().contains("SimpleClass"));
+
+ gfsh.executeCommand("get --key=key2 --region=AuthRegion");
+ result = (CommandResult)gfsh.getResult();
+ assertEquals(result.getStatus(), Status.OK);
+ assertTrue(result.getContent().toString().contains("byte[]"));
+
+ gfsh.executeCommand("query --query=\"select * from /AuthRegion\"");
+ result = (CommandResult)gfsh.getResult();
+ System.out.println("gfsh result: " + result);
+ });
+
+ PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
+ assertEquals(pp.getCount(), 4);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-core/src/test/java/com/gemstone/gemfire/security/PostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/PostProcessorDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/PostProcessorDUnitTest.java
new file mode 100644
index 0000000..4a546e2
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/PostProcessorDUnitTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.security;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geode.security.templates.SamplePostProcessor;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.gemstone.gemfire.cache.EntryEvent;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+public class PostProcessorDUnitTest extends AbstractSecureServerDUnitTest {
+
+ public PostProcessorDUnitTest(){
+ this.postProcessor = SamplePostProcessor.class;
+ }
+
+ @Test
+ public void testPostProcessRegionGet(){
+ List<String> keys = new ArrayList<>();
+ keys.add("key1");
+ keys.add("key2");
+
+ client1.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ // post process for get
+ Object value = region.get("key3");
+ assertEquals("super-user/AuthRegion/key3/value3", value);
+
+ // post processs for getAll
+ Map values = region.getAll(keys);
+ assertEquals(2, values.size());
+ assertEquals("super-user/AuthRegion/key1/value1", values.get("key1"));
+ assertEquals("super-user/AuthRegion/key2/value2", values.get("key2"));
+ });
+ }
+
+ @Test
+ public void testPostProcessQuery(){
+ client1.invoke(()->{
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ // post process for query
+ String query = "select * from /AuthRegion";
+ SelectResults result = region.query(query);
+ assertEquals(5, result.size());
+
+ assertTrue(result.contains("super-user/null/null/value0"));
+ assertTrue(result.contains("super-user/null/null/value1"));
+ assertTrue(result.contains("super-user/null/null/value2"));
+ assertTrue(result.contains("super-user/null/null/value3"));
+ assertTrue(result.contains("super-user/null/null/value4"));
+
+ Pool pool = PoolManager.find(region);
+ result = (SelectResults)pool.getQueryService().newQuery(query).execute();
+ assertTrue(result.contains("super-user/null/null/value0"));
+ assertTrue(result.contains("super-user/null/null/value1"));
+ assertTrue(result.contains("super-user/null/null/value2"));
+ assertTrue(result.contains("super-user/null/null/value3"));
+ assertTrue(result.contains("super-user/null/null/value4"));
+ });
+ }
+
+ @Test
+ public void testRegisterInterestPostProcess(){
+ client1.invoke(()->{
+ ClientCache cache = new ClientCacheFactory(createClientProperties("super-user", "1234567"))
+ .setPoolSubscriptionEnabled(true)
+ .addPoolServer("localhost", serverPort)
+ .create();
+
+ ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
+ factory.addCacheListener(new CacheListenerAdapter() {
+ @Override
+ public void afterUpdate(EntryEvent event) {
+ assertEquals("super-user/AuthRegion/key1/value2", event.getSerializedNewValue().getDeserializedValue());
+ }
+ });
+
+ Region region = factory.create(REGION_NAME);
+ region.put("key1", "value1");
+ region.registerInterest("key1");
+ });
+
+ client2.invoke(()->{
+ ClientCache cache = createClientCache("dataUser", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ region.put("key1", "value2");
+ });
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPDXPostProcessorDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPDXPostProcessorDUnitTest.java
new file mode 100644
index 0000000..b6d520f
--- /dev/null
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPDXPostProcessorDUnitTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.security;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
+import com.jayway.awaitility.Awaitility;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.query.CqAttributes;
+import com.gemstone.gemfire.cache.query.CqAttributesFactory;
+import com.gemstone.gemfire.cache.query.CqEvent;
+import com.gemstone.gemfire.cache.query.CqQuery;
+import com.gemstone.gemfire.cache.query.CqResults;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.internal.cq.CqListenerImpl;
+import com.gemstone.gemfire.internal.AvailablePortHelper;
+import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
+import com.gemstone.gemfire.pdx.SimpleClass;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import com.gemstone.gemfire.test.junit.categories.SecurityTest;
+import com.gemstone.gemfire.test.junit.runners.CategoryWithParameterizedRunnerFactory;
+
+@Category({ DistributedTest.class, SecurityTest.class })
+@RunWith(Parameterized.class)
+@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
+public class CQPDXPostProcessorDUnitTest extends AbstractSecureServerDUnitTest {
+ private static byte[] BYTES = {1,0};
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> parameters(){
+ Object[][] params = {{true}, {false}};
+ return Arrays.asList(params);
+ }
+
+ public CQPDXPostProcessorDUnitTest(boolean pdxPersistent){
+ this.postProcessor = PDXPostProcessor.class;
+ this.pdxPersistent = pdxPersistent;
+ this.jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
+ values = new HashMap();
+ }
+
+ @Test
+ public void testCQ() {
+ String query = "select * from /AuthRegion";
+ client1.invoke(() -> {
+ ClientCache cache = createClientCache("super-user", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+
+ Pool pool = PoolManager.find(region);
+ QueryService qs = pool.getQueryService();
+
+ CqAttributesFactory factory = new CqAttributesFactory();
+
+ factory.addCqListener(new CqListenerImpl() {
+ @Override
+ public void onEvent(final CqEvent aCqEvent) {
+ Object key = aCqEvent.getKey();
+ Object value = aCqEvent.getNewValue();
+ if(key.equals("key1")) {
+ assertTrue(value instanceof SimpleClass);
+ }
+ else if(key.equals("key2")){
+ assertTrue(Arrays.equals(BYTES, (byte[])value));
+ }
+ }
+ });
+
+ CqAttributes cqa = factory.create();
+
+ // Create the CqQuery
+ CqQuery cq = qs.newCq("CQ1", query, cqa);
+ CqResults results = cq.executeWithInitialResults();
+ });
+
+ client2.invoke(() -> {
+ ClientCache cache = createClientCache("authRegionUser", "1234567", serverPort);
+ Region region = cache.getRegion(REGION_NAME);
+ region.put("key1", new SimpleClass(1, (byte) 1));
+ region.put("key2", BYTES);
+ });
+
+ // wait for events to fire
+ Awaitility.await().atMost(1, TimeUnit.SECONDS);
+ PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
+ assertEquals(pp.getCount(), 2);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPostProcessorDunitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPostProcessorDunitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPostProcessorDunitTest.java
index c099893..d95ffa4 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPostProcessorDunitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/CQPostProcessorDunitTest.java
@@ -38,7 +38,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class CQPostProcessorDunitTest extends AbstractIntegratedClientAuthDistributedTest {
+public class CQPostProcessorDunitTest extends AbstractSecureServerDUnitTest {
public CQPostProcessorDunitTest(){
this.postProcessor = SamplePostProcessor.class;
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientQueryAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientQueryAuthDistributedTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientQueryAuthDistributedTest.java
index 2cdef1b..67d131b 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientQueryAuthDistributedTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientQueryAuthDistributedTest.java
@@ -33,7 +33,7 @@ import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.categories.SecurityTest;
@Category({ DistributedTest.class, SecurityTest.class })
-public class ClientQueryAuthDistributedTest extends AbstractIntegratedClientAuthDistributedTest {
+public class ClientQueryAuthDistributedTest extends AbstractSecureServerDUnitTest {
@Test
public void testQuery(){
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/88247e32/geode-cq/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
deleted file mode 100644
index 671882e..0000000
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/PDXPostProcessorDUnitTest.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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.security;
-
-import static org.junit.Assert.*;
-
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-
-import com.jayway.awaitility.Awaitility;
-import org.apache.geode.security.PostProcessor;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import com.gemstone.gemfire.cache.EntryEvent;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
-import com.gemstone.gemfire.cache.client.Pool;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.query.CqAttributes;
-import com.gemstone.gemfire.cache.query.CqAttributesFactory;
-import com.gemstone.gemfire.cache.query.CqEvent;
-import com.gemstone.gemfire.cache.query.CqQuery;
-import com.gemstone.gemfire.cache.query.CqResults;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.query.internal.cq.CqListenerImpl;
-import com.gemstone.gemfire.cache.util.CacheListenerAdapter;
-import com.gemstone.gemfire.internal.AvailablePortHelper;
-import com.gemstone.gemfire.internal.cache.EntryEventImpl;
-import com.gemstone.gemfire.internal.security.GeodeSecurityUtil;
-import com.gemstone.gemfire.management.cli.Result.Status;
-import com.gemstone.gemfire.management.internal.cli.CliUtil;
-import com.gemstone.gemfire.management.internal.cli.HeadlessGfsh;
-import com.gemstone.gemfire.management.internal.cli.i18n.CliStrings;
-import com.gemstone.gemfire.management.internal.cli.result.CommandResult;
-import com.gemstone.gemfire.management.internal.cli.util.CommandStringBuilder;
-import com.gemstone.gemfire.pdx.SimpleClass;
-import com.gemstone.gemfire.pdx.internal.PdxInstanceImpl;
-import com.gemstone.gemfire.test.junit.categories.DistributedTest;
-import com.gemstone.gemfire.test.junit.categories.SecurityTest;
-import com.gemstone.gemfire.test.junit.runners.CategoryWithParameterizedRunnerFactory;
-
-@Category({ DistributedTest.class, SecurityTest.class })
-@RunWith(Parameterized.class)
-@Parameterized.UseParametersRunnerFactory(CategoryWithParameterizedRunnerFactory.class)
-public class PDXPostProcessorDUnitTest extends AbstractIntegratedClientAuthDistributedTest {
- private static byte[] BYTES = {1,0};
-
- @Parameterized.Parameters
- public static Collection<Object[]> parameters(){
- Object[][] params = {{true}, {false}};
- return Arrays.asList(params);
- }
-
- public PDXPostProcessorDUnitTest(boolean pdxPersistent){
- this.postProcessor = PDXPostProcessor.class;
- this.pdxPersistent = pdxPersistent;
- this.jmxPort = AvailablePortHelper.getRandomAvailableTCPPort();
- values = new HashMap();
- }
-
- @Test
- public void testRegionGet(){
- client2.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- // put in a value that's a domain object
- region.put("key1", new SimpleClass(1, (byte) 1));
- // put in a byte value
- region.put("key2", BYTES);
- });
-
- client1.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- // post process for get the client domain object
- Object value = region.get("key1");
- assertTrue(value instanceof SimpleClass);
-
- // post process for get the raw byte value
- value = region.get("key2");
- assertTrue(Arrays.equals(BYTES, (byte[])value));
- });
-
- // this makes sure PostProcessor is getting called
- PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
- assertEquals(pp.getCount(), 2);
- }
-
- @Test
- public void testQuery(){
- client2.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- // put in a value that's a domain object
- region.put("key1", new SimpleClass(1, (byte) 1));
- region.put("key2", BYTES);
- });
-
- client1.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- // post process for query
- String query = "select * from /AuthRegion";
- SelectResults result = region.query(query);
-
- Iterator itr = result.iterator();
- while (itr.hasNext()) {
- Object obj = itr.next();
- if(obj instanceof byte[]){
- assertTrue(Arrays.equals(BYTES, (byte[])obj));
- }
- else{
- assertTrue(obj instanceof SimpleClass);
- }
- }
- });
-
- // this makes sure PostProcessor is getting called
- PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
- assertEquals(pp.getCount(), 2);
- }
-
- @Test
- public void testRegisterInterest(){
- client1.invoke(()->{
- ClientCache cache = new ClientCacheFactory(createClientProperties("super-user", "1234567"))
- .setPoolSubscriptionEnabled(true)
- .addPoolServer("localhost", serverPort)
- .create();
-
- ClientRegionFactory factory = cache.createClientRegionFactory(ClientRegionShortcut.PROXY);
- factory.addCacheListener(new CacheListenerAdapter() {
- @Override
- public void afterUpdate(EntryEvent event) {
- Object key = event.getKey();
- Object value = ((EntryEventImpl) event).getDeserializedValue();
- if(key.equals("key1")) {
- assertTrue(value instanceof SimpleClass);
- }
- else if(key.equals("key2")){
- assertTrue(Arrays.equals(BYTES, (byte[])value));
- }
- }
- });
-
- Region region = factory.create(REGION_NAME);
- region.put("key1", "value1");
- region.registerInterest("key1");
- region.registerInterest("key2");
- });
-
- client2.invoke(()->{
- ClientCache cache = createClientCache("dataUser", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- // put in a value that's a domain object
- region.put("key1", new SimpleClass(1, (byte) 1));
- region.put("key2", BYTES);
- });
-
- // wait for events to fire
- Awaitility.await().atMost(1, TimeUnit.SECONDS);
- PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
- assertEquals(pp.getCount(), 2);
- }
-
- @Test
- public void testCQ() {
- String query = "select * from /AuthRegion";
- client1.invoke(() -> {
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
-
- Pool pool = PoolManager.find(region);
- QueryService qs = pool.getQueryService();
-
- CqAttributesFactory factory = new CqAttributesFactory();
-
- factory.addCqListener(new CqListenerImpl() {
- @Override
- public void onEvent(final CqEvent aCqEvent) {
- Object key = aCqEvent.getKey();
- Object value = aCqEvent.getNewValue();
- if(key.equals("key1")) {
- assertTrue(value instanceof SimpleClass);
- }
- else if(key.equals("key2")){
- assertTrue(Arrays.equals(BYTES, (byte[])value));
- }
- }
- });
-
- CqAttributes cqa = factory.create();
-
- // Create the CqQuery
- CqQuery cq = qs.newCq("CQ1", query, cqa);
- CqResults results = cq.executeWithInitialResults();
- });
-
- client2.invoke(() -> {
- ClientCache cache = createClientCache("authRegionUser", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- region.put("key1", new SimpleClass(1, (byte) 1));
- region.put("key2", BYTES);
- });
-
- // wait for events to fire
- Awaitility.await().atMost(1, TimeUnit.SECONDS);
- PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
- assertEquals(pp.getCount(), 2);
- }
-
- @Test
- public void testGfshCommand(){
- // have client2 input some domain data into the region
- client2.invoke(()->{
- ClientCache cache = createClientCache("super-user", "1234567", serverPort);
- Region region = cache.getRegion(REGION_NAME);
- // put in a value that's a domain object
- region.put("key1", new SimpleClass(1, (byte) 1));
- // put in a byte value
- region.put("key2", BYTES);
- });
-
- client1.invoke(()->{
- CliUtil.isGfshVM = true;
- String shellId = getClass().getSimpleName();
- HeadlessGfsh gfsh = new HeadlessGfsh(shellId, 30, "gfsh_files");
-
- // connect to the jmx server
- final CommandStringBuilder connectCommand = new CommandStringBuilder(CliStrings.CONNECT);
- connectCommand.addOption(CliStrings.CONNECT__USERNAME, "dataUser");
- connectCommand.addOption(CliStrings.CONNECT__PASSWORD, "1234567");
-
- String endpoint = "localhost[" + jmxPort + "]";
- connectCommand.addOption(CliStrings.CONNECT__JMX_MANAGER, endpoint);
-
- gfsh.executeCommand(connectCommand.toString());
- CommandResult result = (CommandResult) gfsh.getResult();
-
- // get command
- gfsh.executeCommand("get --key=key1 --region=AuthRegion");
- result = (CommandResult) gfsh.getResult();
- assertEquals(result.getStatus(), Status.OK);
- if(pdxPersistent)
- assertTrue(result.getContent().toString().contains("com.gemstone.gemfire.pdx.internal.PdxInstanceImpl"));
- else
- assertTrue(result.getContent().toString().contains("SimpleClass"));
-
- gfsh.executeCommand("get --key=key2 --region=AuthRegion");
- result = (CommandResult)gfsh.getResult();
- assertEquals(result.getStatus(), Status.OK);
- assertTrue(result.getContent().toString().contains("byte[]"));
-
- gfsh.executeCommand("query --query=\"select * from /AuthRegion\"");
- result = (CommandResult)gfsh.getResult();
- System.out.println("gfsh result: " + result);
- });
-
- PDXPostProcessor pp = (PDXPostProcessor) GeodeSecurityUtil.getPostProcessor();
- assertEquals(pp.getCount(), 4);
- }
-
- public static class PDXPostProcessor implements PostProcessor{
- private boolean pdx = false;
- private int count = 0;
-
- public void init(Properties props){
- pdx = Boolean.parseBoolean(props.getProperty("security-pdx"));
- count = 0;
- }
- @Override
- public Object processRegionValue(final Principal principal,
- final String regionName,
- final Object key,
- final Object value) {
- count ++;
- if(value instanceof byte[]){
- assertTrue(Arrays.equals(BYTES, (byte[])value));
- }
- else if(pdx){
- assertTrue(value instanceof PdxInstanceImpl);
- }
- else {
- assertTrue(value instanceof SimpleClass);
- }
- return value;
- }
-
- public int getCount(){
- return count;
- }
- }
-
-}