Search in sources :

Example 6 with SecurityTestUtils

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));
    }
}
Also used : DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) LdapUserCredentialGenerator(org.apache.geode.security.generator.LdapUserCredentialGenerator) CredentialGenerator(org.apache.geode.security.generator.CredentialGenerator) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) SecurityTestUtils(org.apache.geode.security.SecurityTestUtils) DummyCredentialGenerator(org.apache.geode.security.generator.DummyCredentialGenerator) Category(org.junit.experimental.categories.Category) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

SecurityTestUtils (org.apache.geode.security.SecurityTestUtils)6 Properties (java.util.Properties)4 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 CredentialGenerator (org.apache.geode.security.generator.CredentialGenerator)4 DummyCredentialGenerator (org.apache.geode.security.generator.DummyCredentialGenerator)4 LdapUserCredentialGenerator (org.apache.geode.security.generator.LdapUserCredentialGenerator)4 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)4 Test (org.junit.Test)4 Category (org.junit.experimental.categories.Category)2 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1