geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hiteshkhame...@apache.org
Subject [92/94] [abbrv] incubator-geode git commit: GEODE-1362 Merge remote-tracking branch 'origin/develop' into feature/GEODE-1372
Date Wed, 15 Jun 2016 00:08:48 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/571724bb/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
index 123b5ab,0000000..5cc0eb0
mode 100755,000000..100755
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/LocatorUDPSecurityDUnitTest.java
@@@ -1,90 -1,0 +1,89 @@@
 +package com.gemstone.gemfire.distributed;
 +
 +import java.io.File;
 +import java.io.IOException;
 +import java.util.Properties;
 +
 +import org.junit.Assert;
 +import org.junit.Test;
 +
 +import com.gemstone.gemfire.GemFireConfigException;
 +import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 +import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper;
 +import com.gemstone.gemfire.internal.AvailablePort;
 +import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
 +import com.gemstone.gemfire.test.dunit.Host;
 +import com.gemstone.gemfire.test.dunit.NetworkUtils;
 +import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 +import com.gemstone.gemfire.test.dunit.VM;
 +import com.gemstone.gemfire.test.dunit.Wait;
 +import com.gemstone.gemfire.test.dunit.WaitCriterion;
 +
 +import static com.gemstone.gemfire.distributed.DistributedSystemConfigProperties.*;
 +
 +public class LocatorUDPSecurityDUnitTest extends LocatorDUnitTest{
 +
-   public LocatorUDPSecurityDUnitTest(String name) {
-     super(name);
++  public LocatorUDPSecurityDUnitTest() {    
 +  }
 +  
 +  @Test
 +  public void testLoop() throws Exception {
-     for(int i=0; i < 100; i++) {
++    for(int i=0; i < 1; i++) {
 +      testMultipleLocatorsRestartingAtSameTime();
 +      tearDown();
 +      setUp();
 +    }
 +  }
 +  
 +  @Override
 +  protected void addDSProps(Properties p) {
 +    p.setProperty(SECURITY_UDP_DHALGO, "AES:128");
 +  }
 +  
 +  @Test
 +  public void testLocatorWithUDPSecurityButServer() throws Exception {
 +    disconnectAllFromDS();
 +    Host host = Host.getHost(0);
 +    VM vm0 = host.getVM(0);
 +    VM vm1 = host.getVM(1);
 +    VM vm2 = host.getVM(2);
 +
 +    final int port =
 +        AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 +    DistributedTestUtils.deleteLocatorStateFile(port1);
 +    final String locators = NetworkUtils.getServerHostName(host) + "[" + port + "]";
 +    final String uniqueName = getUniqueName();
 +
 +    vm0.invoke(new SerializableRunnable("Start locator " + locators) {
 +      public void run() {
 +        File logFile = new File("");
 +        try {
 +          Properties locProps = new Properties();
 +          locProps.setProperty(MCAST_PORT, "0");
 +          locProps.setProperty(MEMBER_TIMEOUT, "1000");
 +          locProps.put(ENABLE_CLUSTER_CONFIGURATION, "false");
 +
 +          addDSProps(locProps);  
 +          Locator.startLocatorAndDS(port, logFile, locProps);
 +        } catch (IOException ex) {
 +          com.gemstone.gemfire.test.dunit.Assert.fail("While starting locator on port "
+ port, ex);
 +        }
 +      }
 +    });
 +    try {
 +
 +      Properties props = new Properties();
 +      props.setProperty(MCAST_PORT, "0");
 +      props.setProperty(LOCATORS, locators);
 +      props.setProperty(MEMBER_TIMEOUT, "1000");
 +     // addDSProps(props);
 +      system = (InternalDistributedSystem) DistributedSystem.connect(props);
 +      
 +    } catch(GemFireConfigException gce){
 +      Assert.assertTrue(gce.getMessage().contains("Rejecting findCoordinatorRequest"));
 +    } finally {
 +      vm0.invoke(getStopLocatorRunnable());
 +    }
 +  }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/571724bb/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/MembershipJUnitTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/571724bb/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/locator/GMSLocatorRecoveryJUnitTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/571724bb/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
----------------------------------------------------------------------
diff --cc geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
index 7385228,58dbe48..75192af
--- a/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/distributed/internal/membership/gms/messenger/JGroupsMessengerJUnitTest.java
@@@ -16,33 -16,21 +16,51 @@@
   */
  package com.gemstone.gemfire.distributed.internal.membership.gms.messenger;
  
 +import com.gemstone.gemfire.ForcedDisconnectException;
 +import com.gemstone.gemfire.GemFireIOException;
 +import com.gemstone.gemfire.distributed.DistributedSystemConfigProperties;
 +import com.gemstone.gemfire.distributed.DistributedSystemDisconnectedException;
 +import com.gemstone.gemfire.distributed.internal.*;
 +import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember;
 +import com.gemstone.gemfire.distributed.internal.membership.NetView;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.GMSMember;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.ServiceConfig;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.Services;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.Services.Stopper;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.HealthMonitor;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.JoinLeave;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.Manager;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.interfaces.MessageHandler;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorRequest;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.locator.FindCoordinatorResponse;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.messages.InstallViewMessage;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinRequestMessage;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.messages.JoinResponseMessage;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.messages.LeaveRequestMessage;
 +import com.gemstone.gemfire.distributed.internal.membership.gms.messenger.JGroupsMessenger.JGroupsReceiver;
 +import com.gemstone.gemfire.internal.*;
 +import com.gemstone.gemfire.internal.admin.remote.RemoteTransportConfig;
 +import com.gemstone.gemfire.internal.cache.DistributedCacheOperation;
 +import com.gemstone.gemfire.internal.logging.log4j.AlertAppender;
 +import com.gemstone.gemfire.test.junit.categories.IntegrationTest;
++
+ import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
+ import static org.junit.Assert.*;
+ import static org.mockito.Matchers.*;
+ import static org.mockito.Mockito.*;
+ 
+ import java.io.ByteArrayInputStream;
+ import java.io.DataInputStream;
+ import java.io.DataOutput;
+ import java.io.IOException;
+ import java.util.ArrayList;
+ import java.util.HashMap;
++import java.util.HashSet;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.Properties;
++import java.util.Set;
+ 
  import org.apache.commons.lang.SerializationException;
  import org.jgroups.Address;
  import org.jgroups.Event;
@@@ -889,174 -891,6 +930,174 @@@ public class JGroupsMessengerJUnitTest 
      assertFalse(AvailablePort.isPortAvailable(services.getConfig().getDistributionConfig().getMcastPort(),
AvailablePort.MULTICAST));
    }
    
 +  private NetView createView(InternalDistributedMember otherMbr) {
 +    InternalDistributedMember sender = messenger.getMemberID();
 +    List<InternalDistributedMember> mbrs = new ArrayList<>();
 +    mbrs.add(sender);
 +    mbrs.add(otherMbr);
 +    NetView v = new NetView(sender, 1, mbrs);
 +    return v;
 +  }
 +  
 +  @Test
 +  public void testEncryptedFindCoordinatorRequest() throws Exception{
 +    InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
 +    
 +    Properties p = new Properties();    
 +    p.put(DistributedSystemConfigProperties.SECURITY_UDP_DHALGO, "AES:128");
 +    initMocks(false, p);
 +    
 +    NetView v = createView(otherMbr);
 +    
 +    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
 +    
 +    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
 +    messenger.initClusterKey();
 +    
 +    FindCoordinatorRequest gfmsg = new FindCoordinatorRequest(messenger.getMemberID(), new
ArrayList<InternalDistributedMember>(2), 1, messenger.getPublickey(messenger.getMemberID()),
1, "");
-     Set<InternalDistributedMember> recipients = new HashSet<>();
++    Set<InternalDistributedMember> recipients = new HashSet();
 +    recipients.add(otherMbr);
 +    gfmsg.setRecipients(recipients);
 +    
 +    short version = Version.CURRENT_ORDINAL;
 +    
 +    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
 +    
 +    messenger.writeEncryptedMessage(gfmsg, version, out);
 +    
 +    byte[] requestBytes = out.toByteArray();
 +    
 +    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
 +    
 +    DistributionMessage distributionMessage = messenger.readEncryptedMessage(dis, version,
otherMbrEncrptor);
 +    
 +    assertEquals(gfmsg, distributionMessage);
 +  }
 +  
 +  @Test
 +  public void testEncryptedFindCoordinatorResponse() throws Exception{
 +    InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
 +    
 +    Properties p = new Properties();    
 +    p.put(DistributedSystemConfigProperties.SECURITY_UDP_DHALGO, "AES:128");
 +    initMocks(false, p);
 +    
 +    NetView v = createView(otherMbr);
 +    
 +    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
 +    otherMbrEncrptor.setPublicKey(messenger.getPublickey(messenger.getMemberID()), messenger.getMemberID());
 +    
 +    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
 +    messenger.initClusterKey();
 +    
 +    FindCoordinatorResponse gfmsg = new FindCoordinatorResponse(messenger.getMemberID(),
messenger.getMemberID(),  messenger.getClusterSecretKey(), 1);
 +    Set<InternalDistributedMember> recipients = new HashSet<>();
 +    recipients.add(otherMbr);
 +    gfmsg.setRecipients(recipients);
 +    
 +    short version = Version.CURRENT_ORDINAL;
 +    
 +    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
 +    
 +    messenger.writeEncryptedMessage(gfmsg, version, out);
 +    
 +    byte[] requestBytes = out.toByteArray();
 +    
 +    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
 +    
 +    messenger.addRequestId(1, messenger.getMemberID());
 +    
 +    DistributionMessage distributionMessage = messenger.readEncryptedMessage(dis, version,
otherMbrEncrptor);
 +    
 +    assertEquals(gfmsg, distributionMessage);
 +  }
 +  
 +  @Test
 +  public void testEncryptedJoinRequest() throws Exception{
 +    InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
 +    
 +    Properties p = new Properties();    
 +    p.put(DistributedSystemConfigProperties.SECURITY_UDP_DHALGO, "AES:128");
 +    initMocks(false, p);
 +    
 +    NetView v = createView(otherMbr);
 +    
 +    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
 +    
 +    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
 +    messenger.initClusterKey();
 +    
 +    JoinRequestMessage gfmsg = new JoinRequestMessage(otherMbr, messenger.getMemberID(),
null, 9789, 1);
 +    
 +    short version = Version.CURRENT_ORDINAL;
 +    
 +    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
 +    
 +    messenger.writeEncryptedMessage(gfmsg, version, out);
 +    
 +    byte[] requestBytes = out.toByteArray();
 +    
 +    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
 +    
 +    DistributionMessage distributionMessage = messenger.readEncryptedMessage(dis, version,
otherMbrEncrptor);
 +    
 +    assertEquals(gfmsg, distributionMessage);
 +  }
 +  
 +  @Test
 +  public void testEncryptedJoinResponse() throws Exception{
 +    InternalDistributedMember otherMbr = new InternalDistributedMember("localhost", 8888);
 +    
 +    Properties p = new Properties();    
 +    p.put(DistributedSystemConfigProperties.SECURITY_UDP_DHALGO, "AES:128");
 +    initMocks(false, p);
 +    
 +    NetView v = createView(otherMbr);
 +    
 +    GMSEncrypt otherMbrEncrptor = new GMSEncrypt(services);
 +    otherMbrEncrptor.setPublicKey(messenger.getPublickey(messenger.getMemberID()), messenger.getMemberID());
 +    
 +    messenger.setPublicKey(otherMbrEncrptor.getPublicKeyBytes(), otherMbr);
 +    messenger.initClusterKey();
 +    
 +    JoinResponseMessage gfmsg = new JoinResponseMessage(otherMbr, messenger.getClusterSecretKey(),
1);
 +    
 +    short version = Version.CURRENT_ORDINAL;
 +    
 +    HeapDataOutputStream out = new HeapDataOutputStream(Version.CURRENT);
 +    
 +    messenger.writeEncryptedMessage(gfmsg, version, out);
 +    
 +    byte[] requestBytes = out.toByteArray();
 +    
 +    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
 +    
 +    messenger.addRequestId(1, messenger.getMemberID());
 +    
 +    DistributionMessage gfMessageAtOtherMbr = messenger.readEncryptedMessage(dis, version,
otherMbrEncrptor);
 +    
 +    assertEquals(gfmsg, gfMessageAtOtherMbr);
 +    
 +    //lets send view as well..
 +    
 +    InstallViewMessage installViewMessage = new InstallViewMessage(v, null, true);
 +    
 +    out = new HeapDataOutputStream(Version.CURRENT);
 +    
 +    messenger.writeEncryptedMessage(installViewMessage, version, out);
 +    
 +    requestBytes = out.toByteArray();
 +    
 +    otherMbrEncrptor.addClusterKey(((JoinResponseMessage)gfMessageAtOtherMbr).getSecretPk());
 +    
 +    dis = new DataInputStream(new ByteArrayInputStream(requestBytes));
 +    
 +    gfMessageAtOtherMbr = messenger.readEncryptedMessage(dis, version, otherMbrEncrptor);
 +    
 +    assertEquals(installViewMessage, gfMessageAtOtherMbr);
 +    
 +  }
 +  
    /**
     * creates an InternalDistributedMember address that can be used
     * with the doctored JGroups channel.  This includes a logical


Mime
View raw message