Search in sources :

Example 1 with SecurityTestUtils

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));
    }
}
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) 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)

Example 2 with SecurityTestUtils

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));
    }
}
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) 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)

Example 3 with SecurityTestUtils

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);
}
Also used : SecurityTestUtils(org.apache.geode.security.SecurityTestUtils)

Example 4 with SecurityTestUtils

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));
    }
}
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)

Example 5 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