mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
10.51.2013 db3b5560e0d197f79a334d7775ee3f85c9462ec5
opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
@@ -34,11 +34,11 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
@@ -73,7 +73,6 @@
/**
 * This class provides a set of test cases for the Directory Server JMX
 * privilege subsystem.
@@ -382,6 +381,7 @@
  /**
   * Check that simple connection to the JMX service are
   * accepted only if JMX_READ privilege is set.
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(enabled = true)
  public void simpleConnectJmxPrivilege() throws Exception
@@ -402,7 +402,7 @@
      opendsConnector = new OpendsJmxConnector("localhost", jmxPort, env);
      opendsConnector.connect();
      opendsConnector.close() ;
      assertTrue(false, "User \"cn=Unprivileged JMX Root,cn=Root "+
      fail("User \"cn=Unprivileged JMX Root,cn=Root "+
          "DNs,cn=config\" doesn't have JMX_READ privilege but he's able " +
          "to connect, which is not the correct behavior");
    }
@@ -411,11 +411,6 @@
      Message message = ERR_JMX_INSUFFICIENT_PRIVILEGES.get();
      assertEquals(message.toString(), e.getMessage());
    }
    catch (IOException e)
    {
      assertTrue(false, "Unexpected exception - error message: "
          + e.getMessage());
    }
    // Add JMX_READ privilege
    InternalClientConnection rootConnection =
@@ -434,21 +429,13 @@
      opendsConnector = new OpendsJmxConnector("localhost", jmxPort, env);
      opendsConnector.connect();
      opendsConnector.close() ;
      assertTrue(true, "User \"cn=Unprivileged JMX Root,cn=Root "+
          "DNs,cn=config\" has JMX_READ privilege and he's able " +
          "to connect, which is the correct behavior.");
    }
    catch (SecurityException e)
    {
      assertTrue(false, "User \"cn=Unprivileged JMX Root,cn=Root " +
      fail("User \"cn=Unprivileged JMX Root,cn=Root " +
          "DNs,cn=config\" has JMX_READ privilege and he's NOT able " +
          "to connect, which is NOT the correct behavior.");
    }
    catch (IOException e)
    {
      assertTrue(false, "Unexpected exception - error message: "
          + e.getMessage());
    }
    // remove JMX_READ privilege
    mods = new ArrayList<Modification>();
@@ -465,7 +452,7 @@
      opendsConnector = new OpendsJmxConnector("localhost", jmxPort, env);
      opendsConnector.connect();
      opendsConnector.close() ;
      assertTrue(false, "User \"cn=Unprivileged JMX Root,cn=Root "+
      fail("User \"cn=Unprivileged JMX Root,cn=Root "+
          "DNs,cn=config\" doesn't have JMX_READ privilege but he's able " +
          "to connect, which is not the correct behavior");
    }
@@ -474,11 +461,6 @@
      Message message = ERR_JMX_INSUFFICIENT_PRIVILEGES.get();
      assertEquals(message.toString(), e.getMessage());
    }
    catch (IOException e)
    {
      assertTrue(false, "Unexpected exception - error message: "
          + e.getMessage());
    }
  }
@@ -1657,12 +1639,7 @@
      }
    }
    if (task == null)
    {
      throw new AssertionError("There is no such task " +
                               taskEntryDN.toString());
    }
    assertNotNull(task, "There is no such task " + taskEntryDN.toString());
    if (! TaskState.isDone(task.getTaskState()))
    {
      long stopWaitingTime = System.currentTimeMillis() + 20000L;
@@ -1673,11 +1650,9 @@
      }
    }
    if (! TaskState.isDone(task.getTaskState()))
    {
      throw new AssertionError("Task " + taskEntryDN.toString() +
                               " did not complete in a timely manner.");
    }
    assertTrue(TaskState.isDone(task.getTaskState()),
        "Task " + taskEntryDN.toString()
            + " did not complete in a timely manner.");
    return task;
  }