| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.schema.GeneralizedTimeSyntax; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * A set of test cases for the ManageAccount tool. |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass |
| | | public void startServer() |
| | | throws Exception |
| | | public void startServer() throws Exception |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "get-all" }, |
| | | new Object[] { "get-password-policy-dn" }, |
| | | new Object[] { "get-account-is-disabled" }, |
| | | new Object[] { "set-account-is-disabled" }, |
| | | new Object[] { "clear-account-is-disabled" }, |
| | | new Object[] { "get-account-expiration-time" }, |
| | | new Object[] { "set-account-expiration-time" }, |
| | | new Object[] { "clear-account-expiration-time" }, |
| | | new Object[] { "get-seconds-until-account-expiration" }, |
| | | new Object[] { "get-password-changed-time" }, |
| | | new Object[] { "set-password-changed-time" }, |
| | | new Object[] { "clear-password-changed-time" }, |
| | | new Object[] { "get-password-expiration-warned-time" }, |
| | | new Object[] { "set-password-expiration-warned-time" }, |
| | | new Object[] { "clear-password-expiration-warned-time" }, |
| | | new Object[] { "get-seconds-until-password-expiration" }, |
| | | new Object[] { "get-seconds-until-password-expiration-warning" }, |
| | | new Object[] { "get-authentication-failure-times" }, |
| | | new Object[] { "add-authentication-failure-time" }, |
| | | new Object[] { "set-authentication-failure-times" }, |
| | | new Object[] { "clear-authentication-failure-times" }, |
| | | new Object[] { "get-seconds-until-authentication-failure-unlock" }, |
| | | new Object[] { "get-remaining-authentication-failure-count" }, |
| | | new Object[] { "get-last-login-time" }, |
| | | new Object[] { "set-last-login-time" }, |
| | | new Object[] { "clear-last-login-time" }, |
| | | new Object[] { "get-seconds-until-idle-lockout" }, |
| | | new Object[] { "get-password-is-reset" }, |
| | | new Object[] { "set-password-is-reset" }, |
| | | new Object[] { "clear-password-is-reset" }, |
| | | new Object[] { "get-seconds-until-password-reset-lockout" }, |
| | | new Object[] { "get-grace-login-use-times" }, |
| | | new Object[] { "add-grace-login-use-time" }, |
| | | new Object[] { "set-grace-login-use-times" }, |
| | | new Object[] { "clear-grace-login-use-times" }, |
| | | new Object[] { "get-remaining-grace-login-count" }, |
| | | new Object[] { "get-password-changed-by-required-time" }, |
| | | new Object[] { "set-password-changed-by-required-time" }, |
| | | new Object[] { "clear-password-changed-by-required-time" }, |
| | | new Object[] { "get-seconds-until-required-change-time" }, |
| | | new Object[] { "get-password-history" }, |
| | | new Object[] { "clear-password-history" } |
| | | { "get-all" }, |
| | | { "get-password-policy-dn" }, |
| | | { "get-account-is-disabled" }, |
| | | { "set-account-is-disabled" }, |
| | | { "clear-account-is-disabled" }, |
| | | { "get-account-expiration-time" }, |
| | | { "set-account-expiration-time" }, |
| | | { "clear-account-expiration-time" }, |
| | | { "get-seconds-until-account-expiration" }, |
| | | { "get-password-changed-time" }, |
| | | { "set-password-changed-time" }, |
| | | { "clear-password-changed-time" }, |
| | | { "get-password-expiration-warned-time" }, |
| | | { "set-password-expiration-warned-time" }, |
| | | { "clear-password-expiration-warned-time" }, |
| | | { "get-seconds-until-password-expiration" }, |
| | | { "get-seconds-until-password-expiration-warning" }, |
| | | { "get-authentication-failure-times" }, |
| | | { "add-authentication-failure-time" }, |
| | | { "set-authentication-failure-times" }, |
| | | { "clear-authentication-failure-times" }, |
| | | { "get-seconds-until-authentication-failure-unlock" }, |
| | | { "get-remaining-authentication-failure-count" }, |
| | | { "get-last-login-time" }, |
| | | { "set-last-login-time" }, |
| | | { "clear-last-login-time" }, |
| | | { "get-seconds-until-idle-lockout" }, |
| | | { "get-password-is-reset" }, |
| | | { "set-password-is-reset" }, |
| | | { "clear-password-is-reset" }, |
| | | { "get-seconds-until-password-reset-lockout" }, |
| | | { "get-grace-login-use-times" }, |
| | | { "add-grace-login-use-time" }, |
| | | { "set-grace-login-use-times" }, |
| | | { "clear-grace-login-use-times" }, |
| | | { "get-remaining-grace-login-count" }, |
| | | { "get-password-changed-by-required-time" }, |
| | | { "set-password-changed-by-required-time" }, |
| | | { "clear-password-changed-by-required-time" }, |
| | | { "get-seconds-until-required-change-time" }, |
| | | { "get-password-history" }, |
| | | { "clear-password-history" } |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "get-all" }, |
| | | new Object[] { "get-password-policy-dn" }, |
| | | new Object[] { "get-account-is-disabled" }, |
| | | new Object[] { "get-account-expiration-time" }, |
| | | new Object[] { "get-seconds-until-account-expiration" }, |
| | | new Object[] { "get-password-changed-time" }, |
| | | new Object[] { "get-password-expiration-warned-time" }, |
| | | new Object[] { "get-seconds-until-password-expiration" }, |
| | | new Object[] { "get-seconds-until-password-expiration-warning" }, |
| | | new Object[] { "get-authentication-failure-times" }, |
| | | new Object[] { "get-seconds-until-authentication-failure-unlock" }, |
| | | new Object[] { "get-remaining-authentication-failure-count" }, |
| | | new Object[] { "get-last-login-time" }, |
| | | new Object[] { "get-seconds-until-idle-lockout" }, |
| | | new Object[] { "get-password-is-reset" }, |
| | | new Object[] { "get-seconds-until-password-reset-lockout" }, |
| | | new Object[] { "get-grace-login-use-times" }, |
| | | new Object[] { "get-remaining-grace-login-count" }, |
| | | new Object[] { "get-password-changed-by-required-time" }, |
| | | new Object[] { "get-seconds-until-required-change-time" }, |
| | | new Object[] { "get-password-history" } |
| | | { "get-all" }, |
| | | { "get-password-policy-dn" }, |
| | | { "get-account-is-disabled" }, |
| | | { "get-account-expiration-time" }, |
| | | { "get-seconds-until-account-expiration" }, |
| | | { "get-password-changed-time" }, |
| | | { "get-password-expiration-warned-time" }, |
| | | { "get-seconds-until-password-expiration" }, |
| | | { "get-seconds-until-password-expiration-warning" }, |
| | | { "get-authentication-failure-times" }, |
| | | { "get-seconds-until-authentication-failure-unlock" }, |
| | | { "get-remaining-authentication-failure-count" }, |
| | | { "get-last-login-time" }, |
| | | { "get-seconds-until-idle-lockout" }, |
| | | { "get-password-is-reset" }, |
| | | { "get-seconds-until-password-reset-lockout" }, |
| | | { "get-grace-login-use-times" }, |
| | | { "get-remaining-grace-login-count" }, |
| | | { "get-password-changed-by-required-time" }, |
| | | { "get-seconds-until-required-change-time" }, |
| | | { "get-password-history" } |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "set-account-is-disabled" }, |
| | | new Object[] { "set-password-is-reset" }, |
| | | { "set-account-is-disabled" }, |
| | | { "set-password-is-reset" }, |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "set-account-expiration-time" }, |
| | | new Object[] { "set-password-changed-time" }, |
| | | new Object[] { "set-password-expiration-warned-time" }, |
| | | new Object[] { "set-authentication-failure-times" }, |
| | | new Object[] { "add-authentication-failure-time" }, |
| | | new Object[] { "set-last-login-time" }, |
| | | new Object[] { "set-grace-login-use-times" }, |
| | | new Object[] { "add-grace-login-use-time" }, |
| | | new Object[] { "set-password-changed-by-required-time" }, |
| | | { "set-account-expiration-time" }, |
| | | { "set-password-changed-time" }, |
| | | { "set-password-expiration-warned-time" }, |
| | | { "set-authentication-failure-times" }, |
| | | { "add-authentication-failure-time" }, |
| | | { "set-last-login-time" }, |
| | | { "set-grace-login-use-times" }, |
| | | { "add-grace-login-use-time" }, |
| | | { "set-password-changed-by-required-time" }, |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "clear-account-is-disabled" }, |
| | | new Object[] { "clear-account-expiration-time" }, |
| | | new Object[] { "clear-password-changed-time" }, |
| | | new Object[] { "clear-password-expiration-warned-time" }, |
| | | new Object[] { "clear-authentication-failure-times" }, |
| | | new Object[] { "clear-last-login-time" }, |
| | | new Object[] { "clear-password-is-reset" }, |
| | | new Object[] { "clear-grace-login-use-times" }, |
| | | new Object[] { "clear-password-changed-by-required-time" }, |
| | | new Object[] { "clear-password-history" } |
| | | { "clear-account-is-disabled" }, |
| | | { "clear-account-expiration-time" }, |
| | | { "clear-password-changed-time" }, |
| | | { "clear-password-expiration-warned-time" }, |
| | | { "clear-authentication-failure-times" }, |
| | | { "clear-last-login-time" }, |
| | | { "clear-password-is-reset" }, |
| | | { "clear-grace-login-use-times" }, |
| | | { "clear-password-changed-by-required-time" }, |
| | | { "clear-password-history" } |
| | | }; |
| | | } |
| | | |
| | | |
| | | private int manageAccountMain(String... args) |
| | | { |
| | | return ManageAccount.main(args, false, null, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Tests the various sets of arguments that may be used to get usage |
| | | * information when no subcommand is given. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testHelpNoSubCommand() |
| | | { |
| | | assertEquals(ManageAccount.main(new String[] { "-H" }, |
| | | false, null, System.err), |
| | | 0); |
| | | assertEquals(ManageAccount.main(new String[] { "--help" }, false, null, |
| | | System.err), |
| | | 0); |
| | | assertEquals(ManageAccount.main(new String[] { "-?" }, false, |
| | | null, System.err), |
| | | 0); |
| | | assertEquals(manageAccountMain("-H"), 0); |
| | | assertEquals(manageAccountMain("--help"), 0); |
| | | assertEquals(manageAccountMain("-?"), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "--help" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the manage-account tool without any subcommand. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testNoSubCommand() |
| | | { |
| | | String[] args = |
| | |
| | | /** |
| | | * Tests the manage-account tool with an invalid subcommand. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testInvalidSubCommand() |
| | | { |
| | | String[] args = |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | assertFalse(manageAccountMain(args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | assertFalse(manageAccountMain(args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test", |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "not-appropriate-for-this-subcommand" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | assertFalse(manageAccountMain(args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "true" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "false" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "nonboolean" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | assertFalse(manageAccountMain(args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test" |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", GeneralizedTimeSyntax.format(System.currentTimeMillis()) |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-O", "invalid" |
| | | }; |
| | | |
| | | assertFalse(ManageAccount.main(args, false, null, System.err) == 0); |
| | | assertFalse(manageAccountMain(args) == 0); |
| | | } |
| | | |
| | | |
| | |
| | | "-b", "uid=test.user,o=test", |
| | | }; |
| | | |
| | | assertEquals(ManageAccount.main(args, false, null, System.err), 0); |
| | | assertEquals(manageAccountMain(args), 0); |
| | | } |
| | | } |
| | | |