| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | /** |
| | | * Configuration Tester. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(groups = {"slow"}) |
| | | public class ConfigurationTest extends QuickSetupTestCase { |
| | | |
| | | Configuration config; |
| | | private Configuration config; |
| | | |
| | | @BeforeClass |
| | | public void setUp() throws Exception { |
| | |
| | | |
| | | @Test(enabled = false) |
| | | public void testGetPort() throws IOException { |
| | | assertTrue(TestUtilities.ldapPort.equals(config.getPort())); |
| | | assertEquals(TestUtilities.ldapPort, (Integer) config.getPort()); |
| | | } |
| | | |
| | | @Test(enabled = false) |
| | |
| | | /** |
| | | * FileManager Tester. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test(groups = {"slow"}, sequential=true) |
| | | public class FileManagerTest extends QuickSetupTestCase { |
| | | |
| | | File fmWorkspace; |
| | | FileManager fileManager; |
| | | private File fmWorkspace; |
| | | private FileManager fileManager; |
| | | |
| | | @BeforeClass |
| | | public void setUp() throws Exception { |
| | |
| | | |
| | | // Make sure files we deleted above were copied from the source dir |
| | | assertTrue(t_f2b1.exists()); |
| | | assertTrue(childOfS.equals(contentsOf(t_f2b1))); |
| | | assertEquals(childOfS, contentsOf(t_f2b1)); |
| | | |
| | | assertTrue(t_d2b.exists()); |
| | | |
| | | assertTrue(t_f1a.exists()); |
| | | assertTrue(childOfS.equals(contentsOf(t_f1a))); |
| | | assertEquals(childOfS, contentsOf(t_f1a)); |
| | | |
| | | // Make sure files that pre-existed didn't get touched |
| | | assertTrue(childOfT.equals(contentsOf(t_f1b))); |
| | | assertTrue(childOfT.equals(contentsOf(t_f2a))); |
| | | assertEquals(childOfT, contentsOf(t_f1b)); |
| | | assertEquals(childOfT, contentsOf(t_f2a)); |
| | | } |
| | | |
| | | /** |
| | | * Tests the rename. |
| | | * @throws Exception |
| | | */ |
| | | /** Tests the rename. */ |
| | | @Test |
| | | public void testRenameNonExistentTarget() throws Exception { |
| | | File src = File.createTempFile("src", null); |
| | |
| | | FileManager.DeletionPolicy.DELETE_IMMEDIATELY); |
| | | assertTrue(dir.exists()); |
| | | // Make sure we didn't lose any kids |
| | | assertTrue(childCount == countSelfAndAllChildren(dir)); |
| | | assertEquals(childCount, countSelfAndAllChildren(dir)); |
| | | |
| | | // Test that using a filter to delete one file works |
| | | FileFilter killChildFileFilter = new FileFilter() { |
| | |
| | | fileManager.deleteRecursively(dir, killChildFileFilter, |
| | | FileManager.DeletionPolicy.DELETE_IMMEDIATELY); |
| | | assertTrue(dir.exists()); |
| | | assertTrue((childCount -1) == countSelfAndAllChildren(dir)); |
| | | assertEquals((childCount -1), countSelfAndAllChildren(dir)); |
| | | assertFalse(f2b1.exists()); |
| | | } |
| | | |
| | |
| | | assertTrue(children == null || children.length == 0); |
| | | fileManager.copy(file, dir); |
| | | assertTrue(file.exists()); |
| | | assertTrue(dir.list().length == 1); |
| | | assertEquals(dir.list().length, 1); |
| | | } |
| | | |
| | | /** |
| | |
| | | String ORIGINAL_CHILD_CONTENT = "orinld"; |
| | | writeContents(dirChild, ORIGINAL_CHILD_CONTENT); |
| | | |
| | | // Try a copy without overwriting and make sure the original |
| | | // file didn't get replaced. |
| | | // Try a copy without overwriting and make sure the original file didn't get replaced. |
| | | fileManager.copy(file, dir, false); |
| | | assertTrue(contentsOf(dirChild).equals(ORIGINAL_CHILD_CONTENT)); |
| | | assertEquals(contentsOf(dirChild), ORIGINAL_CHILD_CONTENT); |
| | | |
| | | // New try a copy with overwrite true and make sure the original |
| | | // file got replaced. |
| | | // New try a copy with overwrite true and make sure the original file got replaced. |
| | | fileManager.copy(file, dir, true); |
| | | assertTrue(contentsOf(dirChild).equals(NEW_CHILD_CONTENT)); |
| | | assertEquals(contentsOf(dirChild), NEW_CHILD_CONTENT); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | File copiedSource = new File(dest, "source"); |
| | | assertTrue(copiedSource.exists()); |
| | | assertTrue(count == countSelfAndAllChildren(copiedSource)); |
| | | assertEquals(count, countSelfAndAllChildren(copiedSource)); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | File copiedSource = new File(dest, "source"); |
| | | assertFalse(copiedSource.exists()); |
| | | assertTrue(countSelfAndAllChildren(dest) == 1); |
| | | assertEquals(countSelfAndAllChildren(dest), 1); |
| | | |
| | | // Test that using a filter to delete one file works |
| | | FileFilter copyChildFileFilter = new FileFilter() { |
| | |
| | | File copiedD2b = new File(d2, "d2b"); |
| | | final File copiedF2b1 = new File(d2b, "f2b1"); |
| | | assertTrue(copiedSource.exists()); |
| | | assertTrue(countSelfAndAllChildren(copiedSource) == 4); |
| | | assertEquals(countSelfAndAllChildren(copiedSource), 4); |
| | | assertTrue(copiedD2.exists()); |
| | | assertTrue(countSelfAndAllChildren(copiedD2) == 3); |
| | | assertEquals(countSelfAndAllChildren(copiedD2), 3); |
| | | assertTrue(copiedD2b.exists()); |
| | | assertTrue(countSelfAndAllChildren(copiedD2b) == 2); |
| | | assertEquals(countSelfAndAllChildren(copiedD2b), 2); |
| | | assertTrue(copiedF2b1.exists()); |
| | | } |
| | | |
| | |
| | | }; |
| | | // With overwrite off make sure it doesn't get replaced |
| | | fileManager.copyRecursively(source, dest, copyChildFileFilter, false); |
| | | assertTrue(ORIGINAL.equals(contentsOf(copiedF2b1))); |
| | | assertEquals(ORIGINAL, contentsOf(copiedF2b1)); |
| | | |
| | | // Now with overwrite make sure it gets replaced. |
| | | fileManager.copyRecursively(source, dest, copyChildFileFilter, true); |
| | | assertTrue(ORIGINAL.equals(contentsOf(copiedF2b1))); |
| | | assertEquals(ORIGINAL, contentsOf(copiedF2b1)); |
| | | } |
| | | |
| | | @DataProvider(name = "differTestData") |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.quicksetup.util; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | |
| | | @Test(dataProvider = "breakHtmlStringData") |
| | | public void testBreakHtmlString(String s, int maxll, String expectedValue) { |
| | | assertTrue(Utils.breakHtmlString(s, maxll).equals(expectedValue)); |
| | | assertEquals(Utils.breakHtmlString(s, maxll), expectedValue); |
| | | } |
| | | |
| | | @DataProvider(name = "stripHtmlData") |
| | |
| | | |
| | | @Test(enabled = false, dataProvider = "stripHtmlData") |
| | | public void testStripHtml(String html, String expectedResult) { |
| | | assertTrue(expectedResult.equals(Utils.stripHtml(html))); |
| | | assertEquals(expectedResult, Utils.stripHtml(html)); |
| | | } |
| | | |
| | | @DataProvider(name = "containsHtmlData") |
| | |
| | | |
| | | @Test(enabled = false, dataProvider = "containsHtmlData") |
| | | public void testContainsHtml(String s, boolean expectedResult) { |
| | | assertTrue(expectedResult == Utils.containsHtml(s)); |
| | | assertEquals(expectedResult, Utils.containsHtml(s)); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.LDIFReader; |
| | | import org.testng.Assert; |
| | | |
| | | import com.forgerock.opendj.util.OperatingSystem; |
| | | |
| | |
| | | } |
| | | return dump.toString(); |
| | | } |
| | | |
| | | /** FIXME Replace with {@link Assert#assertNotEquals(Object, Object)} once we upgrade to testng >= 6.1. */ |
| | | public static void assertNotEquals(Object actual1, Object actual2) |
| | | { |
| | | assertNotEquals(actual1, actual2, null); |
| | | } |
| | | |
| | | /** FIXME Replace with {@link Assert#assertNotEquals(Object, Object, String)} once we upgrade to testng >= 6.1. */ |
| | | public static void assertNotEquals(Object actual1, Object actual2, String message) |
| | | { |
| | | boolean fail = false; |
| | | try |
| | | { |
| | | Assert.assertEquals(actual1, actual2); |
| | | fail = true; |
| | | } |
| | | catch (AssertionError e) |
| | | { |
| | | } |
| | | if (fail) |
| | | { |
| | | Assert.fail(message); |
| | | } |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.admin; |
| | | |
| | | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * ManagedObjectPath test cases. |
| | | */ |
| | |
| | | @Test |
| | | public void testEmptyPathHasNoRelation() { |
| | | ManagedObjectPath<?, ?> path = ManagedObjectPath.emptyPath(); |
| | | assertEquals(path.getRelationDefinition(), null); |
| | | assertNull(path.getRelationDefinition()); |
| | | } |
| | | |
| | | |
| | |
| | | assertTrue(child1.matches(child2)); |
| | | assertTrue(child2.matches(child1)); |
| | | |
| | | assertTrue(child1.equals(child1)); |
| | | assertTrue(child2.equals(child2)); |
| | | assertFalse(child1.equals(child2)); |
| | | assertFalse(child2.equals(child1)); |
| | | assertEquals(child1, child1); |
| | | assertEquals(child2, child2); |
| | | assertNotEquals(child1, child2); |
| | | assertNotEquals(child2, child1); |
| | | |
| | | assertFalse(child1.matches(child3)); |
| | | assertFalse(child2.matches(child3)); |
| | | assertFalse(child3.matches(child1)); |
| | | assertFalse(child3.matches(child2)); |
| | | |
| | | assertFalse(child1.equals(child3)); |
| | | assertFalse(child2.equals(child3)); |
| | | assertFalse(child3.equals(child1)); |
| | | assertFalse(child3.equals(child2)); |
| | | assertNotEquals(child1, child3); |
| | | assertNotEquals(child2, child3); |
| | | assertNotEquals(child3, child1); |
| | | assertNotEquals(child3, child2); |
| | | } |
| | | |
| | | /** |
| | |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(1); |
| | | SizePropertyDefinition spd = buildTestDefinition(builder); |
| | | assertTrue(spd.getLowerLimit() == 1); |
| | | assertEquals(spd.getLowerLimit(), 1); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param expectedValue to compare |
| | | */ |
| | | @Test(dataProvider = "stringLimitData") |
| | | public void testLowerLimit2(String limit, Long expectedValue) { |
| | | public void testLowerLimit2(String limit, long expectedValue) { |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(limit); |
| | | SizePropertyDefinition spd = buildTestDefinition(builder); |
| | | assertTrue(spd.getLowerLimit() == expectedValue); |
| | | assertEquals(spd.getLowerLimit(), expectedValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setLowerLimit(1); |
| | | SizePropertyDefinition spd = buildTestDefinition(builder); |
| | | assertTrue(spd.getLowerLimit() == 1); |
| | | assertEquals(spd.getLowerLimit(), 1); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param expectedValue to compare |
| | | */ |
| | | @Test(dataProvider = "stringLimitData") |
| | | public void testUpperLimit2(String limit, long expectedValue) { |
| | | public void testUpperLimit2(String limit, Long expectedValue) { |
| | | SizePropertyDefinition.Builder builder = createTestBuilder(); |
| | | builder.setUpperLimit(limit); |
| | | SizePropertyDefinition spd = buildTestDefinition(builder); |
| | | assertTrue(spd.getUpperLimit().equals(expectedValue)); |
| | | assertEquals(spd.getUpperLimit(), expectedValue); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.admin.client.ldap; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | import org.testng.Assert; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A mock LDAP connection which is used to verify that an add |
| | |
| | | * Asserts that the entry was created. |
| | | */ |
| | | public void assertEntryIsCreated() { |
| | | Assert.assertTrue(alreadyAdded); |
| | | assertTrue(alreadyAdded); |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public void createEntry(LdapName dn, Attributes attributes) |
| | | throws NamingException { |
| | | Assert.assertFalse(alreadyAdded); |
| | | Assert.assertEquals(dn, expectedDN); |
| | | assertFalse(alreadyAdded); |
| | | assertEquals(dn, expectedDN); |
| | | |
| | | Map<String, List<String>> expected = new HashMap<String, List<String>>( |
| | | this.attributes); |
| | | Map<String, List<String>> expected = new HashMap<>(this.attributes); |
| | | NamingEnumeration<? extends Attribute> ne = attributes.getAll(); |
| | | while (ne.hasMore()) { |
| | | Attribute attribute = ne.next(); |
| | | String attrID = attribute.getID(); |
| | | List<String> values = expected.remove(attrID); |
| | | if (values == null) { |
| | | Assert.fail("Unexpected attribute " + attrID); |
| | | } |
| | | assertNotNull(values, "Unexpected attribute " + attrID); |
| | | assertAttributeEquals(attribute, values); |
| | | } |
| | | |
| | | if (!expected.isEmpty()) { |
| | | Assert.fail("Missing expected attributes: " + expected.keySet()); |
| | | } |
| | | assertTrue(expected.isEmpty(), "Missing expected attributes: " + expected.keySet()); |
| | | |
| | | alreadyAdded = true; |
| | | } |
| | |
| | | .getInstance(), "test child new", null); |
| | | |
| | | // Check pre-commit values. |
| | | Assert.assertEquals(child.isMandatoryBooleanProperty(), null); |
| | | Assert.assertNull(child.isMandatoryBooleanProperty()); |
| | | Assert.assertEquals(child.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert |
| | | .assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null); |
| | | Assert.assertNull(child.getMandatoryReadOnlyAttributeTypeProperty()); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), |
| | | "dc=domain1,dc=com", "dc=domain2,dc=com", "dc=domain3,dc=com"); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), |
| | |
| | | .getInstance(), "test child new", null); |
| | | |
| | | // Check pre-commit values. |
| | | Assert.assertEquals(child.isMandatoryBooleanProperty(), null); |
| | | Assert.assertNull(child.isMandatoryBooleanProperty()); |
| | | Assert.assertEquals(child.getMandatoryClassProperty(), |
| | | "org.opends.server.extensions.UserDefinedVirtualAttributeProvider"); |
| | | Assert |
| | | .assertEquals(child.getMandatoryReadOnlyAttributeTypeProperty(), null); |
| | | Assert.assertNull(child.getMandatoryReadOnlyAttributeTypeProperty()); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty1(), |
| | | "dc=default value p2v1,dc=com", "dc=default value p2v2,dc=com"); |
| | | assertDNSetEquals(child.getOptionalMultiValuedDNProperty2(), |
| | |
| | | */ |
| | | package org.opends.server.admin.client.ldap; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.forgerock.util.Reject; |
| | | import org.testng.Assert; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A mock LDAP connection which is used to verify that a modify |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void modifyEntry(LdapName dn, Attributes mods) throws NamingException { |
| | | Assert.assertFalse(alreadyModified); |
| | | Assert.assertEquals(dn, expectedDN); |
| | | assertFalse(alreadyModified); |
| | | assertEquals(dn, expectedDN); |
| | | |
| | | Map<String, List<String>> expected = new HashMap<String, List<String>>( |
| | | modifications); |
| | | Map<String, List<String>> expected = new HashMap<>(modifications); |
| | | NamingEnumeration<? extends Attribute> ne = mods.getAll(); |
| | | while (ne.hasMore()) { |
| | | Attribute mod = ne.next(); |
| | | String attrID = mod.getID(); |
| | | List<String> values = expected.remove(attrID); |
| | | if (values == null) { |
| | | Assert.fail("Unexpected modification to attribute " + attrID); |
| | | } |
| | | assertNotNull(values, "Unexpected modification to attribute " + attrID); |
| | | assertAttributeEquals(mod, values); |
| | | } |
| | | |
| | | if (!expected.isEmpty()) { |
| | | Assert.fail("Missing modifications to: " + expected.keySet()); |
| | | } |
| | | assertTrue(expected.isEmpty(), "Missing modifications to: " + expected.keySet()); |
| | | |
| | | alreadyModified = true; |
| | | } |
| | |
| | | PropertySet ps = createTestPropertySet(pp); |
| | | Property<T> p = ps.getProperty(pd); |
| | | SortedSet<T> ss = p.getActiveValues(); |
| | | assertTrue(ss.size() == values.size()); |
| | | assertEquals(ss.size(), values.size()); |
| | | for (T v : values) { |
| | | assertTrue(ss.contains(v)); |
| | | } |
| | |
| | | ps.setPropertyValues(pd, newValues); |
| | | |
| | | Set<T> ev2 = p.getEffectiveValues(); |
| | | assertTrue(ev2.size() == newValues.size()); |
| | | assertEquals(ev2.size(), newValues.size()); |
| | | for(T v : ev2) { |
| | | assertTrue(newValues.contains(v)); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | package org.opends.server.api; |
| | | |
| | | |
| | | |
| | | import java.net.Socket; |
| | | import java.util.ArrayList; |
| | | import java.util.Set; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | |
| | | int returnCode = LDAPPasswordModify.mainPasswordModify(args, false, null, |
| | | null); |
| | | assertFalse(returnCode == 0); |
| | | assertNotEquals(returnCode, 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | message = r.readMessage(); |
| | | ModifyResponseProtocolOp modifyResponse = |
| | | message.getModifyResponseProtocolOp(); |
| | | assertFalse(modifyResponse.getResultCode() == 0); |
| | | assertNotEquals(modifyResponse.getResultCode(), 0); |
| | | |
| | | assertEquals(TestPasswordValidator.getLastNewPassword(), |
| | | ByteString.valueOf("newPassword")); |
| | |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | * |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | String userResults = |
| | | ldapCompare(adminParam.getLdapCompareArgs("cn:level3 user"), |
| | | LDAPResultCode.COMPARE_TRUE); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | assertNotEquals(userResults, ""); |
| | | } |
| | | |
| | | |
| | |
| | | makeModDN(SALES_DN, "cn=sales dept", "0", MANAGER_NEW_DN); |
| | | modEntries(modrdnLdif, LEVEL_1_USER_DN, "pa$$word", PROXY_USER_DN); |
| | | String userNewResults = ldapSearch(userParamNew.getLdapSearchArgs()); |
| | | Assert.assertFalse(userNewResults.equals("")); |
| | | assertNotEquals(userNewResults, ""); |
| | | String modrdnLdif1 = |
| | | makeModDN(SALES_NEW_DN, "cn=sales dept", "0", MANAGER_DN); |
| | | modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word", PROXY_USER_DN); |
| | | String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs()); |
| | | Assert.assertFalse(userOrigResults.equals("")); |
| | | assertNotEquals(userOrigResults, ""); |
| | | } |
| | | } |
| | | |
| | |
| | | makeModDN(SALES_DN, "cn=sales dept", "0", MANAGER_NEW_DN); |
| | | modEntries(modrdnLdif, LEVEL_1_USER_DN, "pa$$word"); |
| | | String userNewResults = ldapSearch(userParamNew.getLdapSearchArgs()); |
| | | Assert.assertFalse(userNewResults.equals("")); |
| | | assertNotEquals(userNewResults, ""); |
| | | String modrdnLdif1 = |
| | | makeModDN(SALES_NEW_DN, "cn=sales dept", "0", MANAGER_DN); |
| | | modEntries(modrdnLdif1, LEVEL_1_USER_DN, "pa$$word"); |
| | | String userOrigResults = ldapSearch(userParamOrig.getLdapSearchArgs()); |
| | | Assert.assertFalse(userOrigResults.equals("")); |
| | | assertNotEquals(userOrigResults, ""); |
| | | } |
| | | } |
| | | |
| | |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(DNS_ALL_ACI, DIR_MGR_DN, DIR_MGR_PW); |
| | | String userResults = ldapSearch(userParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | assertNotEquals(userResults, ""); |
| | | } |
| | | } |
| | | |
| | |
| | | addEntries(BASIC_LDIF__GROUP_SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(GROUP1_GROUPDN_MODS, DIR_MGR_DN, DIR_MGR_PW); |
| | | String userResults = ldapSearch(userParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(userResults.equals("")); |
| | | assertNotEquals(userResults, ""); |
| | | String adminResults = ldapSearch(adminParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(adminResults.equals("")); |
| | | Assert.assertEquals(adminResults, ""); |
| | | } |
| | | } |
| | | |
| | |
| | | addEntries(BASIC_LDIF__SEARCH_TESTS, DIR_MGR_DN, DIR_MGR_PW); |
| | | modEntries(GLOBAL_MODS, DIR_MGR_DN, DIR_MGR_PW); |
| | | String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(monitorResults.equals("")); |
| | | assertNotEquals(monitorResults, ""); |
| | | String baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(baseResults.equals("")); |
| | | assertNotEquals(baseResults, ""); |
| | | deleteAttrFromEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI, true); |
| | | monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(monitorResults.equals("")); |
| | | Assert.assertEquals(monitorResults, ""); |
| | | baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(baseResults.equals("")); |
| | | Assert.assertEquals(baseResults, ""); |
| | | } |
| | | |
| | | @Test(dataProvider = "searchTestParams") |
| | |
| | | diffFromExpected = diffLdif(params._expectedResultsLdif, searchResults); |
| | | |
| | | // Ignoring whitespace the diff should be empty. |
| | | Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0); |
| | | assertEquals(diffFromExpected.trim(), ""); |
| | | } catch (Throwable e) { |
| | | System.err.println( |
| | | "Started with dit:\n" + |
| | |
| | | String diffFromExpected = diffLdif(actualResults, expectedLdif); |
| | | |
| | | // Ignoring whitespace the diff should be empty. |
| | | Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0, |
| | | "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif); |
| | | assertEquals(diffFromExpected.trim(), "", "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif); |
| | | |
| | | |
| | | // Add the ACI: this will prevent the cn and sn attributes from being read |
| | |
| | | diffFromExpected = diffLdif(actualResults, expectedLdif); |
| | | |
| | | // Ignoring whitespace the diff should be empty. |
| | | Assert.assertTrue(diffFromExpected.replaceAll("\\s", "").length() == 0, |
| | | "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif); |
| | | assertEquals(diffFromExpected.trim(), "", "Got: \n" + actualResults + "\nBut expected:\n" + expectedLdif); |
| | | } |
| | | |
| | | |
| | |
| | | null, null, null); |
| | | |
| | | String monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(monitorResults.equals("")); |
| | | assertNotEquals(monitorResults, ""); |
| | | String baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertFalse(baseResults.equals("")); |
| | | assertNotEquals(baseResults, ""); |
| | | deleteAttrFromEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI, true); |
| | | monitorResults = ldapSearch(monitorParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(monitorResults.equals("")); |
| | | Assert.assertEquals(monitorResults, ""); |
| | | baseResults = ldapSearch(baseParam.getLdapSearchArgs()); |
| | | Assert.assertTrue(baseResults.equals("")); |
| | | Assert.assertEquals(baseResults, ""); |
| | | |
| | | // Test selfwrite right. Attempt to bind as level3 user and remove |
| | | // level1 user from a group, should fail. |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | String adminDNResults = |
| | | LDAPSearchParams(adminDN, PWD, null, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(adminDNResults)); |
| | | assertNotEquals(adminDNResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(adminDNResults); |
| | | Assert.assertTrue(attrMap.containsKey(ATTR_USER_PASSWORD)); |
| | | String adminRootDNResults = |
| | | LDAPSearchParams(adminRootDN, PWD, null, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(adminRootDNResults)); |
| | | assertNotEquals(adminRootDNResults, ""); |
| | | Map<String, String> attrMap1 = getAttrMap(adminRootDNResults); |
| | | Assert.assertTrue(attrMap1.containsKey(ATTR_USER_PASSWORD)); |
| | | String rootDNResults = |
| | | LDAPSearchParams(rootDN, PWD, null, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(rootDNResults)); |
| | | assertNotEquals(rootDNResults, ""); |
| | | Map<String, String> attrMap2 = getAttrMap(rootDNResults); |
| | | Assert.assertTrue(attrMap2.containsKey(ATTR_USER_PASSWORD)); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | |
| | | String adminDNResults = |
| | | LDAPSearchParams(user3, PWD, adminDN, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(adminDNResults)); |
| | | assertNotEquals(adminDNResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(adminDNResults); |
| | | Assert.assertTrue(attrMap.containsKey(ATTR_USER_PASSWORD)); |
| | | String adminRootDNResults = |
| | | LDAPSearchParams(user3, PWD, adminRootDN, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(adminRootDNResults)); |
| | | assertNotEquals(adminRootDNResults, ""); |
| | | Map<String, String> attrMap1 = getAttrMap(adminRootDNResults); |
| | | Assert.assertTrue(attrMap1.containsKey(ATTR_USER_PASSWORD)); |
| | | String rootDNResults = |
| | | LDAPSearchParams(user3, PWD, adminDN, null, null, |
| | | user1, pwdFilter, ATTR_USER_PASSWORD); |
| | | Assert.assertFalse("".equals(rootDNResults)); |
| | | assertNotEquals(rootDNResults, ""); |
| | | Map<String, String> attrMap2 = getAttrMap(rootDNResults); |
| | | Assert.assertTrue(attrMap2.containsKey(ATTR_USER_PASSWORD)); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | |
| | | String userResults = |
| | | LDAPSearchParams(DIR_MGR_DN, PWD, null, "dn:", null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, rRights); |
| | | } |
| | |
| | | String userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, rRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", addAci); |
| | |
| | | userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, arRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", delAci); |
| | |
| | | userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, adrRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", writeAci); |
| | |
| | | userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, adrwRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", proxyAci); |
| | |
| | | userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, allRights); |
| | | } |
| | |
| | | String userResults = |
| | | LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, rRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", addAci); |
| | |
| | | userResults = |
| | | LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, arRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", delAci); |
| | |
| | | userResults = |
| | | LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, adrRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", writeAci); |
| | |
| | | userResults = |
| | | LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, adrwRights); |
| | | aciLdif=makeAddLDIF("aci", "ou=People,o=test", proxyAci); |
| | |
| | | userResults = |
| | | LDAPSearchCtrl(superUser, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | attrMap=getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, allRights); |
| | | } |
| | |
| | | String userResults = |
| | | LDAPSearchCtrl(DIR_MGR_DN, PWD, null, OID_GET_EFFECTIVE_RIGHTS, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkEntryLevel(attrMap, bypassRights); |
| | | } |
| | |
| | | String userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, null, |
| | | base, filter, "aclRights mail description"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkAttributeLevel(attrMap, "mail", srwMailAttrRights); |
| | | checkAttributeLevel(attrMap, "description", srDescrptionAttrRights); |
| | |
| | | String userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + superUser, attrList, |
| | | base, filter, "aclRights mail description"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkAttributeLevel(attrMap, "mail", srwMailAttrRights); |
| | | checkAttributeLevel(attrMap, "description", srDescrptionAttrRights); |
| | |
| | | String userResults = |
| | | LDAPSearchParams(superUser, PWD, null, "dn: " + user1, memberAttrList, |
| | | base, filter, "aclRights"); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkAttributeLevel(attrMap, "member", selfWriteAttrRights); |
| | | } |
| | |
| | | String reqRightsStr) throws Exception { |
| | | String attrType=attributeLevel.toLowerCase() + attr; |
| | | String retRightsStr=attrMap.get(attrType); |
| | | Assert.assertTrue(retRightsStr.equals(reqRightsStr)); |
| | | assertEquals(retRightsStr, reqRightsStr); |
| | | } |
| | | |
| | | private void |
| | | checkEntryLevel(Map<String, String> attrMap, String reqRightsStr) |
| | | throws Exception { |
| | | private void checkEntryLevel(Map<String, String> attrMap, String reqRightsStr) throws Exception { |
| | | String retRightsStr=attrMap.get(entryLevel.toLowerCase()); |
| | | Assert.assertTrue(retRightsStr.equals(reqRightsStr)); |
| | | assertEquals(retRightsStr, reqRightsStr); |
| | | } |
| | | } |
| | |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2015 ForgeRock AS |
| | | */ |
| | | |
| | | |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.Assert; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI; |
| | | |
| | | /** |
| | | * Test the groupdn keyword using nested groups. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class NestedGroupDNTestCase extends AciTestCase { |
| | | |
| | | private static final String peopleBase="ou=People,o=test"; |
| | |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | //Access to user5 should be denied, user5 is not in any groups. |
| | | Assert.assertTrue(userResults.equals("")); |
| | | Assert.assertEquals(userResults, ""); |
| | | //Add user5 to group1. |
| | | String member5Ldif=makeAddLDIF("member", group3DN, user5); |
| | | LDIFModify(member5Ldif, DIR_MGR_DN, PWD); |
| | |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | //Results should be returned since user5 now has access. |
| | | Assert.assertFalse(userResults1.equals("")); |
| | | assertNotEquals(userResults1, ""); |
| | | } |
| | | |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | Assert.assertTrue(userResults.equals("")); |
| | | Assert.assertEquals(userResults, ""); |
| | | //Add group4 (dynamic) to group3. |
| | | String group3Ldif=makeAddLDIF("member", group3DN, group4DN); |
| | | LDIFModify(group3Ldif, DIR_MGR_DN, PWD); |
| | |
| | | String userResults1 = |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | //Results should be returned, since user5 now has access because of |
| | | //nested group4. |
| | | Assert.assertFalse(userResults1.equals("")); |
| | | //Results should be returned, since user5 now has access because of nested group4. |
| | | assertNotEquals(userResults1, ""); |
| | | } |
| | | |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | Assert.assertTrue(userResults.equals("")); |
| | | Assert.assertEquals(userResults, ""); |
| | | //Nest group1 in group3, creating circular nesting. |
| | | String group3Ldif=makeAddLDIF("member", group3DN, group1DN); |
| | | LDIFModify(group3Ldif, DIR_MGR_DN, PWD); |
| | |
| | | LDAPSearchParams(user5, PWD, null, null, null, |
| | | user5, filter, null); |
| | | //Results should not be returned because of circular condition. |
| | | Assert.assertTrue(userResults1.equals("")); |
| | | Assert.assertEquals(userResults1, ""); |
| | | } |
| | | |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, attrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | checkAttributeVal(attrMap, "l", "Austin"); |
| | | checkAttributeVal(attrMap, "sn", "1"); |
| | |
| | | String userResults1 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, attrList1); |
| | | Assert.assertFalse("".equals(userResults1)); |
| | | assertNotEquals(userResults1, ""); |
| | | Map<String, String> attrMap1 = getAttrMap(userResults1); |
| | | checkAttributeVal(attrMap1, "sn", "1"); |
| | | checkAttributeVal(attrMap1, "uid", "user.1"); |
| | |
| | | String userResults2 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, attrList); |
| | | Assert.assertFalse("".equals(userResults2)); |
| | | assertNotEquals(userResults2, ""); |
| | | Map<String, String> attrMap2 = getAttrMap(userResults2); |
| | | checkAttributeVal(attrMap2, "l", "Austin"); |
| | | checkAttributeVal(attrMap2, "sn", "1"); |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | //The aci attribute type is operational, it should not be there. |
| | | //The other two should be there. |
| | | Assert.assertFalse(attrMap.containsKey("aci")); |
| | | Assert.assertTrue(attrMap.containsKey("sn")); |
| | | Assert.assertTrue(attrMap.containsKey("uid")); |
| | | assertFalse(attrMap.containsKey("aci")); |
| | | assertTrue(attrMap.containsKey("sn")); |
| | | assertTrue(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | //Add aci that allows both non-operational attributes and the operational |
| | | //attribute "aci" search/read. |
| | |
| | | String userResults1 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults1)); |
| | | assertNotEquals(userResults1, ""); |
| | | Map<String, String> attrMap1 = getAttrMap(userResults1); |
| | | //All three attributes should be there. |
| | | Assert.assertTrue(attrMap1.containsKey("aci")); |
| | | Assert.assertTrue(attrMap1.containsKey("sn")); |
| | | Assert.assertTrue(attrMap1.containsKey("uid")); |
| | | assertTrue(attrMap1.containsKey("aci")); |
| | | assertTrue(attrMap1.containsKey("sn")); |
| | | assertTrue(attrMap1.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | //Add ACI that only allows only aci operational attribute search/read. |
| | | String aciLdif2=makeAddLDIF("aci", user1, opAttrAci); |
| | |
| | | String userResults2 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, aciFilter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults2)); |
| | | assertNotEquals(userResults2, ""); |
| | | Map<String, String> attrMap2 = getAttrMap(userResults2); |
| | | // Only operational attribute aci should be there, the other two should not. |
| | | Assert.assertTrue(attrMap2.containsKey("aci")); |
| | | Assert.assertFalse(attrMap2.containsKey("sn")); |
| | | Assert.assertFalse(attrMap2.containsKey("uid")); |
| | | assertTrue(attrMap2.containsKey("aci")); |
| | | assertFalse(attrMap2.containsKey("sn")); |
| | | assertFalse(attrMap2.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | } |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | //All should be returned. |
| | | Assert.assertTrue(attrMap.containsKey("aci")); |
| | | Assert.assertTrue(attrMap.containsKey("sn")); |
| | | Assert.assertTrue(attrMap.containsKey("uid")); |
| | | assertTrue(attrMap.containsKey("aci")); |
| | | assertTrue(attrMap.containsKey("sn")); |
| | | assertTrue(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | } |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | //Only aci should be returned. |
| | | Assert.assertTrue(attrMap.containsKey("aci")); |
| | | Assert.assertFalse(attrMap.containsKey("sn")); |
| | | Assert.assertFalse(attrMap.containsKey("uid")); |
| | | assertTrue(attrMap.containsKey("aci")); |
| | | assertFalse(attrMap.containsKey("sn")); |
| | | assertFalse(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | } |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | //All should be returned. |
| | | Assert.assertTrue(attrMap.containsKey("aci")); |
| | | Assert.assertTrue(attrMap.containsKey("sn")); |
| | | Assert.assertTrue(attrMap.containsKey("uid")); |
| | | assertTrue(attrMap.containsKey("aci")); |
| | | assertTrue(attrMap.containsKey("sn")); |
| | | assertTrue(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | } |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, aciFilter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | //All should be returned. |
| | | Assert.assertTrue(attrMap.containsKey("aci")); |
| | | Assert.assertTrue(attrMap.containsKey("sn")); |
| | | Assert.assertTrue(attrMap.containsKey("uid")); |
| | | assertTrue(attrMap.containsKey("aci")); |
| | | assertTrue(attrMap.containsKey("sn")); |
| | | assertTrue(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | //Add two ACIs, one with '+' and the other with '*'. |
| | | String aciLdif1=makeAddLDIF("aci", user1, allOpAttrAci1, userAttrAci); |
| | |
| | | String userResults1 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, aciFilter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults1)); |
| | | assertNotEquals(userResults1, ""); |
| | | Map<String, String> attrMap1 = getAttrMap(userResults1); |
| | | //All should be returned. |
| | | Assert.assertTrue(attrMap1.containsKey("aci")); |
| | | Assert.assertTrue(attrMap1.containsKey("sn")); |
| | | Assert.assertTrue(attrMap1.containsKey("uid")); |
| | | assertTrue(attrMap1.containsKey("aci")); |
| | | assertTrue(attrMap1.containsKey("sn")); |
| | | assertTrue(attrMap1.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | //Add two ACIs, one with '+' and the other with '*'. |
| | | String aciLdif2=makeAddLDIF("aci", user1, notAllOpAttrAci1, userAttrAci); |
| | |
| | | String userResults2 = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, opAttrList); |
| | | Assert.assertFalse("".equals(userResults2)); |
| | | assertNotEquals(userResults2, ""); |
| | | Map<String, String> attrMap2 = getAttrMap(userResults2); |
| | | //Only non-operation should be returned. |
| | | Assert.assertFalse(attrMap2.containsKey("aci")); |
| | | Assert.assertTrue(attrMap2.containsKey("sn")); |
| | | Assert.assertTrue(attrMap2.containsKey("uid")); |
| | | assertFalse(attrMap2.containsKey("aci")); |
| | | assertTrue(attrMap2.containsKey("sn")); |
| | | assertTrue(attrMap2.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | } |
| | | |
| | |
| | | String userResults = |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, attrList); |
| | | Assert.assertFalse("".equals(userResults)); |
| | | assertNotEquals(userResults, ""); |
| | | Map<String, String> attrMap = getAttrMap(userResults); |
| | | Assert.assertTrue(attrMap.containsKey("l")); |
| | | Assert.assertTrue(attrMap.containsKey("sn")); |
| | | Assert.assertTrue(attrMap.containsKey("uid")); |
| | | assertTrue(attrMap.containsKey("l")); |
| | | assertTrue(attrMap.containsKey("sn")); |
| | | assertTrue(attrMap.containsKey("uid")); |
| | | deleteAttrFromEntry(user1, "aci"); |
| | | String aciLdif1=makeAddLDIF("aci", user1, grp1AttrAci); |
| | | LDIFModify(aciLdif1, DIR_MGR_DN, PWD); |
| | |
| | | LDAPSearchParams(user3, PWD, null, null, null, |
| | | user1, filter, attrList); |
| | | //This search should return nothing since the URL has a bogus DN. |
| | | Assert.assertTrue("".equals(userResults1)); |
| | | assertEquals("", userResults1); |
| | | } |
| | | |
| | | private void |
| | | checkAttributeVal(Map<String, String> attrMap, String attr, |
| | | String val) throws Exception { |
| | | String mapVal=attrMap.get(attr); |
| | | Assert.assertTrue(mapVal.equals(val)); |
| | | assertEquals(mapVal, val); |
| | | } |
| | | |
| | | /** New tests to really unit test the isApplicable method. */ |
| | |
| | | if (attrType == null) { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attribute); |
| | | } |
| | | boolean res = TargetAttr.isApplicable(attrType, targetAttr); |
| | | Assert.assertEquals(res, expectedResult); |
| | | assertEquals(TargetAttr.isApplicable(attrType, targetAttr), expectedResult); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.config.ConfigConstants.ATTR_AUTHZ_GLOBAL_ACI; |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.testng.Assert.fail; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.Assert; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TargetTestCase extends AciTestCase |
| | | { |
| | | private static final String testUser="uid=user.3,ou=People,o=test"; |
| | |
| | | boolean match = AciTargets.isTargetApplicable(aci, |
| | | aci.getTargets(), |
| | | DN.valueOf(entryDN)); |
| | | assertTrue(!match, aciString + " in entry " + aciDN + |
| | | " incorrectly applied to " + entryDN); |
| | | assertFalse(match, aciString + " in entry " + aciDN + " incorrectly applied to " + entryDN); |
| | | } |
| | | |
| | | /** |
| | |
| | | String userResults = |
| | | LDAPSearchParams(testUser, PWD, null,null, null, |
| | | testUser, filter, null); |
| | | Assert.assertTrue(userResults.equals("")); |
| | | assertEquals(userResults, ""); |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | { |
| | | DN[] baseDNs = b.getBaseDNs(); |
| | | assertNotNull(baseDNs); |
| | | assertFalse(baseDNs.length == 0); |
| | | assertNotEquals(baseDNs.length, 0); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.backends; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | |
| | | "add: objectClass", |
| | | "objectClass: extensibleObject"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "add: objectClass", |
| | | "objectClass: extensibleObject"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "changetype: modify", |
| | | "delete: attributeTypes"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "changetype: modify", |
| | | "replace: attributeTypes"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | String attrName = "testaddattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testaddattributetypesuccessfulnooid"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testaddattributetypenospacebeforeparenthesis"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | "98-schema-test-attrtype.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | |
| | | "add: attributeTypes", |
| | | "attributeTypes: invalidsyntax"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.99999 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-APPROX 'xxxundefinedxxx' X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "USAGE xxxinvalidxxx X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0); |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " + |
| | | "'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " + |
| | | "'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | String attrName = "testremoveattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testremoveattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testremoveattributetypeundefined"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | String attrName = "name"; |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "uid"; |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testremoveattributetypereferencedbynf"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testremoveattributetypereferencedbydcr"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | |
| | | String attrName = "testremoveatrefbymruat"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | String ocName = "testaddobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | String ocName = "testaddobjectclasssuccessfulnooid"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | "98-schema-test-oc.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | String ocName = "testaddobjectclassmultipleconflicts"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | String ocName = "testremovethenaddobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | "add: objectClasses", |
| | | "objectClasses: invalidsyntax"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddOCUndefinedSuperior' SUP undefined STRUCTURAL " + |
| | | "MUST cn X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "SUP testAddOCObsoleteSuperiorSup STRUCTURAL MUST cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "STRUCTURAL MUST testAddOCObsoleteRequiredAttrAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "STRUCTURAL MAY testAddOCObsoleteOptionalAttrAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddOCUndefinedRequired' SUP top STRUCTURAL " + |
| | | "MUST undefined X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MUST ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddOCUndefinedOptional' SUP top STRUCTURAL " + |
| | | "MAY undefined X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MAY ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddAbstractOCWithNonAbstractSuperior' SUP person " + |
| | | "ABSTRACT MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddAuxiliaryOCWithStructuralSuperior' SUP person " + |
| | | "AUXILIARY MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "'testAddStructuralOCWithAuxiliarySuperior' SUP posixAccount " + |
| | | "STRUCTURAL MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | String ocName = "testremoveobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | String ocName = "person"; |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | |
| | | String ocName = "testremoveobjectclassreferencedbydcr"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | private String[] standardArgs(String path) |
| | | { |
| | | return new String[] { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that doesn't already exist. |
| | |
| | | String nameFormName = "testaddnameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | "98-schema-test-nameform.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | |
| | | String nameFormName = "testaddnameformwithundefinedreqat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithmultipleundefinedreqat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithundefinedoptat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithmultipleundefinedoptat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithundefinedoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithauxiliaryoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testaddnameformwithobsoleteoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | "MUST testAddNFWithObsoleteReqATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MUST cn MAY testAddNFWithObsoleteOptATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | String nameFormName = "testaddnameformocconflict2"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertTrue(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testremovenameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | String nameFormName = "testremovethenaddnameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | "OC testRemoveNameFormReferencedByDSROC MUST cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | String nameFormName = "testremovenameformreferencedbydsrnf"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleSuccessful' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | String ocName = "testaddditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | String ocName = "testreplaceditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | "X-SCHEMA-FILE '98-schema-test-dcr.ldif' " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | String ocName = "testadddcrtoaltschemafileoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | |
| | | "98-schema-test-dcr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | "NAME 'testRemoveThenAddDITContentRule' MAY sn " + |
| | | "NOT description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | String ocName = "testremovethenaddditcontentruleoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleAuxiliaryOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleObsoleteOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleConflictingOC2' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedAuxOC' " + |
| | | "AUX xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "AUX ( posixAccount $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleAuxOCNotAuxOC' " + |
| | | "AUX person X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "AUX ( posixAccount $ person ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "AUX testAddDITContentRuleObsoleteAuxOCAuxiliary " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedReqAT' " + |
| | | "MUST xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MUST ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedOptAT' " + |
| | | "MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MAY ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedNotAT' " + |
| | | "NOT xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NOT ( description $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDCRProhibitReqStructuralAT' " + |
| | | "NOT cn X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testAddDCRProhibitReqAuxiliaryAT' AUX posixAccount " + |
| | | "NOT uid X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MUST testAddDCRObsoleteReqATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "MAY testAddDCRObsoleteOptATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NOT testAddDCRObsoleteNotATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "NAME 'testRemoveDITContentRuleSuccessful' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | String ocName = "testremoveditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | "FORM testAddDITStructureRuleSuccessfulNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999001; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | int ruleID = 999002; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | "X-SCHEMA-FILE '98-schema-test-dsr.ldif' " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999010; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | |
| | | "98-schema-test-dsr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertTrue(schemaFile.exists()); |
| | |
| | | "FORM testRemoveAndAddDITStructureRuleSuccessfulNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999003; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | "FORM xxxundefinedxxx " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999004; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | "FORM testAddDSRUndefinedSuperiorNF SUP 999000 " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999005; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | "FORM testAddDITStructureRuleObsoleteNameFormNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "FORM testAddDITStructureRuleObsoleteSuperiorNF2 SUP 999012 " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "FORM testRemoveDITStructureRuleSuccessfulNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999006; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | "FORM testRemoveSuperiorDITStructureRuleNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999007; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | |
| | |
| | | "FORM testRemoveSuperiorDITStructureRuleNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | args = new String[] |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(), |
| | | "98-schema-test-mru.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | "NAME 'testAddMRUMRUndefined' APPLIES cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | } |
| | | |
| | | assertFalse(LDAPModify.mainModify(args, false, null, null) == 0); |
| | | private int runModify(String[] args) |
| | | { |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | String attrName = "testattributetypesmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | String objectClassName = "testobjectclassesmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(objectClassName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | String nameFormName = "testnameformsmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | String objectClassName = "testditcontentrulesmatchingruleoc"; |
| | | assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | String objectClassName = "testditcontentrulesmatchingruleoc1"; |
| | | assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | String attrName = "testmatchingruleusematchingruleat1"; |
| | | assertNull(DirectoryServer.getSchema().getAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 20); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | } |
| | | |
| | | |
| | |
| | | "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " + |
| | | "MUST testIssue1381AT )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | * are added without a space before closing parenthesis. |
| | | */ |
| | | @Test |
| | | public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception |
| | | public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception |
| | | { |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String path = TestCaseUtils.createTempFile( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | " caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 X-ORIGIN 'RFC 4519')"); |
| | | |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | } |
| | | |
| | | /** |
| | | * Tests to ensure that the schema subentry includes the lastmod attributes |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | // Sleep longer than the TimeThread delay to ensure the modifytimestamp |
| | | // will be different. |
| | | Thread.sleep(6000); |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | |
| | | schemaEntry = DirectoryServer.getEntry(DN.valueOf("cn=schema")); |
| | | assertNotNull(schemaEntry); |
| | |
| | | |
| | | ByteString newMTValue = |
| | | schemaEntry.getAttribute(mtType).get(0).iterator().next(); |
| | | assertFalse(oldMTValue.equals(newMTValue)); |
| | | assertNotEquals(oldMTValue, newMTValue); |
| | | } |
| | | |
| | | |
| | | private int runModifyWithSystemErr(String[] args) |
| | | { |
| | | return LDAPModify.mainModify(args, false, null, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Tests the ability to properly handle adding and removing a schema |
| | |
| | | List<Attribute> listBefore = entryBefore.getAttribute(attrType); |
| | | List<Attribute> listAfter = entryAfter.getAttribute(attrType); |
| | | |
| | | assertTrue(listAfter != null); |
| | | |
| | | assertNotNull(listAfter); |
| | | assertEquals(listBefore.size(), listAfter.size()); |
| | | |
| | | for (Attribute attrBefore : listBefore) { |
| | |
| | | List<Attribute> listBefore = entryBefore.getAttribute(attrType); |
| | | List<Attribute> listAfter = entryAfter.getAttribute(attrType); |
| | | |
| | | assertTrue(listAfter != null); |
| | | |
| | | assertNotNull(listAfter); |
| | | assertEquals(listBefore.size(), listAfter.size()); |
| | | |
| | | for (Attribute attrBefore : listBefore) { |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | int resultCode = TestCaseUtils.applyModifications(true, |
| | | "dn: " + taskDN, |
| | | "changetype: delete"); |
| | | assertFalse(resultCode == 0); |
| | | assertNotEquals(resultCode, 0); |
| | | assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN))); |
| | | } |
| | | |
| | |
| | | "changetype: modify", |
| | | "replace: description", |
| | | "description: foo"); |
| | | assertFalse(resultCode == 0); |
| | | assertNotEquals(resultCode, 0); |
| | | |
| | | |
| | | // Perform a modification to cancel the task. |
| | |
| | | "changetype: modify", |
| | | "add: description", |
| | | "description: foo"); |
| | | assertFalse(resultCode == 0); |
| | | assertNotEquals(resultCode, 0); |
| | | |
| | | |
| | | // Perform a modification to delete that task. |
| | |
| | | // Make sure recurring task iteration got scheduled. |
| | | long tasksCountAfter = taskBackend.numSubordinates(DN.valueOf( |
| | | "cn=Scheduled Tasks,cn=tasks"), true); |
| | | assertTrue(tasksCountAfter == (tasksCountBefore + 1)); |
| | | assertEquals(tasksCountAfter, tasksCountBefore + 1); |
| | | |
| | | // Perform a modification to update a non-state attribute. |
| | | int resultCode = |
| | |
| | | "changetype: modify", |
| | | "replace: ds-recurring-task-schedule", |
| | | "ds-recurring-task-schedule: * * * * *"); |
| | | assertFalse(resultCode == 0); |
| | | assertNotEquals(resultCode, 0); |
| | | |
| | | // Delete recurring task. |
| | | resultCode = |
| | |
| | | // Make sure recurring task iteration got canceled and removed. |
| | | tasksCountAfter = taskBackend.numSubordinates(DN.valueOf( |
| | | "cn=Scheduled Tasks,cn=tasks"), true); |
| | | assertTrue(tasksCountAfter == tasksCountBefore); |
| | | assertEquals(tasksCountAfter, tasksCountBefore); |
| | | } |
| | | |
| | | |
| | |
| | | package org.opends.server.controls; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Set; |
| | | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPReader; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test password control. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class PasswordControlTest |
| | | extends ControlsTestCase |
| | | { |
| | |
| | | @DataProvider(name = "passwordPolicyErrorTypeData") |
| | | public Object[][] createPasswordPolicyErrorTypeData() |
| | | { |
| | | |
| | | HashMap<Integer, String> values = new HashMap<Integer, String>(); |
| | | values.put(0, "passwordExpired"); |
| | | values.put(1, "accountLocked"); |
| | |
| | | values.put(6, "passwordTooShort"); |
| | | values.put(7, "passwordTooYoung"); |
| | | values.put(8, "passwordInHistory"); |
| | | return new Object[][] |
| | | { |
| | | { values } }; |
| | | return new Object[][] { { values } }; |
| | | } |
| | | |
| | | /** |
| | |
| | | @DataProvider(name = "passwordPolicyWarningTypeData") |
| | | public Object[][] createPasswordPolicyWarningTypeData() |
| | | { |
| | | |
| | | HashMap<Byte, String> values = new HashMap<Byte, String>(); |
| | | values.put((byte)0x80, "timeBeforeExpiration"); |
| | | values.put((byte)0x81, "graceAuthNsRemaining"); |
| | | return new Object[][] |
| | | { |
| | | { values } }; |
| | | return new Object[][] { { values } }; |
| | | } |
| | | |
| | | /** |
| | |
| | | // Retrieve the values |
| | | PasswordPolicyWarningType[] vals = PasswordPolicyWarningType.values(); |
| | | |
| | | // Check if we have the correct munber |
| | | // Check if we have the correct number |
| | | assertEquals(vals.length, exceptedValues.size()); |
| | | |
| | | // Check if we have the correct byte value |
| | |
| | | for (int i = 0x70; i < 0x90; i++) |
| | | { |
| | | byte b = new Integer(i).byteValue(); |
| | | if (keys.contains(b)) |
| | | { |
| | | continue; |
| | | } |
| | | else |
| | | if (!keys.contains(b)) |
| | | { |
| | | assertNull(PasswordPolicyWarningType.valueOf(b)); |
| | | PasswordPolicyWarningType val = PasswordPolicyWarningType.valueOf(b); |
| | | assertNull(val); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | @DataProvider(name = "passwordExpiredControlData") |
| | | public Object[][] createPasswordExpiredControlData() |
| | | { |
| | | |
| | | return new Object[][] { |
| | | { true }, |
| | | { false }, |
| | |
| | | try |
| | | { |
| | | pec = PasswordExpiredControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | assertTrue(false, |
| | | "should be allow to create a passwordExpiredControl with value"); |
| | | fail("should be allow to create a passwordExpiredControl with value"); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DirectoryException expected) |
| | | { |
| | | // Normal case |
| | | assertTrue(true, |
| | | "should be allow to create a passwordExpiredControl with value"); |
| | | } |
| | | |
| | | // Check toString |
| | |
| | | @DataProvider(name = "passwordExpiringControlData") |
| | | public Object[][] createPasswordExpiringControlData() |
| | | { |
| | | |
| | | return new Object[][] { |
| | | { true, 1}, |
| | | { false, 2}, |
| | |
| | | try |
| | | { |
| | | pec = PasswordExpiringControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | assertTrue(false, |
| | | "shouldn't be allow to create PasswordExpiringControl without value"); |
| | | fail("shouldn't be allowed to create PasswordExpiringControl without value"); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DirectoryException expected) |
| | | { |
| | | // Normal case |
| | | assertTrue(true, |
| | | "shouldn't be allow to create PasswordExpiringControl without value"); |
| | | } |
| | | |
| | | control = new LDAPControl(OID_NS_PASSWORD_EXPIRING, isCritical, |
| | |
| | | try |
| | | { |
| | | pec = PasswordExpiringControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | assertTrue(false, |
| | | "shouldn't be allow to create PasswordExpiringControl with a wrong value"); |
| | | fail("shouldn't be allowed to create PasswordExpiringControl with a wrong value"); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DirectoryException expected) |
| | | { |
| | | // Normal case |
| | | assertTrue(true, |
| | | "shouldn't be allow to create PasswordExpiringControl with a wrong value"); |
| | | } |
| | | |
| | | // Check encode/decode |
| | |
| | | @DataProvider(name = "passwordPolicyRequestControlData") |
| | | public Object[][] createPasswordPolicyRequestControlData() |
| | | { |
| | | |
| | | return new Object[][] { |
| | | { true}, |
| | | { false}, |
| | |
| | | try |
| | | { |
| | | pec = PasswordPolicyRequestControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | assertTrue(false, |
| | | "should be allow to create a PasswordPolicyRequestControl with value"); |
| | | fail("should be allow to create a PasswordPolicyRequestControl with value"); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DirectoryException expected) |
| | | { |
| | | // Normal case |
| | | assertTrue(true, |
| | | "should be allow to create a PasswordPolicyRequestControl with value"); |
| | | } |
| | | |
| | | // Check toString |
| | |
| | | @DataProvider(name = "passwordPolicyResponseControl") |
| | | public Object[][] createPasswordPolicyResponseControlData() |
| | | { |
| | | |
| | | return new Object[][] { |
| | | { true , -1}, |
| | | { false , -1}, |
| | |
| | | * Test PasswordPolicyResponseControl. |
| | | */ |
| | | @Test(dataProvider = "passwordPolicyResponseControl") |
| | | public void passwordPolicyResponseControlTest( |
| | | boolean isCritical, int warningValue) |
| | | public void passwordPolicyResponseControlTest(boolean isCritical, int warningValue) |
| | | throws Exception |
| | | { |
| | | // Check default constructor |
| | |
| | | // PasswordPolicyErrorType errorType) |
| | | for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values()) |
| | | { |
| | | for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType |
| | | .values()) |
| | | for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType.values()) |
| | | { |
| | | pprc = new PasswordPolicyResponseControl(isCritical, |
| | | warningType, warningValue, errorType); |
| | |
| | | |
| | | |
| | | // check encode/decode |
| | | PasswordPolicyResponseControl control ; |
| | | ByteStringBuilder bsb = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(bsb); |
| | | for (PasswordPolicyErrorType errorType : PasswordPolicyErrorType.values()) |
| | | { |
| | | for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType |
| | | .values()) |
| | | for (PasswordPolicyWarningType warningType : PasswordPolicyWarningType.values()) |
| | | { |
| | | bsb.clear(); |
| | | control = new PasswordPolicyResponseControl(isCritical, |
| | | warningType, warningValue, errorType); |
| | | PasswordPolicyResponseControl control = new PasswordPolicyResponseControl( |
| | | isCritical, warningType, warningValue, errorType); |
| | | control.write(writer); |
| | | LDAPControl c = LDAPReader.readControl(ASN1.getReader(bsb)); |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | |
| | | { |
| | | c = new LDAPControl(OID_PASSWORD_POLICY_CONTROL, isCritical); |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | | assertTrue(false,"the control should have a value"); |
| | | fail("the control should have a value"); |
| | | } |
| | | catch (DirectoryException e) |
| | | catch (DirectoryException expected) |
| | | { |
| | | // normal case |
| | | assertTrue(true,"the control should have a value"); |
| | | } |
| | | |
| | | |
| | |
| | | null, warningValue, errorType); |
| | | control.write(writer); |
| | | c = LDAPReader.readControl(ASN1.getReader(bsb)); |
| | | try |
| | | { |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | | assertNull(pprc.getWarningType()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | assertTrue(false,"We should be able to decode the control"); |
| | | } |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | | assertNull(pprc.getWarningType()); |
| | | |
| | | // check null error type |
| | | bsb.clear(); |
| | |
| | | warningType, warningValue, null); |
| | | control.write(writer); |
| | | c = LDAPReader.readControl(ASN1.getReader(bsb)); |
| | | try |
| | | { |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | | assertNull(pprc.getErrorType()); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | assertTrue(false,"We should be able to decode the control"); |
| | | } |
| | | pprc = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), c.getValue()); |
| | | assertNull(pprc.getErrorType()); |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.RawAttribute; |
| | | import org.opends.server.types.RawModification; |
| | | import org.opends.server.util.StaticUtils; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for (Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | |
| | | |
| | | ArrayList<RawAttribute> rawAttrs = new ArrayList<RawAttribute>(); |
| | |
| | | |
| | | message = r.readMessage(); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | found = false; |
| | | for (Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | |
| | | message = r.readMessage(); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private boolean passwordPolicyControlExists(List<Control> controls, PasswordPolicyErrorType expectedErrorType) |
| | | throws DirectoryException |
| | | { |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl) c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), expectedErrorType); |
| | | found = true; |
| | | } |
| | | } |
| | | return found; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--add", "password-validator:Length-Based Password Validator"); |
| | | setPasswordPolicyProp("--add", "password-validator:Length-Based Password Validator"); |
| | | |
| | | Socket s = new Socket("127.0.0.1", TestCaseUtils.getServerLdapPort()); |
| | | org.opends.server.tools.LDAPReader r = new org.opends.server.tools.LDAPReader(s); |
| | |
| | | |
| | | message = r.readMessage(); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertFalse(addResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--remove", "password-validator:Length-Based Password Validator"); |
| | | setPasswordPolicyProp("--remove", "password-validator:Length-Based Password Validator"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "lockout-failure-count:3"); |
| | | setPasswordPolicyProp("--set", "lockout-failure-count:3"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | |
| | | message = r.readMessage(); |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertFalse(bindResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | } |
| | | |
| | | bindRequest = new BindRequestProtocolOp( |
| | |
| | | |
| | | message = r.readMessage(); |
| | | BindResponseProtocolOp bindResponse = message.getBindResponseProtocolOp(); |
| | | assertFalse(bindResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(bindResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.ACCOUNT_LOCKED); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.ACCOUNT_LOCKED)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "lockout-failure-count:0"); |
| | | setPasswordPolicyProp("--set", "lockout-failure-count:0"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that an appropriate password policy response control is returned for |
| | | * a compare operation when the user's password is in a "must change" state. |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | CompareResponseProtocolOp compareResponse = |
| | | message.getCompareResponseProtocolOp(); |
| | | assertFalse(compareResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(compareResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | DeleteResponseProtocolOp deleteResponse = |
| | | message.getDeleteResponseProtocolOp(); |
| | | assertFalse(deleteResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(deleteResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | "userPassword: password", |
| | | "ds-privilege-name: bypass-acl"); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | "userPassword: password", |
| | | "ds-privilege-name: bypass-acl"); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=authz.user,o=test", |
| | |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "allow-user-password-changes:false"); |
| | | setPasswordPolicyProp("--set", "allow-user-password-changes:false"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | ModifyResponseProtocolOp modifyResponse = |
| | | message.getModifyResponseProtocolOp(); |
| | | assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "allow-user-password-changes:true"); |
| | | setPasswordPolicyProp("--set", "allow-user-password-changes:true"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that an appropriate password policy response control is returned for |
| | | * a modify operation when the proposed password is in the user's password |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-history-count:5"); |
| | | setPasswordPolicyProp("--set", "password-history-count:5"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | ModifyResponseProtocolOp modifyResponse = |
| | | message.getModifyResponseProtocolOp(); |
| | | assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.PASSWORD_IN_HISTORY); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_IN_HISTORY)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-history-count:0"); |
| | | setPasswordPolicyProp("--set", "password-history-count:0"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-change-requires-current-password:true"); |
| | | setPasswordPolicyProp("--set", "password-change-requires-current-password:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | ModifyResponseProtocolOp modifyResponse = |
| | | message.getModifyResponseProtocolOp(); |
| | | assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "password-change-requires-current-password:false"); |
| | | setPasswordPolicyProp("--set", "password-change-requires-current-password:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "min-password-age:24 hours"); |
| | | setPasswordPolicyProp("--set", "min-password-age:24 hours"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | ModifyResponseProtocolOp modifyResponse = |
| | | message.getModifyResponseProtocolOp(); |
| | | assertFalse(modifyResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.PASSWORD_TOO_YOUNG); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.PASSWORD_TOO_YOUNG)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "min-password-age:0 seconds"); |
| | | setPasswordPolicyProp("--set", "min-password-age:0 seconds"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntries( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | ModifyDNResponseProtocolOp modifyDNResponse = |
| | | message.getModifyDNResponseProtocolOp(); |
| | | assertFalse(modifyDNResponse.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(modifyDNResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests that an appropriate password policy response control is returned for |
| | | * a search operation when the user's password is in a "must change" state. |
| | |
| | | { |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:true"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:true"); |
| | | |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user,o=test", |
| | |
| | | message = r.readMessage(); |
| | | SearchResultDoneProtocolOp searchDone = |
| | | message.getSearchResultDoneProtocolOp(); |
| | | assertFalse(searchDone.getResultCode() == LDAPResultCode.SUCCESS); |
| | | assertNotEquals(searchDone.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | controls = message.getControls(); |
| | | assertNotNull(controls); |
| | | assertFalse(controls.isEmpty()); |
| | | |
| | | boolean found = false; |
| | | for(Control c : controls) |
| | | { |
| | | if (c.getOID().equals(OID_PASSWORD_POLICY_CONTROL)) |
| | | { |
| | | PasswordPolicyResponseControl pwpControl; |
| | | if(c instanceof LDAPControl) |
| | | { |
| | | pwpControl = |
| | | PasswordPolicyResponseControl.DECODER.decode(c.isCritical(), ((LDAPControl)c).getValue()); |
| | | } |
| | | else |
| | | { |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | found = true; |
| | | } |
| | | } |
| | | assertTrue(found); |
| | | assertTrue(passwordPolicyControlExists(controls, PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | | TestCaseUtils.dsconfig( |
| | | "set-password-policy-prop", |
| | | "--policy-name", "Default Password Policy", |
| | | "--set", "force-change-on-add:false"); |
| | | setPasswordPolicyProp("--set", "force-change-on-add:false"); |
| | | |
| | | StaticUtils.close(s); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void setPasswordPolicyProp(String arg, String value) |
| | | { |
| | | TestCaseUtils.dsconfig("set-password-policy-prop", "--policy-name", "Default Password Policy", arg, value); |
| | | } |
| | | } |
| | |
| | | package org.opends.server.controls; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | assertFalse(type.compareTo(MODIFY_DN) == 0, |
| | | "couldn't decode a control with previousDN " |
| | | + "not null and type=modDN"); |
| | | assertNotEquals(type.compareTo(MODIFY_DN), 0, |
| | | "couldn't decode a control with previousDN not null and type=modDN"); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | assertFalse(type.compareTo(PersistentSearchChangeType.MODIFY_DN) == 0, |
| | | "couldn't decode a control with previousDN " |
| | | + "not null and type=modDN"); |
| | | assertNotEquals(type.compareTo(PersistentSearchChangeType.MODIFY_DN), 0, |
| | | "couldn't decode a control with previousDN not null and type=modDN"); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | // Try an empty DN, which is acceptable. |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOf("")); |
| | | assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1)); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertTrue(proxyControl.getAuthorizationDN().isRootDN()); |
| | | |
| | |
| | | // Try a valid DN, which is acceptable. |
| | | proxyControl = |
| | | new ProxiedAuthV1Control(ByteString.valueOf("uid=test,o=test")); |
| | | assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1)); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertEquals(proxyControl.getAuthorizationDN(), |
| | | DN.valueOf("uid=test,o=test")); |
| | |
| | | // Try an invalid DN, which will be initally accepted but will fail when |
| | | // attempting to get the authorization DN. |
| | | proxyControl = new ProxiedAuthV1Control(ByteString.valueOf("invalid")); |
| | | assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1)); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | try |
| | | { |
| | |
| | | |
| | | // Try an empty DN, which is acceptable. |
| | | proxyControl = new ProxiedAuthV1Control(DN.rootDN()); |
| | | assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1)); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertTrue(proxyControl.getAuthorizationDN().isRootDN()); |
| | | |
| | |
| | | // Try a valid DN, which is acceptable. |
| | | proxyControl = |
| | | new ProxiedAuthV1Control(DN.valueOf("uid=test,o=test")); |
| | | assertTrue(proxyControl.getOID().equals(OID_PROXIED_AUTH_V1)); |
| | | assertEquals(proxyControl.getOID(), OID_PROXIED_AUTH_V1); |
| | | assertTrue(proxyControl.isCritical()); |
| | | assertEquals(proxyControl.getAuthorizationDN(), |
| | | DN.valueOf("uid=test,o=test")); |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)") |
| | | .addControl(new ServerSideSortRequestControl(true, "givenName:undefinedOrderingMatch")); |
| | | InternalSearchOperation internalSearch = getRootConnection().processSearch(request); |
| | | assertFalse(internalSearch.getResultCode() == ResultCode.SUCCESS); |
| | | assertNotEquals(internalSearch.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | |
| | | |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertFalse; |
| | | import static org.testng.Assert.assertTrue; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.testng.annotations.Test; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests for {@link AdditionalLogItem}. |
| | | */ |
| | |
| | | AdditionalLogItem item = AdditionalLogItem.keyOnly(getClass(), "testKey"); |
| | | assertEquals(item.getSource(), getClass()); |
| | | assertEquals(item.getKey(), "testKey"); |
| | | assertEquals(item.getValue(), null); |
| | | assertNull(item.getValue()); |
| | | assertEquals(item.toString(), "testKey"); |
| | | assertEquals(item.toString(new StringBuilder()).toString(), "testKey"); |
| | | } |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | |
| | | |
| | | // Build the array of connections we will use to perform the tests. |
| | | connections.put(new InternalClientConnection(new AuthenticationInfo()), |
| | | false); |
| | | |
| | | connections.put(new InternalClientConnection(new AuthenticationInfo()), false); |
| | | connections.put(InternalClientConnection.getRootConnection(), true); |
| | | |
| | | connections.put( |
| | | newConn("cn=Directory Manager,cn=Root DNs,cn=config", true), true); |
| | | connections.put( |
| | | newConn("cn=Unprivileged Root,cn=Root DNs,cn=config", true), false); |
| | | connections.put(newConn("cn=Directory Manager,cn=Root DNs,cn=config", true), true); |
| | | connections.put(newConn("cn=Unprivileged Root,cn=Root DNs,cn=config", true), false); |
| | | connections.put(newConn("cn=Proxy Root,cn=Root DNs,cn=config", true), true); |
| | | connections.put(newConn("cn=Unprivileged User,o=test", false), false); |
| | | connections.put(newConn("cn=Privileged User,o=test", false), true); |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0); |
| | | assertEquals(runSearchWithSystemErr(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(args, false, null, null) == 0); |
| | | assertNotEquals(runSearch(args), 0); |
| | | } |
| | | |
| | | |
| | |
| | | "(objectClass=*)" |
| | | }; |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(searchArgs, false, null, null) == 0); |
| | | assertNotEquals(runSearch(searchArgs), 0); |
| | | |
| | | |
| | | // Disable the PROXIED_AUTH privilege and verify that the operation now |
| | |
| | | TestCaseUtils.dsconfig( |
| | | "set-global-configuration-prop", |
| | | "--add", "disabled-privilege:proxied-auth"); |
| | | assertEquals(LDAPSearch.mainSearch(searchArgs, false, null, null), 0); |
| | | assertEquals(runSearch(searchArgs), 0); |
| | | |
| | | |
| | | // Re-enable the PROXIED_AUTH privilege and verify that the operation |
| | |
| | | "set-global-configuration-prop", |
| | | "--remove", "disabled-privilege:proxied-auth"); |
| | | |
| | | assertFalse(LDAPSearch.mainSearch(searchArgs, false, null, null) == 0); |
| | | assertNotEquals(runSearch(searchArgs), 0); |
| | | } |
| | | |
| | | private int runSearch(String[] args) |
| | | { |
| | | return LDAPSearch.mainSearch(args, false, null, null); |
| | | } |
| | | |
| | | private int runSearchWithSystemErr(String[] args) |
| | | { |
| | | return LDAPSearch.mainSearch(args, false, null, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Tests the ability to update the set of privileges for a user on the fly |
| | |
| | | package org.opends.server.types; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | public void testNullDN() throws Exception { |
| | | DN nullDN = DN.rootDN(); |
| | | |
| | | assertTrue(nullDN.size() == 0); |
| | | assertEquals(nullDN.size(), 0); |
| | | assertEquals(nullDN.toString(), ""); |
| | | } |
| | | |
| | |
| | | DN dn2 = DN.valueOf(second); |
| | | |
| | | if (result == 0) { |
| | | assertTrue(dn1.equals(dn2), "DN equality for <" + first |
| | | + "> and <" + second + ">"); |
| | | assertEquals (dn1, dn2, "DN equality for <" + first + "> and <" + second + ">"); |
| | | } else { |
| | | assertFalse(dn1.equals(dn2), "DN equality for <" + first |
| | | + "> and <" + second + ">"); |
| | | assertNotEquals(dn1, dn2, "DN equality for <" + first + "> and <" + second + ">"); |
| | | } |
| | | } |
| | | |
| | |
| | | public void testEqualsNonDN() throws Exception { |
| | | DN dn = DN.valueOf("dc=example,dc=com"); |
| | | |
| | | assertFalse(dn.equals("not a DN")); |
| | | assertNotEquals(dn, "not a DN"); |
| | | } |
| | | |
| | | |
| | |
| | | int h2 = dn2.hashCode(); |
| | | |
| | | if (result == 0) { |
| | | if (h1 != h2) { |
| | | Assert.fail("Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } |
| | | assertEquals(h1, h2, |
| | | "Hash codes for <" + first + "> and <" + second + "> should be the same."); |
| | | } else { |
| | | if (h1 == h2) { |
| | | Assert.fail("Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } |
| | | assertNotEquals(h1, h2, |
| | | "Hash codes for <" + first + "> and <" + second + "> should be the same."); |
| | | } |
| | | } |
| | | |
| | |
| | | ObjectClass parent2, |
| | | ObjectClassType type, |
| | | boolean isValid) throws Exception { |
| | | ObjectClassBuilder builder = new ObjectClassBuilder("testType", |
| | | "1.2.3"); |
| | | ObjectClassBuilder builder = new ObjectClassBuilder("testType", "1.2.3"); |
| | | builder.setObjectClassType(type); |
| | | Set<ObjectClass> superiors = new LinkedHashSet<ObjectClass>(); |
| | | superiors.add(parent1); |
| | | superiors.add(parent2); |
| | | builder.setSuperior(superiors); |
| | | ObjectClass child = builder.getInstance(); |
| | | Assert.assertTrue(child.getSuperiorClasses().size()==2); |
| | | Assert.assertEquals(child.getSuperiorClasses().size(), 2); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | RDN rdn1 = new RDN(AT_DC, AV_DC_ORG); |
| | | RDN rdn2 = rdn1.duplicate(); |
| | | |
| | | assertFalse(rdn1 == rdn2); |
| | | assertNotSame(rdn1, rdn2); |
| | | assertEquals(rdn1, rdn2); |
| | | } |
| | | |
| | |
| | | RDN rdn1 = new RDN(types, names, values); |
| | | RDN rdn2 = rdn1.duplicate(); |
| | | |
| | | assertFalse(rdn1 == rdn2); |
| | | assertNotSame(rdn1, rdn2); |
| | | assertEquals(rdn1, rdn2); |
| | | } |
| | | |
| | |
| | | RDN rdn2 = RDN.decode(second); |
| | | |
| | | if (result == 0) { |
| | | assertTrue(rdn1.equals(rdn2), "RDN equality for <" + first |
| | | + "> and <" + second + ">"); |
| | | assertEquals(rdn1, rdn2, |
| | | "RDN equality for <" + first + "> and <" + second + ">"); |
| | | } else { |
| | | assertFalse(rdn1.equals(rdn2), "RDN equality for <" + first |
| | | + "> and <" + second + ">"); |
| | | assertNotEquals(rdn1, rdn2, |
| | | "RDN equality for <" + first + "> and <" + second + ">"); |
| | | } |
| | | } |
| | | |
| | |
| | | int h2 = rdn2.hashCode(); |
| | | |
| | | if (result == 0) { |
| | | if (h1 != h2) { |
| | | fail("Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } |
| | | assertEquals(h1, h2, "Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } else { |
| | | if (h1 == h2) { |
| | | fail("Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } |
| | | assertNotEquals(h1, h2, "Hash codes for <" + first + "> and <" + second |
| | | + "> should be the same."); |
| | | } |
| | | } |
| | | |
| | |
| | | rc = 1; |
| | | } |
| | | |
| | | assertEquals(rc, result, "Comparison for <" + first + "> and <" |
| | | + second + ">."); |
| | | assertEquals(rc, result, "Comparison for <" + first + "> and <" + second + ">."); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the equals method with a null argument. |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testEqualityNull() { |
| | | RDN rdn = new RDN(AT_DC, AV_DC_ORG); |
| | | |
| | | assertFalse(rdn.equals(null)); |
| | | assertNotEquals(rdn, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the equals method with a non-RDN argument. |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test |
| | | public void testEqualityNonRDN() { |
| | | RDN rdn = new RDN(AT_DC, AV_DC_ORG); |
| | | |
| | | assertFalse(rdn.equals("this isn't an RDN")); |
| | | assertNotEquals(rdn, "this isn't an RDN"); |
| | | } |
| | | } |
| | | |