From f7036e50348484f4daf39f9e8457de602ab83939 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Tue, 28 Aug 2007 15:54:13 +0000
Subject: [PATCH] Changes for replication security issues 511, 512, 608.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java |   41 +++++++++++++++++++++++++++++------------
 1 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 016d567..35ba5fd 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -28,13 +28,13 @@
 
 import static org.opends.server.config.ConfigConstants.ATTR_TASK_COMPLETION_TIME;
 import static org.opends.server.config.ConfigConstants.ATTR_TASK_STATE;
+import org.opends.server.config.ConfigException;
 import static org.opends.server.loggers.ErrorLogger.logError;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
-import java.net.SocketException;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.LinkedList;
@@ -58,6 +58,7 @@
 import org.opends.server.replication.common.ServerState;
 import org.opends.server.replication.plugin.PersistentServerState;
 import org.opends.server.replication.plugin.ReplicationBroker;
+import org.opends.server.replication.protocol.ReplSessionSecurity;
 import org.opends.server.schema.DirectoryStringSyntax;
 import org.opends.server.schema.IntegerSyntax;
 import org.opends.server.types.Attribute;
@@ -106,7 +107,7 @@
   private DN monitorDn;
   private String monitorAttr;
   private long lastCount;
-  
+
   /**
    * schema check flag
    */
@@ -141,7 +142,7 @@
   protected ReplicationBroker openReplicationSession(
       final DN baseDn, short serverId, int window_size,
       int port, int timeout, boolean emptyOldChanges)
-          throws Exception, SocketException
+          throws Exception
   {
     ServerState state;
     if (emptyOldChanges)
@@ -150,7 +151,8 @@
        state = new ServerState();
 
     ReplicationBroker broker = new ReplicationBroker(
-        state, baseDn, serverId, 0, 0, 0, 0, window_size, 0);
+        state, baseDn, serverId, 0, 0, 0, 0, window_size, 0,
+        getReplSessionSecurity());
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + port);
     broker.start(servers);
@@ -188,10 +190,11 @@
   protected ReplicationBroker openReplicationSession(
       final DN baseDn, short serverId, int window_size,
       int port, int timeout, ServerState state)
-          throws Exception, SocketException
+          throws Exception
   {
     ReplicationBroker broker = new ReplicationBroker(
-        state, baseDn, serverId, 0, 0, 0, 0, window_size, 0);
+        state, baseDn, serverId, 0, 0, 0, 0, window_size, 0,
+        getReplSessionSecurity());
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + port);
     broker.start(servers);
@@ -210,7 +213,7 @@
       final DN baseDn, short serverId, int window_size,
       int port, int timeout, int maxSendQueue, int maxRcvQueue,
       boolean emptyOldChanges)
-          throws Exception, SocketException
+          throws Exception
   {
     ServerState state;
     if (emptyOldChanges)
@@ -220,7 +223,8 @@
 
     ReplicationBroker broker = new ReplicationBroker(
         state, baseDn, serverId, maxRcvQueue, 0,
-        maxSendQueue, 0, window_size, 0);
+        maxSendQueue, 0, window_size, 0,
+        getReplSessionSecurity());
     ArrayList<String> servers = new ArrayList<String>(1);
     servers.add("localhost:" + port);
     broker.start(servers);
@@ -367,7 +371,7 @@
     while (op.getSearchEntries().isEmpty() && (count<100));
     if (op.getSearchEntries().isEmpty())
       throw new Exception("Could not read monitoring information");
-    
+
     SearchResultEntry entry = op.getSearchEntries().getFirst();
     AttributeType attrType =
          DirectoryServer.getDefaultAttributeType(attr);
@@ -481,7 +485,7 @@
       LockManager.unlock(dn, lock);
     }
   }
-  
+
   /**
    * Update the monitor count for the specified monitor attribute.
    */
@@ -498,7 +502,7 @@
       assertTrue(false);
     }
   }
-  
+
   /**
    * Get the delta between the current / last monitor counts.
    * @return The delta between the current and last monitor count.
@@ -535,7 +539,7 @@
     mods.add(mod);
     return mods;
   }
-  
+
   /**
    * Utility method to create, run a task and check its result.
    */
@@ -606,4 +610,17 @@
                  "The task completed in an unexpected state");
   }
 
+  /**
+   * Create a new replication session security object that can be used in
+   * unit tests.
+   *
+   * @return A new replication session security object.
+   * @throws ConfigException If an error occurs.
+   */
+  protected static ReplSessionSecurity getReplSessionSecurity()
+       throws ConfigException
+  {
+    return new ReplSessionSecurity(null, null, null, true);
+  }
+
 }

--
Gitblit v1.10.0