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