Search in sources :

Example 11 with DistributionConfigImpl

use of org.apache.geode.distributed.internal.DistributionConfigImpl in project geode by apache.

the class SSLConfigJUnitTest method testPartialCustomizedManagerSslConfig.

@Test
public void testPartialCustomizedManagerSslConfig() throws Exception {
    boolean sslenabled = false;
    String sslprotocols = "any";
    String sslciphers = "any";
    boolean requireAuth = true;
    boolean jmxManagerSslenabled = true;
    String jmxManagerSslprotocols = "SSLv7";
    String jmxManagerSslciphers = "RSA_WITH_GARBAGE";
    boolean jmxManagerSslRequireAuth = true;
    Properties gemFireProps = new Properties();
    gemFireProps.put(CLUSTER_SSL_ENABLED, String.valueOf(sslenabled));
    gemFireProps.put(CLUSTER_SSL_PROTOCOLS, sslprotocols);
    gemFireProps.put(CLUSTER_SSL_CIPHERS, sslciphers);
    gemFireProps.put(CLUSTER_SSL_REQUIRE_AUTHENTICATION, String.valueOf(requireAuth));
    gemFireProps.put(JMX_MANAGER_SSL_ENABLED, String.valueOf(jmxManagerSslenabled));
    gemFireProps.put(JMX_MANAGER_SSL_PROTOCOLS, jmxManagerSslprotocols);
    gemFireProps.put(JMX_MANAGER_SSL_CIPHERS, jmxManagerSslciphers);
    gemFireProps.put(JMX_MANAGER_SSL_REQUIRE_AUTHENTICATION, String.valueOf(jmxManagerSslRequireAuth));
    gemFireProps.putAll(getGfSecurityPropertiesJMX(true));
    DistributionConfigImpl config = new DistributionConfigImpl(gemFireProps);
    isEqual(config.getClusterSSLEnabled(), sslenabled);
    isEqual(config.getClusterSSLProtocols(), sslprotocols);
    isEqual(config.getClusterSSLCiphers(), sslciphers);
    isEqual(config.getClusterSSLRequireAuthentication(), requireAuth);
    isEqual(config.getJmxManagerSSLEnabled(), jmxManagerSslenabled);
    isEqual(config.getJmxManagerSSLProtocols(), jmxManagerSslprotocols);
    isEqual(config.getJmxManagerSSLCiphers(), jmxManagerSslciphers);
    isEqual(config.getJmxManagerSSLRequireAuthentication(), jmxManagerSslRequireAuth);
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_KEYSTORE), config.getClusterSSLKeyStore());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_KEYSTORE_TYPE), config.getClusterSSLKeyStoreType());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_KEYSTORE_PASSWORD), config.getClusterSSLKeyStorePassword());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_TRUSTSTORE), config.getClusterSSLTrustStore());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_TRUSTSTORE_PASSWORD), config.getClusterSSLTrustStorePassword());
    isEqual(JMX_SSL_PROPS_SUBSET_MAP.get(JMX_MANAGER_SSL_KEYSTORE), config.getJmxManagerSSLKeyStore());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_KEYSTORE_TYPE), config.getJmxManagerSSLKeyStoreType());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_KEYSTORE_PASSWORD), config.getJmxManagerSSLKeyStorePassword());
    isEqual(JMX_SSL_PROPS_SUBSET_MAP.get(JMX_MANAGER_SSL_TRUSTSTORE), config.getJmxManagerSSLTrustStore());
    isEqual(CLUSTER_SSL_PROPS_MAP.get(CLUSTER_SSL_TRUSTSTORE_PASSWORD), config.getJmxManagerSSLTrustStorePassword());
}
Also used : DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 12 with DistributionConfigImpl

use of org.apache.geode.distributed.internal.DistributionConfigImpl in project geode by apache.

the class SSLConfigJUnitTest method testManagerDefaultConfig.

@Test
public void testManagerDefaultConfig() throws Exception {
    boolean sslenabled = false;
    String sslprotocols = "any";
    String sslciphers = "any";
    boolean requireAuth = true;
    boolean jmxManagerSsl = false;
    boolean jmxManagerSslenabled = false;
    String jmxManagerSslprotocols = "any";
    String jmxManagerSslciphers = "any";
    boolean jmxManagerSslRequireAuth = true;
    DistributionConfigImpl config = new DistributionConfigImpl(new Properties());
    isEqual(config.getClusterSSLEnabled(), sslenabled);
    isEqual(config.getClusterSSLProtocols(), sslprotocols);
    isEqual(config.getClusterSSLCiphers(), sslciphers);
    isEqual(config.getClusterSSLRequireAuthentication(), requireAuth);
    isEqual(config.getJmxManagerSSLEnabled(), jmxManagerSsl);
    isEqual(config.getJmxManagerSSLEnabled(), jmxManagerSslenabled);
    isEqual(config.getJmxManagerSSLProtocols(), jmxManagerSslprotocols);
    isEqual(config.getJmxManagerSSLCiphers(), jmxManagerSslciphers);
    isEqual(config.getJmxManagerSSLRequireAuthentication(), jmxManagerSslRequireAuth);
}
Also used : DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 13 with DistributionConfigImpl

use of org.apache.geode.distributed.internal.DistributionConfigImpl in project geode by apache.

the class JGroupsMessengerJUnitTest method initMocks.

/**
   * Create stub and mock objects
   */
private void initMocks(boolean enableMcast, Properties addProp) throws Exception {
    if (messenger != null) {
        messenger.stop();
        messenger = null;
    }
    Properties nonDefault = new Properties();
    nonDefault.put(DISABLE_TCP, "true");
    nonDefault.put(MCAST_PORT, enableMcast ? "" + AvailablePortHelper.getRandomAvailableUDPPort() : "0");
    nonDefault.put(MCAST_TTL, "0");
    nonDefault.put(LOG_FILE, "");
    nonDefault.put(LOG_LEVEL, "fine");
    nonDefault.put(LOCATORS, "localhost[10344]");
    nonDefault.put(ACK_WAIT_THRESHOLD, "1");
    nonDefault.putAll(addProp);
    DistributionConfigImpl config = new DistributionConfigImpl(nonDefault);
    RemoteTransportConfig tconfig = new RemoteTransportConfig(config, DistributionManager.NORMAL_DM_TYPE);
    stopper = mock(Stopper.class);
    when(stopper.isCancelInProgress()).thenReturn(false);
    manager = mock(Manager.class);
    when(manager.isMulticastAllowed()).thenReturn(enableMcast);
    healthMonitor = mock(HealthMonitor.class);
    joinLeave = mock(JoinLeave.class);
    ServiceConfig serviceConfig = new ServiceConfig(tconfig, config);
    services = mock(Services.class);
    when(services.getConfig()).thenReturn(serviceConfig);
    when(services.getCancelCriterion()).thenReturn(stopper);
    when(services.getHealthMonitor()).thenReturn(healthMonitor);
    when(services.getManager()).thenReturn(manager);
    when(services.getJoinLeave()).thenReturn(joinLeave);
    DM dm = mock(DM.class);
    InternalDistributedSystem system = InternalDistributedSystem.newInstanceForTesting(dm, nonDefault);
    when(services.getStatistics()).thenReturn(new DistributionStats(system, statsId));
    messenger = new JGroupsMessenger();
    messenger.init(services);
    // if I do this earlier then test this return messenger as null
    when(services.getMessenger()).thenReturn(messenger);
    String jgroupsConfig = messenger.getJGroupsStackConfig();
    int startIdx = jgroupsConfig.indexOf("<org");
    int insertIdx = jgroupsConfig.indexOf('>', startIdx + 4) + 1;
    jgroupsConfig = jgroupsConfig.substring(0, insertIdx) + "<" + InterceptUDP.class.getName() + "/>" + jgroupsConfig.substring(insertIdx);
    messenger.setJGroupsStackConfigForTesting(jgroupsConfig);
    // System.out.println("jgroups config: " + jgroupsConfig);
    messenger.start();
    messenger.started();
    interceptor = (InterceptUDP) messenger.myChannel.getProtocolStack().getTransport().getUpProtocol();
}
Also used : JoinLeave(org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave) HealthMonitor(org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor) DM(org.apache.geode.distributed.internal.DM) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) DistributionManager(org.apache.geode.distributed.internal.DistributionManager) Manager(org.apache.geode.distributed.internal.membership.gms.interfaces.Manager) Services(org.apache.geode.distributed.internal.membership.gms.Services) Stopper(org.apache.geode.distributed.internal.membership.gms.Services.Stopper) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) DistributionStats(org.apache.geode.distributed.internal.DistributionStats)

Example 14 with DistributionConfigImpl

use of org.apache.geode.distributed.internal.DistributionConfigImpl in project geode by apache.

the class GMSMembershipManagerJUnitTest method initMocks.

@Before
public void initMocks() throws Exception {
    Properties nonDefault = new Properties();
    nonDefault.put(ACK_WAIT_THRESHOLD, "1");
    nonDefault.put(ACK_SEVERE_ALERT_THRESHOLD, "10");
    nonDefault.put(DISABLE_TCP, "true");
    nonDefault.put(MCAST_PORT, "0");
    nonDefault.put(MCAST_TTL, "0");
    nonDefault.put(LOG_FILE, "");
    nonDefault.put(LOG_LEVEL, "fine");
    nonDefault.put(MEMBER_TIMEOUT, "2000");
    nonDefault.put(LOCATORS, "localhost[10344]");
    distConfig = new DistributionConfigImpl(nonDefault);
    distProperties = nonDefault;
    RemoteTransportConfig tconfig = new RemoteTransportConfig(distConfig, DistributionManager.NORMAL_DM_TYPE);
    mockConfig = mock(ServiceConfig.class);
    when(mockConfig.getDistributionConfig()).thenReturn(distConfig);
    when(mockConfig.getTransport()).thenReturn(tconfig);
    authenticator = mock(Authenticator.class);
    myMemberId = new InternalDistributedMember("localhost", 8887);
    messenger = mock(Messenger.class);
    when(messenger.getMemberID()).thenReturn(myMemberId);
    stopper = mock(Stopper.class);
    when(stopper.isCancelInProgress()).thenReturn(false);
    healthMonitor = mock(HealthMonitor.class);
    when(healthMonitor.getFailureDetectionPort()).thenReturn(Integer.valueOf(-1));
    joinLeave = mock(JoinLeave.class);
    services = mock(Services.class);
    when(services.getAuthenticator()).thenReturn(authenticator);
    when(services.getConfig()).thenReturn(mockConfig);
    when(services.getMessenger()).thenReturn(messenger);
    when(services.getCancelCriterion()).thenReturn(stopper);
    when(services.getHealthMonitor()).thenReturn(healthMonitor);
    when(services.getJoinLeave()).thenReturn(joinLeave);
    Timer t = new Timer(true);
    when(services.getTimer()).thenReturn(t);
    Random r = new Random();
    mockMembers = new InternalDistributedMember[5];
    for (int i = 0; i < mockMembers.length; i++) {
        mockMembers[i] = new InternalDistributedMember("localhost", 8888 + i);
        GMSMember m = (GMSMember) mockMembers[i].getNetMember();
        UUID uuid = new UUID(r.nextLong(), r.nextLong());
        m.setUUID(uuid);
    }
    members = new ArrayList<>(Arrays.asList(mockMembers));
    listener = mock(DistributedMembershipListener.class);
    manager = new GMSMembershipManager(listener);
    manager.init(services);
    when(services.getManager()).thenReturn(manager);
}
Also used : JoinLeave(org.apache.geode.distributed.internal.membership.gms.interfaces.JoinLeave) GMSMember(org.apache.geode.distributed.internal.membership.gms.GMSMember) HealthMonitor(org.apache.geode.distributed.internal.membership.gms.interfaces.HealthMonitor) RemoteTransportConfig(org.apache.geode.internal.admin.remote.RemoteTransportConfig) Messenger(org.apache.geode.distributed.internal.membership.gms.interfaces.Messenger) DistributedMembershipListener(org.apache.geode.distributed.internal.membership.DistributedMembershipListener) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) Services(org.apache.geode.distributed.internal.membership.gms.Services) Stopper(org.apache.geode.distributed.internal.membership.gms.Services.Stopper) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) Timer(java.util.Timer) Random(java.util.Random) ServiceConfig(org.apache.geode.distributed.internal.membership.gms.ServiceConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) UUID(org.jgroups.util.UUID) Authenticator(org.apache.geode.distributed.internal.membership.gms.interfaces.Authenticator) Before(org.junit.Before)

Example 15 with DistributionConfigImpl

use of org.apache.geode.distributed.internal.DistributionConfigImpl in project geode by apache.

the class ClientSocketFactoryIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    System.setProperty(GEMFIRE_PREFIX + "clientSocketFactory", TSocketFactory.class.getName());
    Properties properties = new Properties();
    properties.setProperty(CLUSTER_SSL_ENABLED, "false");
    DistributionConfig distributionConfig = new DistributionConfigImpl(properties);
    SocketCreatorFactory.setDistributionConfig(distributionConfig);
}
Also used : DistributionConfig(org.apache.geode.distributed.internal.DistributionConfig) DistributionConfigImpl(org.apache.geode.distributed.internal.DistributionConfigImpl) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) RestoreSystemProperties(org.junit.contrib.java.lang.system.RestoreSystemProperties) Before(org.junit.Before)

Aggregations

DistributionConfigImpl (org.apache.geode.distributed.internal.DistributionConfigImpl)61 Properties (java.util.Properties)59 Test (org.junit.Test)50 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)45 UnitTest (org.apache.geode.test.junit.categories.UnitTest)26 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)23 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)20 RestoreSystemProperties (org.junit.contrib.java.lang.system.RestoreSystemProperties)11 MembershipTest (org.apache.geode.test.junit.categories.MembershipTest)10 File (java.io.File)6 SecurableCommunicationChannel (org.apache.geode.internal.security.SecurableCommunicationChannel)6 DistributionConfig (org.apache.geode.distributed.internal.DistributionConfig)5 ServiceConfig (org.apache.geode.distributed.internal.membership.gms.ServiceConfig)4 Services (org.apache.geode.distributed.internal.membership.gms.Services)4 RemoteTransportConfig (org.apache.geode.internal.admin.remote.RemoteTransportConfig)4 Before (org.junit.Before)3 Map (java.util.Map)2 LogWriter (org.apache.geode.LogWriter)2 Cache (org.apache.geode.cache.Cache)2 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)2