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

neil_a_wilson
30.20.2007 758aacd7cf4509b2ef2fc4d29a341cadefeec8cf
Provide a test case to ensure that the set of server privileges will always
stay in sync with the set of available default root privileges and the set of
privileges that may be disabled.
1 files modified
51 ■■■■■ changed files
opends/tests/unit-tests-testng/src/server/org/opends/server/types/PrivilegeTestCase.java 51 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/types/PrivilegeTestCase.java
@@ -37,9 +37,12 @@
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.GlobalCfgDefn;
import org.opends.server.admin.std.meta.RootDNCfgDefn;
import org.opends.server.backends.task.Task;
import org.opends.server.backends.task.TaskBackend;
import org.opends.server.backends.task.TaskState;
@@ -2489,6 +2492,54 @@
  /**
   * Tests to ensure that the set of privileges defined in the server matches
   * the set of privileges that can be configured as default root privileges,
   * and that it also matches the set of privileges that can be disabled.
   */
  @Test()
  public void testConfigurablePrivilegeSets()
  {
    HashSet<String> serverPrivNames = new HashSet<String>();
    for (Privilege p : Privilege.values())
    {
      serverPrivNames.add(p.toString());
    }
    HashSet<String> defaultRootPrivNames = new HashSet<String>();
    for (RootDNCfgDefn.DefaultRootPrivilegeName p :
         RootDNCfgDefn.DefaultRootPrivilegeName.values())
    {
      defaultRootPrivNames.add(p.toString());
      assertTrue(serverPrivNames.contains(p.toString()),
                 "The set of server privileges does not contain potential " +
                 "default root privilege " + p.toString());
    }
    HashSet<String> disableablePrivNames = new HashSet<String>();
    for (GlobalCfgDefn.DisabledPrivilege p :
         GlobalCfgDefn.DisabledPrivilege.values())
    {
      disableablePrivNames.add(p.toString());
      assertTrue(serverPrivNames.contains(p.toString()),
                 "The set of server privileges does not contain disableable " +
                 "privilege " + p.toString());
    }
    for (String s : serverPrivNames)
    {
      assertTrue(defaultRootPrivNames.contains(s),
                 "The set of available default root privileges does not " +
                 "contain server privilege " + s);
      assertTrue(disableablePrivNames.contains(s),
                 "The set of disableable privileges does not contain server " +
                 "privilege " + s);
    }
  }
  /**
   * Retrieves the specified task from the server, waiting for it to finish all
   * the running its going to do before returning.
   *