use of org.apache.geode.security.SecurityTestUtils in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithInvalidAuthInitialize.
/**
* AuthInitialize is incorrect
*/
@Test
public void testP2PAuthenticationWithInvalidAuthInitialize() throws Exception {
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthenticator());
assertNull(gen.getJavaProperties());
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, "Incorrect_AuthInitialize");
props.setProperty(SECURITY_PEER_AUTHENTICATOR, gen.getAuthenticator());
startTheLocator(props, gen.getJavaProperties(), locatorPort);
try {
new SecurityTestUtils("tmp").createSystem(props, null);
fail("AuthenticationFailedException was expected as the AuthInitialize object passed is incorrect");
} catch (GemFireSecurityException expected) {
// success
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
use of org.apache.geode.security.SecurityTestUtils in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithBothValidAndInValidCredentials.
@Test
public void testP2PAuthenticationWithBothValidAndInValidCredentials() throws Exception {
addIgnoredException("Authentication failed");
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthenticator());
assertNotNull(gen.getAuthInit());
assertNotNull(gen.getInvalidCredentials(1));
assertNull(gen.getJavaProperties());
assertNull(gen.getSystemProperties());
assertNotNull(gen.getValidCredentials(1));
assertNotNull(gen.getValidCredentials(3));
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR, gen.getAuthenticator());
props.putAll(gen.getValidCredentials(1));
startTheLocator(props, null, locatorPort);
try {
// invalid credentials for the peer
props.putAll(gen.getInvalidCredentials(1));
try {
new SecurityTestUtils("tmp").createSystem(props, null);
fail("AuthenticationFailedException was expected as wrong credentials were passed");
} catch (GemFireSecurityException expected) {
// success
}
props.putAll(gen.getValidCredentials(3));
createDS(props, null);
verifyMembers(2);
disconnectFromDS();
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
use of org.apache.geode.security.SecurityTestUtils in project geode by apache.
the class P2PAuthenticationDUnitTest method createDS.
private static void createDS(final Properties props, final Properties javaProps) {
SecurityTestUtils tmpUtil = new SecurityTestUtils("tmp");
tmpUtil.createSystem(props, javaProps);
}
use of org.apache.geode.security.SecurityTestUtils in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithInvalidAuthenticator.
/**
* Authenticator is incorrect
*/
// GEODE-1089: random port
@Category(FlakyTest.class)
@Test
public void testP2PAuthenticationWithInvalidAuthenticator() throws Exception {
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthInit());
assertNull(gen.getJavaProperties());
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR, "xyz");
startTheLocator(props, null, locatorPort);
try {
new SecurityTestUtils("tmp").createSystem(props, null);
fail("AuthenticationFailedException was expected as the Authenticator object passed is incorrect");
} catch (GemFireSecurityException expected) {
// success
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
use of org.apache.geode.security.SecurityTestUtils in project geode by apache.
the class P2PAuthenticationDUnitTest method testP2PAuthenticationWithNoCredentials.
// GEODE-1091: random port
@Category(FlakyTest.class)
@Test
public void testP2PAuthenticationWithNoCredentials() throws Exception {
int locatorPort = getRandomAvailablePort(SOCKET);
CredentialGenerator gen = new DummyCredentialGenerator();
assertNotNull(gen.getAuthenticator());
assertNotNull(gen.getAuthInit());
assertNull(gen.getJavaProperties());
assertNull(gen.getSystemProperties());
Properties props = new Properties();
props.setProperty(MCAST_PORT, "0");
props.setProperty(LOCATORS, getIPLiteral() + "[" + locatorPort + "]");
props.setProperty(SECURITY_PEER_AUTH_INIT, gen.getAuthInit());
props.setProperty(SECURITY_PEER_AUTHENTICATOR, gen.getAuthenticator());
startTheLocator(props, null, locatorPort);
try {
new SecurityTestUtils("tmp").createSystem(props, null);
fail("AuthenticationFailedException was expected as no credentials are set");
} catch (GemFireSecurityException expected) {
// success
} finally {
locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
}
}
Aggregations