You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/29 21:12:56 UTC
[2/4] incubator-geode git commit: Cleanup
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5bc82d4/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index 50c1811..835c241 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@ -18,6 +18,11 @@
*/
package com.gemstone.gemfire.security;
+//import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
+//import static com.gemstone.gemfire.security.ClientAuthorizationTestBase.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
import java.util.Iterator;
import java.util.Properties;
@@ -29,7 +34,6 @@ import com.gemstone.gemfire.internal.cache.execute.PRClientServerTestBase;
import com.gemstone.gemfire.internal.cache.functions.TestFunction;
import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.VM;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import org.junit.Test;
@@ -40,13 +44,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
@Override
public final void preTearDownClientAuthorizationTestBase() throws Exception {
- // close the clients first
- client1.invoke(() -> SecurityTestUtil.closeCache());
- client2.invoke(() -> SecurityTestUtil.closeCache());
- SecurityTestUtil.closeCache();
- // then close the servers
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ closeCache();
}
/**
@@ -55,8 +53,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
*/
@Test
public void testOps1() throws Exception {
- Iterator iter = getDummyGeneratorCombos().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
CredentialGenerator cGen = gen.getCredentialGenerator();
Properties extraAuthProps = cGen.getSystemProperties();
@@ -66,127 +63,204 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
String authInit = cGen.getAuthInit();
String accessor = gen.getAuthorizationCallback();
- LogWriterUtils.getLogWriter().info("testOps1: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info(
- "testOps1: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testOps1: Using accessor: " + accessor);
+ getLogWriter().info("testOps1: Using authinit: " + authInit);
+ getLogWriter().info("testOps1: Using authenticator: " + authenticator);
+ getLogWriter().info("testOps1: Using accessor: " + accessor);
// Start servers with all required properties
- Properties serverProps = buildProperties(authenticator, accessor, false,
- extraAuthProps, extraAuthzProps);
+ Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
- Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
- Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
+ int port1 = createCacheServerOnVM(server1, javaProps, serverProps);
+ int port2 = createCacheServerOnVM(server2, javaProps, serverProps);
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
- OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
- port2)) {
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.PUT, OperationCode.PUT}, new OperationCode[] { OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1, port2)) {
continue;
}
+
verifyPutsGets();
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
- OperationCode.DESTROY, OperationCode.DESTROY},
- javaProps, authInit, port1, port2)) {
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] { OperationCode.DESTROY, OperationCode.DESTROY}, javaProps, authInit, port1, port2)) {
continue;
}
+
verifyContainsKeyDestroys();
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
- OperationCode.INVALIDATE, OperationCode.INVALIDATE},
- javaProps, authInit, port1, port2)) {
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] { OperationCode.INVALIDATE, OperationCode.INVALIDATE}, javaProps, authInit, port1, port2)) {
continue;
}
+
verifyContainsKeyInvalidates();
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.GET, OperationCode.GET}, new OperationCode[] {
- OperationCode.REGION_DESTROY, OperationCode.REGION_DESTROY},
- javaProps, authInit, port1, port2)) {
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.GET, OperationCode.GET}, new OperationCode[] { OperationCode.REGION_DESTROY, OperationCode.REGION_DESTROY}, javaProps, authInit, port1, port2)) {
continue;
}
+
verifyGetAllInTX();
verifyGetAllRegionDestroys();
}
}
- private boolean prepareClientsForOps(AuthzCredentialGenerator gen,
- CredentialGenerator cGen, OperationCode[] client1OpCodes,
- OperationCode[] client2OpCodes, Properties javaProps, String authInit,
- Integer port1, Integer port2) {
- return prepareClientsForOps(gen, cGen, client1OpCodes, client2OpCodes,
- javaProps, authInit, port1, port2, Boolean.TRUE /*
- * both clients in
- * multiuser mode
- */, Boolean.FALSE /* unused */);
+ /**
+ * Test query/function execute
+ */
+ @Test
+ public void testOps2() throws Exception {
+ AuthzCredentialGenerator gen = getXmlAuthzGenerator();
+ CredentialGenerator cGen = gen.getCredentialGenerator();
+ Properties extraAuthProps = cGen.getSystemProperties();
+ Properties javaProps = cGen.getJavaProperties();
+ Properties extraAuthzProps = gen.getSystemProperties();
+ String authenticator = cGen.getAuthenticator();
+ String authInit = cGen.getAuthInit();
+ String accessor = gen.getAuthorizationCallback();
+
+ getLogWriter().info("testOps2: Using authinit: " + authInit);
+ getLogWriter().info("testOps2: Using authenticator: " + authenticator);
+ getLogWriter().info("testOps2: Using accessor: " + accessor);
+
+ // Start servers with all required properties
+ Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
+
+ int port1 = createCacheServerOnVM(server1, javaProps, serverProps);
+ int port2 = createCacheServerOnVM(server2, javaProps, serverProps);
+
+ // Start client1 with valid/invalid QUERY credentials
+ Properties[] client1Credentials = new Properties[] {
+ gen.getAllowedCredentials(new OperationCode[] {OperationCode.PUT, OperationCode.QUERY}, new String[] {regionName}, 1),
+ gen.getDisallowedCredentials(new OperationCode[] {OperationCode.PUT, OperationCode.QUERY}, new String[] {regionName}, 1)
+ };
+
+ javaProps = cGen.getJavaProperties();
+ getLogWriter().info("testOps2: For first client credentials: " + client1Credentials[0] + "\n" + client1Credentials[1]);
+
+ final Properties finalJavaProps = javaProps;
+ client1.invoke(() -> createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, NO_EXCEPTION));
+
+ // Start client2 with valid/invalid EXECUTE_FUNCTION credentials
+ Properties[] client2Credentials = new Properties[] {
+ gen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION}, new String[] {regionName}, 2),
+ gen.getDisallowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION}, new String[] {regionName}, 9)
+ };
+
+ javaProps = cGen.getJavaProperties();
+ getLogWriter().info("testOps2: For second client credentials: " + client2Credentials[0] + "\n" + client2Credentials[1]);
+
+ final Properties finalJavaProps2 = javaProps;
+ client2.invoke(() -> createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, NO_EXCEPTION));
+
+ Function function = new TestFunction(true,TestFunction.TEST_FUNCTION1);
+
+ server1.invoke(() -> PRClientServerTestBase.registerFunction(function));
+
+ server2.invoke(() -> PRClientServerTestBase.registerFunction(function));
+
+ // Perform some put operations before verifying queries
+ client1.invoke(() -> doMultiUserPuts(4, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+ client1.invoke(() -> doMultiUserQueries(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+ client1.invoke(() -> doMultiUserQueryExecute(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+
+ // Verify that the FE succeeds/fails
+ client2.invoke(() ->doMultiUserFE(2, function, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, false));
+
+ // Failover
+ server1.invoke(() -> closeCache());
+ Thread.sleep(2000);
+
+ client1.invoke(() -> doMultiUserPuts(4, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+
+ client1.invoke(() -> doMultiUserQueries(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+ client1.invoke(() -> doMultiUserQueryExecute(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+
+ // Verify that the FE succeeds/fails
+ client2.invoke(() -> doMultiUserFE(2, function, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, true));
+ }
+
+ @Test
+ public void testOpsWithClientsInDifferentModes() throws Exception {
+ for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
+ AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+ CredentialGenerator cGen = gen.getCredentialGenerator();
+ Properties extraAuthProps = cGen.getSystemProperties();
+ Properties javaProps = cGen.getJavaProperties();
+ Properties extraAuthzProps = gen.getSystemProperties();
+ String authenticator = cGen.getAuthenticator();
+ String authInit = cGen.getAuthInit();
+ String accessor = gen.getAuthorizationCallback();
+
+ getLogWriter().info("testOpsWithClientsInDifferentModes: Using authinit: " + authInit);
+ getLogWriter().info("testOpsWithClientsInDifferentModes: Using authenticator: " + authenticator);
+ getLogWriter().info("testOpsWithClientsInDifferentModes: Using accessor: " + accessor);
+
+ // Start servers with all required properties
+ Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
+
+ int port1 = createCacheServerOnVM(server1, javaProps, serverProps);
+ int port2 = createCacheServerOnVM(server2, javaProps, serverProps);
+
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.PUT, OperationCode.PUT}, new OperationCode[] { OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1, port2, false, true)) {
+ continue;
+ }
+
+ verifyPutsGets(false, true);
+
+ if (!prepareClientsForOps(gen, cGen, new OperationCode[] { OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] { OperationCode.DESTROY, OperationCode.DESTROY}, javaProps, authInit, port1, port2, false, false)) {
+ continue;
+ }
+
+ verifyContainsKeyDestroys(false, false);
+ }
}
- private boolean prepareClientsForOps(AuthzCredentialGenerator gen,
- CredentialGenerator cGen, OperationCode[] client1OpCodes,
- OperationCode[] client2OpCodes, Properties javaProps, String authInit,
- Integer port1, Integer port2, Boolean bothClientsInMultiuserMode,
- Boolean allowOp) {
+ private boolean prepareClientsForOps(final AuthzCredentialGenerator gen, final CredentialGenerator cGen, final OperationCode[] client1OpCodes, final OperationCode[] client2OpCodes, final Properties javaProps, final String authInit, final int port1, final int port2) {
+ return prepareClientsForOps(gen, cGen, client1OpCodes, client2OpCodes, javaProps, authInit, port1, port2, true /* both clients in multiuser mode */, false /* unused */);
+ }
+
+ private boolean prepareClientsForOps(final AuthzCredentialGenerator gen, final CredentialGenerator cGen, final OperationCode[] client1OpCodes, final OperationCode[] client2OpCodes, Properties javaProps, final String authInit, final int port1, final int port2, final boolean bothClientsInMultiuserMode, final boolean allowOp) {
// Start client1 with valid/invalid client1OpCodes credentials
- Properties[] client1Credentials = new Properties[] {
- gen.getAllowedCredentials(client1OpCodes, new String[] {regionName}, 1),
- gen.getDisallowedCredentials(new OperationCode[] {client1OpCodes[1]},
- new String[] {regionName}, 1)};
+ Properties[] client1Credentials = new Properties[] { gen.getAllowedCredentials(client1OpCodes, new String[] {regionName}, 1), gen.getDisallowedCredentials(new OperationCode[] {client1OpCodes[1]}, new String[] {regionName}, 1)};
+
if (client1Credentials[0] == null || client1Credentials[0].size() == 0) {
- LogWriterUtils.getLogWriter().info(
- "testOps1: Unable to obtain valid credentials with "
- + client1OpCodes[0].toString()
- + " permission; skipping this combination.");
+ getLogWriter().info("testOps1: Unable to obtain valid credentials with " + client1OpCodes[0].toString() + " permission; skipping this combination.");
return false;
}
+
if (client1Credentials[1] == null || client1Credentials[1].size() == 0) {
- LogWriterUtils.getLogWriter().info(
- "testOps1: Unable to obtain valid credentials with no "
- + client1OpCodes[0].toString()
- + " permission; skipping this combination.");
+ getLogWriter().info("testOps1: Unable to obtain valid credentials with no " + client1OpCodes[0].toString() + " permission; skipping this combination.");
return false;
}
+
javaProps = cGen.getJavaProperties();
- LogWriterUtils.getLogWriter().info(
- "testOps1: For first client credentials: " + client1Credentials[0]
- + "\n" + client1Credentials[1]);
+ getLogWriter().info("testOps1: For first client credentials: " + client1Credentials[0] + "\n" + client1Credentials[1]);
final Properties finalJavaProps = javaProps;
- client1.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
+
+ client1.invoke(() -> createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, NO_EXCEPTION));
// Start client2 with valid/invalid client2OpCodes credentials
- Properties[] client2Credentials = new Properties[] {
- gen.getAllowedCredentials(client2OpCodes,
- new String[] {regionName}, 2),
- gen.getDisallowedCredentials(client2OpCodes,
- new String[] {regionName}, 9)};
+ Properties[] client2Credentials = new Properties[] { gen.getAllowedCredentials(client2OpCodes, new String[] {regionName}, 2), gen.getDisallowedCredentials(client2OpCodes, new String[] {regionName}, 9)};
+
if (client2Credentials[0] == null || client2Credentials[0].size() == 0) {
- LogWriterUtils.getLogWriter().info(
- "testOps1: Unable to obtain valid credentials with "
- + client2OpCodes[0].toString()
- + " permission; skipping this combination.");
+ getLogWriter().info("testOps1: Unable to obtain valid credentials with " + client2OpCodes[0].toString() + " permission; skipping this combination.");
return false;
}
+
if (client2Credentials[1] == null || client2Credentials[1].size() == 0) {
- LogWriterUtils.getLogWriter().info(
- "testOps1: Unable to obtain valid credentials with no "
- + client2OpCodes[0].toString()
- + " permission; skipping this combination.");
+ getLogWriter().info("testOps1: Unable to obtain valid credentials with no " + client2OpCodes[0].toString() + " permission; skipping this combination.");
return false;
}
+
javaProps = cGen.getJavaProperties();
- LogWriterUtils.getLogWriter().info(
- "testOps1: For second client credentials: " + client2Credentials[0]
- + "\n" + client2Credentials[1]);
+ getLogWriter().info("testOps1: For second client credentials: " + client2Credentials[0] + "\n" + client2Credentials[1]);
+
if (bothClientsInMultiuserMode) {
final Properties finalJavaProps2 = javaProps;
- client2.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
+ client2.invoke(() -> createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, NO_EXCEPTION));
+
} else {
int credentialsIndex = allowOp ? 0 : 1;
final Properties finalJavaProps2 = javaProps;
- client2.invoke(() -> SecurityTestUtil.createCacheClient(authInit, client2Credentials[credentialsIndex], finalJavaProps2, new int[] {port1, port2}, -1, false, false, SecurityTestUtil.NO_EXCEPTION));
+ client2.invoke(() -> createCacheClient(authInit, client2Credentials[credentialsIndex], finalJavaProps2, new int[] {port1, port2}, -1, false, false, NO_EXCEPTION));
}
+
return true;
}
@@ -194,18 +268,17 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
verifyPutsGets(true, false /*unused */);
}
- private void verifyPutsGets(Boolean isMultiuser, Boolean opAllowed)
- throws Exception {
+ private void verifyPutsGets(final boolean isMultiuser, final boolean opAllowed) throws Exception {
// Perform some put operations from client1
- client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] { SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] { NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
// Verify that the gets succeed/fail
if (isMultiuser) {
- client2.invoke(() -> SecurityTestUtil.doMultiUserGets(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ client2.invoke(() -> doMultiUserGets(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+
} else {
- int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
- : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
- client2.invoke(() -> SecurityTestUtil.doMultiUserGets(1, 1, new Integer[] {expectedResult}));
+ int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
+ client2.invoke(() -> doMultiUserGets(1, 1, new Integer[] {expectedResult}));
}
}
@@ -213,19 +286,18 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
verifyContainsKeyDestroys(true, false /* unused */);
}
- private void verifyContainsKeyDestroys(Boolean isMultiuser, Boolean opAllowed)
- throws Exception {
+ private void verifyContainsKeyDestroys(final boolean isMultiuser, final boolean opAllowed) throws Exception {
// Do puts before verifying containsKey
- client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NO_EXCEPTION}));
- client1.invoke(() -> SecurityTestUtil.doMultiUserContainsKeys(1, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Boolean[] {Boolean.TRUE, Boolean.FALSE}));
+ client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] {NO_EXCEPTION, NO_EXCEPTION}));
+ client1.invoke(() -> doMultiUserContainsKeys(1, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Boolean[] {true, false}));
// Verify that the destroys succeed/fail
if (isMultiuser) {
- client2.invoke(() -> SecurityTestUtil.doMultiUserDestroys(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ client2.invoke(() -> doMultiUserDestroys(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+
} else {
- int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
- : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
- client2.invoke(() -> SecurityTestUtil.doMultiUserDestroys(1, 1, new Integer[] {expectedResult}));
+ int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
+ client2.invoke(() -> doMultiUserDestroys(1, 1, new Integer[] {expectedResult}));
}
}
@@ -233,167 +305,41 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
verifyContainsKeyInvalidates(true, false /* unused */);
}
- private void verifyContainsKeyInvalidates(Boolean isMultiuser, Boolean opAllowed)
- throws Exception {
+ private void verifyContainsKeyInvalidates(final boolean isMultiuser, final boolean opAllowed) throws Exception {
// Do puts before verifying containsKey
- client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NO_EXCEPTION}));
- client1.invoke(() -> SecurityTestUtil.doMultiUserContainsKeys(1, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Boolean[] {Boolean.TRUE, Boolean.FALSE}));
+ client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] {NO_EXCEPTION, NO_EXCEPTION}));
+ client1.invoke(() -> doMultiUserContainsKeys(1, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Boolean[] {true, false}));
// Verify that the invalidates succeed/fail
if (isMultiuser) {
- client2.invoke(() -> SecurityTestUtil.doMultiUserInvalidates(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ client2.invoke(() -> doMultiUserInvalidates(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+
} else {
- int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
- : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
- client2.invoke(() -> SecurityTestUtil.doMultiUserInvalidates(1, 1, new Integer[] {expectedResult}));
+ int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
+ client2.invoke(() -> doMultiUserInvalidates(1, 1, new Integer[] {expectedResult}));
}
}
private void verifyGetAllInTX() {
- server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
- client1.invoke(() -> SecurityTestUtil.doMultiUserGetAll(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Boolean.TRUE/*use TX*/));
+ server1.invoke(() -> doPuts());
+ client1.invoke(() -> doMultiUserGetAll(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, true/*use TX*/));
}
private void verifyGetAllRegionDestroys() {
- server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
- client1.invoke(() -> SecurityTestUtil.doMultiUserGetAll(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ server1.invoke(() -> doPuts());
+ client1.invoke(() -> doMultiUserGetAll(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
// Verify that the region destroys succeed/fail
- client2.invoke(() -> SecurityTestUtil.doMultiUserRegionDestroys(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+ client2.invoke(() -> doMultiUserRegionDestroys(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
}
- public static void doPuts() {
- Region region = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
+ private void doPuts() {
+ Region region = GemFireCacheImpl.getInstance().getRegion(REGION_NAME);
region.put("key1", "value1");
region.put("key2", "value2");
}
- /**
- * Test query/function execute
- */
- @Test
- public void testOps2() throws Exception {
- AuthzCredentialGenerator gen = getXmlAuthzGenerator();
- CredentialGenerator cGen = gen.getCredentialGenerator();
- Properties extraAuthProps = cGen.getSystemProperties();
- Properties javaProps = cGen.getJavaProperties();
- Properties extraAuthzProps = gen.getSystemProperties();
- String authenticator = cGen.getAuthenticator();
- String authInit = cGen.getAuthInit();
- String accessor = gen.getAuthorizationCallback();
-
- LogWriterUtils.getLogWriter().info("testOps2: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info("testOps2: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testOps2: Using accessor: " + accessor);
-
- // Start servers with all required properties
- Properties serverProps = buildProperties(authenticator, accessor, false,
- extraAuthProps, extraAuthzProps);
- Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
- Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
-
- // Start client1 with valid/invalid QUERY credentials
- Properties[] client1Credentials = new Properties[] {
- gen.getAllowedCredentials(
- new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
- new String[] {regionName},
- 1),
- gen.getDisallowedCredentials(
- new OperationCode[] {OperationCode.PUT, OperationCode.QUERY},
- new String[] {regionName},
- 1)
- };
-
- javaProps = cGen.getJavaProperties();
- LogWriterUtils.getLogWriter().info(
- "testOps2: For first client credentials: " + client1Credentials[0]
- + "\n" + client1Credentials[1]);
- final Properties finalJavaProps = javaProps;
- client1.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
-
- // Start client2 with valid/invalid EXECUTE_FUNCTION credentials
- Properties[] client2Credentials = new Properties[] {
- gen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
- new String[] {regionName}, 2),
- gen.getDisallowedCredentials(new OperationCode[] {OperationCode.EXECUTE_FUNCTION},
- new String[] {regionName}, 9)};
-
- javaProps = cGen.getJavaProperties();
- LogWriterUtils.getLogWriter().info(
- "testOps2: For second client credentials: " + client2Credentials[0]
- + "\n" + client2Credentials[1]);
- final Properties finalJavaProps2 = javaProps;
- client2.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
-
- Function function = new TestFunction(true,TestFunction.TEST_FUNCTION1);
- server1.invoke(() -> PRClientServerTestBase.registerFunction(function));
-
- server2.invoke(() -> PRClientServerTestBase.registerFunction(function));
-
- // Perform some put operations before verifying queries
- client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(4, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
- client1.invoke(() -> SecurityTestUtil.doMultiUserQueries(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
- client1.invoke(() -> SecurityTestUtil.doMultiUserQueryExecute(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
-
- // Verify that the FE succeeds/fails
- client2.invoke(() ->SecurityTestUtil.doMultiUserFE(2, function, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, false));
-
- // Failover
- server1.invoke(() -> SecurityTestUtil.closeCache());
- Thread.sleep(2000);
-
- client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(4, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
-
- client1.invoke(() -> SecurityTestUtil.doMultiUserQueries(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
- client1.invoke(() -> SecurityTestUtil.doMultiUserQueryExecute(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
-
- // Verify that the FE succeeds/fails
- client2.invoke(() -> SecurityTestUtil.doMultiUserFE(2, function, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, true));
- }
-
- protected Integer createCacheServerOnVM(VM server, Properties javaProps, Properties serverProps) {
- return server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), serverProps, javaProps));
-
- }
-
- public void testOpsWithClientsInDifferentModes() throws Exception {
- Iterator iter = getDummyGeneratorCombos().iterator();
- while (iter.hasNext()) {
- AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
- CredentialGenerator cGen = gen.getCredentialGenerator();
- Properties extraAuthProps = cGen.getSystemProperties();
- Properties javaProps = cGen.getJavaProperties();
- Properties extraAuthzProps = gen.getSystemProperties();
- String authenticator = cGen.getAuthenticator();
- String authInit = cGen.getAuthInit();
- String accessor = gen.getAuthorizationCallback();
-
- LogWriterUtils.getLogWriter().info("testOpsWithClientsInDifferentModes: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info(
- "testOpsWithClientsInDifferentModes: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testOpsWithClientsInDifferentModes: Using accessor: " + accessor);
-
- // Start servers with all required properties
- Properties serverProps = buildProperties(authenticator, accessor, false,
- extraAuthProps, extraAuthzProps);
- Integer port1 = createCacheServerOnVM(server1, javaProps, serverProps);
- Integer port2 = createCacheServerOnVM(server2, javaProps, serverProps);
-
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.PUT, OperationCode.PUT}, new OperationCode[] {
- OperationCode.GET, OperationCode.GET}, javaProps, authInit, port1,
- port2, Boolean.FALSE, Boolean.TRUE)) {
- continue;
- }
- verifyPutsGets(false, true);
-
- if (!prepareClientsForOps(gen, cGen, new OperationCode[] {
- OperationCode.PUT, OperationCode.CONTAINS_KEY}, new OperationCode[] {
- OperationCode.DESTROY, OperationCode.DESTROY},
- javaProps, authInit, port1, port2, Boolean.FALSE, Boolean.FALSE)) {
- continue;
- }
- verifyContainsKeyDestroys(false, false);
- }
+ private int createCacheServerOnVM(final VM server, final Properties javaProps, final Properties serverProps) {
+ return server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5bc82d4/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
index 708140c..58e05a0 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
@@ -18,6 +18,8 @@
*/
package com.gemstone.gemfire.security;
+import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
+import static com.gemstone.gemfire.security.ClientAuthorizationTestBase.*;
import static com.gemstone.gemfire.security.SecurityTestUtil.*;
import static com.gemstone.gemfire.test.dunit.Assert.*;
import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
@@ -72,19 +74,21 @@ public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorization
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
- Integer port1 = createServer1(javaProps, serverProps);
- Integer port2 = createServer2(javaProps, serverProps);
+ int port1 = createServer1(javaProps, serverProps);
+ int port2 = createServer2(javaProps, serverProps);
// Start client1 with valid CREATE credentials
Properties createCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.PUT }, new String[] { REGION_NAME }, 1);
javaProps = cGen.getJavaProperties();
getLogWriter().info("testAllowPutsGets: For first client credentials: " + createCredentials);
+
createClient1(javaProps, authInit, port1, port2, createCredentials);
// Start client2 with valid GET credentials
Properties getCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.GET }, new String[] { REGION_NAME }, 2);
javaProps = cGen.getJavaProperties();
+
getLogWriter().info("testAllowPutsGets: For second client credentials: " + getCredentials);
createClient2(javaProps, authInit, port1, port2, getCredentials);
@@ -99,23 +103,23 @@ public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorization
client2.invoke(() -> doGets(2, NO_EXCEPTION));
}
- private void createClient2(Properties javaProps, String authInit, int port1, int port2, Properties getCredentials) {
- client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
+ private void createClient2(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties getCredentials) {
+ client2.invoke(() -> createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
}
- private void createClient1(Properties javaProps, String authInit, int port1, int port2, Properties createCredentials) {
- client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
+ private void createClient1(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties createCredentials) {
+ client1.invoke(() -> createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
}
- private Integer createServer2(Properties javaProps, Properties serverProps) {
- return server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+ private int createServer2(final Properties javaProps, final Properties serverProps) {
+ return server2.invoke(() -> createCacheServer(getLocatorPort(), serverProps, javaProps));
}
- private Integer createServer1(Properties javaProps, Properties serverProps) {
- return server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+ private int createServer1(final Properties javaProps, final Properties serverProps) {
+ return server1.invoke(() -> createCacheServer(getLocatorPort(), serverProps, javaProps));
}
- private void doPuts(int num, int expectedResult) {
+ private void doPuts(final int num, final int expectedResult) {
assertTrue(num <= KEYS.length);
Region region = getCache().getRegion(REGION_NAME);
assertNotNull(region);
@@ -130,10 +134,10 @@ public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorization
}
}
- private void doGets(int num, int expectedResult) {
+ private void doGets(final int num, final int expectedResult) {
assertTrue(num <= KEYS.length);
- Region region = SecurityTestUtil.getCache().getRegion(REGION_NAME);
+ Region region = getCache().getRegion(REGION_NAME);
assertNotNull(region);
for (int index = 0; index < num; ++index) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5bc82d4/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
index b838957..7c7fe9b 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
@@ -19,6 +19,7 @@
package com.gemstone.gemfire.security;
import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.DeltaClientPostAuthorizationDUnitTest.*;
import static com.gemstone.gemfire.security.SecurityTestUtil.*;
import static com.gemstone.gemfire.test.dunit.Assert.*;
import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
@@ -27,19 +28,12 @@ import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.Random;
import com.gemstone.gemfire.DeltaTestImpl;
-import com.gemstone.gemfire.cache.InterestResultPolicy;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.ServerConnectivityException;
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.cache.query.CqException;
-import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest;
-import com.gemstone.gemfire.internal.util.Callable;
import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.CredentialGenerator;
import com.gemstone.gemfire.test.dunit.VM;
@@ -66,7 +60,7 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
@Override
public final void preTearDownClientAuthorizationTestBase() throws Exception {
- SecurityTestUtil.closeCache();
+ closeCache();
}
@Test
@@ -106,15 +100,15 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
// End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
- server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+ server2.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
- server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
- server1.invoke(() -> SecurityTestUtil.closeCache());
+ server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+ server1.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
}
@@ -180,26 +174,26 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
credentialsTypeStr = " authorized " + authOpCode;
}
- Properties clientProps = SecurityTestUtil.concatProperties(new Properties[] { opCredentials, extraAuthProps, extraAuthzProps });
+ Properties clientProps = concatProperties(new Properties[] { opCredentials, extraAuthProps, extraAuthzProps });
// Start the client with valid credentials but allowed or disallowed to perform an operation
getLogWriter().info("executeOpBlock: For client" + clientNum + credentialsTypeStr + " credentials: " + opCredentials);
boolean setupDynamicRegionFactory = (opFlags & OpFlags.ENABLE_DRF) > 0;
if (useThisVM) {
- createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, SecurityTestUtil.NO_EXCEPTION);
+ createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION);
} else {
- clientVM.invoke(() -> createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, SecurityTestUtil.NO_EXCEPTION));
+ clientVM.invoke(() -> createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
}
}
int expectedResult;
if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) {
- expectedResult = SecurityTestUtil.NOTAUTHZ_EXCEPTION;
+ expectedResult = NOTAUTHZ_EXCEPTION;
} else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) {
- expectedResult = SecurityTestUtil.OTHER_EXCEPTION;
+ expectedResult = OTHER_EXCEPTION;
} else {
- expectedResult = SecurityTestUtil.NO_EXCEPTION;
+ expectedResult = NO_EXCEPTION;
}
// Perform the operation from selected client
@@ -208,15 +202,14 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
} else {
byte ordinal = opCode.toOrdinal();
int[] indices = currentOp.getIndices();
- clientVM.invoke(() -> DeltaClientPostAuthorizationDUnitTest.doOp(new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
+ clientVM.invoke(() -> doOp(new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
}
}
}
- private final void setUpDeltas() {
+ private void setUpDeltas() {
for (int i = 0; i < 8; i++) {
- deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
- new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("0", 0));
+ deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("0", 0));
}
deltas[1].setIntVar(5);
deltas[2].setIntVar(5);
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/c5bc82d4/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index ba6b26f..e514b1c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -58,9 +58,6 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
private static VM locatorVM = null;
- private static final String USER_NAME = "security-username";
- private static final String PASSWORD = "security-password";
-
private static final String[] ignoredExceptions = {
AuthenticationRequiredException.class.getName(),
AuthenticationFailedException.class.getName(),
@@ -160,7 +157,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, "Incorrect_AuthInitialize");
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
- startLocator(props, gen.getJavaProperties(), locatorPort);
+ startTheLocator(props, gen.getJavaProperties(), locatorPort);
try {
new SecurityTestUtil("tmp").createSystem(props, null);
@@ -191,7 +188,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, "xyz");
- startLocator(props, null, locatorPort);
+ startTheLocator(props, null, locatorPort);
try {
new SecurityTestUtil("tmp").createSystem(props, null);
@@ -201,7 +198,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
// success
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
@@ -221,7 +218,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
- startLocator(props, null, locatorPort);
+ startTheLocator(props, null, locatorPort);
try {
new SecurityTestUtil("tmp").createSystem(props, null);
@@ -231,7 +228,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
// success
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
@@ -253,7 +250,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
props.putAll(gen.getValidCredentials(1));
- startLocator(props, gen.getJavaProperties(), locatorPort);
+ startTheLocator(props, gen.getJavaProperties(), locatorPort);
try {
createDS(props, gen.getJavaProperties());
@@ -261,7 +258,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
disconnectFromDS();
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
@@ -287,7 +284,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
props.putAll(gen.getValidCredentials(1));
- startLocator(props, null, locatorPort);
+ startTheLocator(props, null, locatorPort);
try {
// invalid credentials for the peer
@@ -308,7 +305,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
disconnectFromDS();
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
@@ -361,7 +358,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.putAll(credentials);
props.putAll(extraProps);
- startLocator(props, javaProps, port);
+ startTheLocator(props, javaProps, port);
try {
@@ -399,34 +396,34 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
pause(2000);
// Verify the number of members on all peers and locator
- locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
+ locatorVM.invoke(() -> verifyMembers(4));
verifyMembers(2);
- peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
- peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
+ peer2.invoke(() -> verifyMembers(4));
+ peer3.invoke(() -> verifyMembers(4));
// Disconnect the first peer and check again
disconnectFromDS();
pause(2000);
- locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
- peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
- peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
+ locatorVM.invoke(() -> verifyMembers(3));
+ peer2.invoke(() -> verifyMembers(3));
+ peer3.invoke(() -> verifyMembers(3));
// Disconnect the second peer and check again
peer2.invoke(() -> disconnectFromDS());
pause(2000);
- locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(2));
- peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(2));
+ locatorVM.invoke(() -> verifyMembers(2));
+ peer3.invoke(() -> verifyMembers(2));
// Same for last peer
peer3.invoke(() -> disconnectFromDS());
pause(2000);
- locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(1));
+ locatorVM.invoke(() -> verifyMembers(1));
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(port, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(port, ignoredExceptions));
}
}
@@ -461,7 +458,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
props.putAll(credentials);
- startLocator(props, null, locatorPort);
+ startTheLocator(props, null, locatorPort);
try {
// Start the first peer with huge credentials
@@ -514,24 +511,24 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
peer3.invoke(() -> disconnectFromDS());
} finally {
- locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
+ locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
- private void createDS(VM peer2, Properties props, Properties javaProps) {
+ private void createDS(final VM peer2, final Properties props, final Properties javaProps) {
peer2.invoke(() -> createDS(props, javaProps));
}
- private void startLocator(Properties props, Properties javaProps, int port) {
- locatorVM.invoke(() -> SecurityTestUtil.startLocator(getUniqueName(), port, props, javaProps, ignoredExceptions));
+ private void startTheLocator(final Properties props, final Properties javaProps, final int port) {
+ locatorVM.invoke(() -> startLocator(getUniqueName(), port, props, javaProps, ignoredExceptions));
}
- private static void createDS(Properties props, Properties javaProps) {
+ private static void createDS(final Properties props, final Properties javaProps) {
SecurityTestUtil tmpUtil = new SecurityTestUtil("tmp");
tmpUtil.createSystem(props, javaProps);
}
- private static void verifyMembers(int numExpectedMembers) {
+ private static void verifyMembers(final int numExpectedMembers) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
MembershipManager mgr = MembershipManagerHelper.getMembershipManager(ds);
assertEquals(numExpectedMembers, mgr.getView().size());