Implement a TestCaseUtils.dsconfig method that provides a more convenient
mechanism for making configuration changes within the unit test framework.
| | |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.dsconfig.DSConfig; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.FilePermission; |
| | |
| | | assertTrue(InvocationCounterPlugin.startupCalled()); |
| | | |
| | | SERVER_STARTED = true; |
| | | |
| | | |
| | | initializeTestBackend(true); |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Invokes the dsconfig tool with the provided set of arguments. Note that |
| | | * the address, port, bind DN (cn=Directory Manager), and password will always |
| | | * be provided, so they should not be included in the argument list. The |
| | | * given arguments should include only the subcommand and its associated |
| | | * options, along with any other global options that may not be included by |
| | | * default. |
| | | * <BR><BR> |
| | | * An assertion will be used to ensure that the dsconfig invocation is |
| | | * successful. If running dsconfig returns a non-zero result, then an |
| | | * assertion error will be thrown. |
| | | * |
| | | * @param args The set of arguments that should be provided when invoking |
| | | * the dsconfig tool |
| | | */ |
| | | public static void dsconfig(String... args) |
| | | { |
| | | String[] fullArgs = new String[args.length + 8]; |
| | | fullArgs[0] = "-h"; |
| | | fullArgs[1] = "127.0.0.1"; |
| | | fullArgs[2] = "-p"; |
| | | fullArgs[3] = String.valueOf(serverLdapPort); |
| | | fullArgs[4] = "-D"; |
| | | fullArgs[5] = "cn=Directory Manager"; |
| | | fullArgs[6] = "-w"; |
| | | fullArgs[7] = "password"; |
| | | |
| | | System.arraycopy(args, 0, fullArgs, 8, args.length); |
| | | |
| | | assertEquals(DSConfig.main(fullArgs, false, System.out, System.err), 0); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test() |
| | | public void testEnabledAlert() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--add", "enabled-alert-type:" + ALERT_TYPE |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "enabled-alert-type:" + ALERT_TYPE); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--remove", "enabled-alert-type:" + ALERT_TYPE |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "enabled-alert-type:" + ALERT_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test() |
| | | public void testNotEnabledAlert() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--add", "enabled-alert-type:" + ALERT_TYPE + ".bogus" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "enabled-alert-type:" + ALERT_TYPE + ".bogus"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--remove", "enabled-alert-type:" + ALERT_TYPE + ".bogus" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "enabled-alert-type:" + ALERT_TYPE + ".bogus"); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test() |
| | | public void testDisabledAlert() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test() |
| | | public void testNotDisabledAlert() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE + ".bogus" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE + ".bogus"); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE + ".bogus" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE + ".bogus"); |
| | | } |
| | | } |
| | | |
| | |
| | | @Test() |
| | | public void testEnabledAndDisabledAlert() |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--add", "enabled-alert-type:" + ALERT_TYPE, |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE, |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "disabled-alert-type:" + ALERT_TYPE); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-alert-handler-prop", |
| | | "--handler-name", "Dummy Alert Handler", |
| | | "--remove", "enabled-alert-type:" + ALERT_TYPE, |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE, |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "disabled-alert-type:" + ALERT_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--add", "password-validator-dn:cn=Length-Based Password Validator," + |
| | | "cn=Password Validators,cn=config" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "cn=Password Validators,cn=config"); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | ASN1Reader r = new ASN1Reader(s); |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--remove", "password-validator-dn:cn=Length-Based Password " + |
| | | "Validator,cn=Password Validators,cn=config" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "Validator,cn=Password Validators,cn=config"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "lockout-failure-count:3" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "lockout-failure-count:3"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "lockout-failure-count:0" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "lockout-failure-count:0"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "allow-user-password-changes:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "allow-user-password-changes:false"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "allow-user-password-changes:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "allow-user-password-changes:true"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-history-count:5" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "password-history-count:5"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-history-count:0" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "password-history-count:0"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-change-requires-current-password:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "password-change-requires-current-password:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-change-requires-current-password:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "password-change-requires-current-password:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "minimum-password-age:24 hours" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "minimum-password-age:24 hours"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "minimum-password-age:0 seconds" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "minimum-password-age:0 seconds"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "force-change-on-add:false"); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | // Change the server configuration so that error messages should be |
| | | // returned. |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "return-bind-error-messages:true" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "return-bind-error-messages:true"); |
| | | |
| | | bindOperation = |
| | | conn.processSimpleBind(new ASN1OctetString("cn=Directory Manager"), |
| | |
| | | |
| | | // Change the configuration back and make sure that the error message goes |
| | | // away. |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "return-bind-error-messages:false" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "return-bind-error-messages:false"); |
| | | |
| | | bindOperation = |
| | | conn.processSimpleBind(new ASN1OctetString("cn=Directory Manager"), |
| | |
| | | public void testServerWideAnonymousIdleTimeLimit() |
| | | throws Exception |
| | | { |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "idle-time-limit:5 seconds" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "idle-time-limit:5 seconds"); |
| | | |
| | | |
| | | Socket s = null; |
| | |
| | | s.close(); |
| | | } catch (Exception e) {} |
| | | |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "idle-time-limit:0 seconds" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "idle-time-limit:0 seconds"); |
| | | } |
| | | } |
| | | |
| | |
| | | ); |
| | | |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "idle-time-limit:5 seconds" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "idle-time-limit:5 seconds"); |
| | | |
| | | |
| | | Socket s = null; |
| | |
| | | s.close(); |
| | | } catch (Exception e) {} |
| | | |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--set", "idle-time-limit:0 seconds" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--set", "idle-time-limit:0 seconds"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | // Update the set of allowed tasks to include the dummy task. |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--add", "allowed-task:org.opends.server.tasks.DummyTask" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--add", "allowed-task:org.opends.server.tasks.DummyTask"); |
| | | |
| | | |
| | | // Now verify that we can add the task and have it complete successfully. |
| | |
| | | |
| | | // Remove the task class from the set of allowed tasks and verify that we |
| | | // can no longer schedule the task. |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--remove", "allowed-task:org.opends.server.tasks.DummyTask" |
| | | }; |
| | | assertEquals(DSConfig.main(args, false, System.out, System.err), 0); |
| | | "--remove", "allowed-task:org.opends.server.tasks.DummyTask"); |
| | | |
| | | |
| | | // Now verify that we can add the task and have it complete successfully. |
| | |
| | | |
| | | // Disable the PROXIED_AUTH privilege and verify that the operation now |
| | | // succeeds. |
| | | String[] configArgs = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--add", "disabled-privilege:proxied-auth" |
| | | }; |
| | | assertEquals(DSConfig.main(configArgs, false, System.out, System.err), 0); |
| | | "--add", "disabled-privilege:proxied-auth"); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs, false, null, null), 0); |
| | | |
| | | |
| | | // Re-enable the PROXIED_AUTH privilege and verify that the operation |
| | | // fails again. |
| | | configArgs = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--remove", "disabled-privilege:proxied-auth" |
| | | }; |
| | | assertEquals(DSConfig.main(configArgs, false, System.out, System.err), 0); |
| | | "--remove", "disabled-privilege:proxied-auth"); |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(searchArgs, false, null, null) == 0); |
| | | } |
| | | |