unit tests: removed some additional suppressions (compared to forgerock-build-tools equivalent file)
| | |
| | | Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | information: "Portions Copyrighted [year] [name of copyright owner]". |
| | | |
| | | Copyright 2012-2015 ForgeRock AS. All rights reserved. |
| | | Copyright 2012-2016 ForgeRock AS. All rights reserved. |
| | | --> |
| | | <!DOCTYPE suppressions PUBLIC |
| | | "-//Puppy Crawl//DTD Suppressions 1.1//EN" |
| | |
| | | Once additional suppressions added at the end of the file can be removed due to code |
| | | cleaning, then this file may be deleted and replaced by equivalent in |
| | | forgerock-build-tools. |
| | | |
| | | --> |
| | | |
| | | <!-- check-src-default.xml --> |
| | |
| | | <suppress checks="TodoComment" files="/src/test/java" /> |
| | | |
| | | <!-- Additional suppressions (compared to forgerock-build-tools equivalent file) --> |
| | | <suppress checks="LineLength" files="/src/test/java" /> |
| | | <suppress checks="RegexpSingleline" files="/src/test/java" /> |
| | | <suppress checks="FileTabCharacter" files="/src/test/java" /> |
| | | <suppress checks="LineLength" files="/src/test/java" /> |
| | | <suppress checks="RedundantImport" files="/src/test/java" /> |
| | | <suppress checks="UnusedImports" files="/src/test/java" /> |
| | | <suppress checks="EmptyStatement" files="/src/test/java" /> |
| | | <suppress checks="EqualsHashCode" files="/src/test/java" /> |
| | | |
| | | </suppressions> |
| | |
| | | Modification mod = new Modification(ModificationType.ADD, attribute); |
| | | |
| | | org.opends.server.types.Modification srvModification = toModification(mod); |
| | | Attribute attr = srvModification.getAttribute(); |
| | | assertThat(srvModification.getModificationType()).isEqualTo(ModificationType.ADD); |
| | | assertThat(srvModification.getAttribute().getAttributeDescription().getAttributeType().getNameOrOID()).isEqualTo("test"); |
| | | assertThat(srvModification.getAttribute().size()).isEqualTo(2); |
| | | assertThat(attr.getAttributeDescription().getAttributeType().getNameOrOID()).isEqualTo("test"); |
| | | assertThat(attr.size()).isEqualTo(2); |
| | | |
| | | mod = new Modification(ModificationType.INCREMENT, attribute); |
| | | srvModification = toModification(mod); |
| | |
| | | import java.net.ServerSocket; |
| | | import java.net.Socket; |
| | | import java.net.SocketAddress; |
| | | import java.net.SocketException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | * @return the bounded Server socket. |
| | | * |
| | | * @throws IOException in case of underlying exception. |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | private static ServerSocket bindPort(int port) |
| | | throws IOException |
| | |
| | | * @return the bounded Server socket. |
| | | * |
| | | * @throws IOException in case of underlying exception. |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | public static ServerSocket bindFreePort() throws IOException |
| | | { |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server; |
| | | |
| | |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.Comparator; |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.IdentityHashMap; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.testng.*; |
| | | import org.testng.IClass; |
| | | import org.testng.IReporter; |
| | | import org.testng.ISuite; |
| | | import org.testng.ITestContext; |
| | | import org.testng.ITestNGMethod; |
| | | import org.testng.ITestResult; |
| | | import org.testng.TestListenerAdapter; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.xml.XmlSuite; |
| | |
| | | } |
| | | |
| | | |
| | | private static final String DIVIDER_LINE = "-------------------------------------------------------------------------------" + EOL; |
| | | private static final String DIVIDER_LINE = |
| | | "-------------------------------------------------------------------------------" + EOL; |
| | | |
| | | @Override |
| | | public void onStart(ITestContext testContext) { |
| | |
| | | try { |
| | | reportStream = new PrintStream(new FileOutputStream(reportFile)); |
| | | } catch (FileNotFoundException e) { |
| | | originalSystemErr.println("Could not open " + reportFile + " for writing. Will write the unit test report to the console instead."); |
| | | originalSystemErr.println( |
| | | "Could not open " + reportFile + " for writing. Will write the unit test report to the console instead."); |
| | | e.printStackTrace(originalSystemErr); |
| | | reportStream = originalSystemErr; |
| | | } |
| | |
| | | |
| | | if (countTestsWithStatus(ITestResult.FAILURE) == 0 |
| | | && countTestsWithStatus(ITestResult.SKIP) != 0) { |
| | | originalSystemErr.println("There were no explicit test failures, but some tests were skipped (possibly due to errors in @Before* or @After* methods)."); |
| | | originalSystemErr.println("There were no explicit test failures," |
| | | + " but some tests were skipped (possibly due to errors in @Before* or @After* methods)."); |
| | | System.exit(-1); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | Class<?> classWithTestAnnotation = findClassWithTestAnnotation(testClass); |
| | | Class<?> annotatedClass = findClassWithTestAnnotation(testClass); |
| | | |
| | | if (classWithTestAnnotation == null) { |
| | | if (annotatedClass == null) { |
| | | String errorMessage = |
| | | "The test class " + testClass.getName() + " does not have a @Test annotation. " + |
| | | "All test classes must have a @Test annotation, and this annotation must have " + |
| | |
| | | throw new RuntimeException(errorMessage); |
| | | } |
| | | |
| | | Test testAnnotation = classWithTestAnnotation.getAnnotation(Test.class); |
| | | Test testAnnotation = annotatedClass.getAnnotation(Test.class); |
| | | if (!testAnnotation.sequential()) { |
| | | // Give an error message that is as specific as possible. |
| | | boolean isTestClass = annotatedClass.equals(testClass); |
| | | String errorMessage = |
| | | "The @Test annotation for class " + testClass.getName() + |
| | | (classWithTestAnnotation.equals(testClass) ? " " : (", which is declared by class " + classWithTestAnnotation.getName() + ", ")) + |
| | | (isTestClass ? " " : (", which is declared by class " + annotatedClass.getName() + ", ")) + |
| | | "must include sequential=true to ensure that tests for a single class are run together."; |
| | | TestCaseUtils.originalSystemErr.println("\n\nERROR: " + errorMessage + "\n\n"); |
| | | throw new RuntimeException(errorMessage); |
| | |
| | | |
| | | |
| | | if (doProgressTime) { |
| | | originalSystemErr.println(" Test duration status: {Total min:sec. Since last status sec.}"); |
| | | originalSystemErr.println( |
| | | " Test duration status: {Total min:sec. Since last status sec.}"); |
| | | } |
| | | |
| | | if (doProgressTestCount) { |
| | | originalSystemErr.println(" Test count status: {# test classes # test methods # test method invocations # test failures}."); |
| | | originalSystemErr.println( |
| | | " Test count status: {# test classes # test methods # test method invocations # test failures}."); |
| | | } |
| | | |
| | | if (doProgressMemory) { |
| | | originalSystemErr.println(" Memory usage status: {MB in use +/-change since last status}"); |
| | | originalSystemErr.println( |
| | | " Memory usage status: {MB in use +/-change since last status}"); |
| | | } |
| | | |
| | | if (doProgressMemoryGcs) { |
| | | originalSystemErr.println(" GCs during status: {GCs done to settle used memory time to do it}"); |
| | | originalSystemErr.println( |
| | | " GCs during status: {GCs done to settle used memory time to do it}"); |
| | | } |
| | | |
| | | if (doProgressThreadCount) { |
| | | originalSystemErr.println(" Thread count status: {#td number of active threads}"); |
| | | originalSystemErr.println( |
| | | " Thread count status: {#td number of active threads}"); |
| | | } |
| | | |
| | | if (doProgressRestarts) { |
| | | originalSystemErr.println(" In core restart status: {#rs number of in-core restarts}"); |
| | | originalSystemErr.println( |
| | | " In core restart status: {#rs number of in-core restarts}"); |
| | | } |
| | | |
| | | if (doProgressThreadChange) { |
| | | originalSystemErr.println(" Thread change status: +/- thread name for new or finished threads since last status"); |
| | | originalSystemErr.println( |
| | | " Thread change status: +/- thread name for new or finished threads since last status"); |
| | | } |
| | | |
| | | originalSystemErr.println(" TestClass (the class that just completed)"); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS. |
| | | * Portions Copyright 2011-2016 ForgeRock AS. |
| | | * Portions Copyright 2013 Manuel Gaupp |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.*; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.StringReader; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.GregorianCalendar; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.*; |
| | | import org.opends.server.tools.LDAPCompare; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.tools.LDIFDiff; |
| | | import org.opends.server.tools.LDIFModify; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | private static final String BIND_RULE_USERDN_PARENT = "userdn=\"ldap:///parent\""; |
| | | private static final String BIND_RULE_USERDN_CN_RDN = "userdn=\"ldap:///CN=*,dc=example,dc=com\""; |
| | | private static final String BIND_RULE_USERDN_NOT_UID_RDN = "userdn!=\"ldap:///uid=*,dc=example,dc=com\""; |
| | | // @Checkstyle:off |
| | | private static final String BIND_RULE_USERDN_UID_OR_CN_RDN = "userdn=\"ldap:///uid=*,dc=example,dc=com || ldap:///cn=*,dc=example,dc=com\""; |
| | | private static final String BIND_RULE_USERDN_ALL_CN_ADMINS = "userdn=\"ldap:///dc=example,dc=com??sub?(cn=*admin*)\""; |
| | | /** TODO: this might be invalid? */ |
| | | private static final String BIND_RULE_USERDN_TOP_LEVEL_CN_ADMINS = "userdn=\"ldap:///dc=example,dc=com??one?(cn=*admin*)\""; |
| | | // @Checkstyle:on |
| | | private static final String BIND_RULE_GROUPDN_GROUP_1 = |
| | | "groupdn=\"ldap:///" + OU_GROUP_1_DN + "\""; |
| | | private static final String BIND_RULE_IP_LOCALHOST = "ip=\"127.0.0.1\""; |
| | |
| | | private static final String BIND_RULE_AUTHMETHOD_SSL = "authmethod=\"ssl\""; |
| | | private static final String BIND_RULE_AUTHMETHOD_SASL_DIGEST_MD5 = "authmethod=\"sasl DIGEST-MD5\""; |
| | | |
| | | // @Checkstyle:off |
| | | /** Admin, but not anonymous. */ |
| | | private static final String BIND_RULE_USERDN_NOT_ADMIN = and(not(BIND_RULE_USERDN_ADMIN), BIND_RULE_AUTHMETHOD_SIMPLE); |
| | | |
| | |
| | | private static final String BIND_RULE_IP_NOT_LOCALHOST_OR_USERDN_ADMIN = or(BIND_RULE_IP_NOT_LOCALHOST, BIND_RULE_USERDN_ADMIN); |
| | | |
| | | private static final String BIND_RULE_ADMIN_AND_LOCALHOST_OR_SSL = and(BIND_RULE_USERDN_ADMIN, or(BIND_RULE_AUTHMETHOD_SSL, BIND_RULE_DNS_LOCALHOST)); |
| | | // @Checkstyle:on |
| | | |
| | | |
| | | // These are made up |
| | | // @Checkstyle:off |
| | | private static final String BIND_RULE_GROUPDN_1 = "groupdn=\"ldap:///cn=SomeGroup,dc=example,dc=com\""; |
| | | private static final String BIND_RULE_GROUPDN_2 = "groupdn=\"ldap:///cn=SomeGroup,dc=example,dc=com || ldap:///cn=SomeOtherGroup,dc=example,dc=com\""; |
| | | private static final String BIND_RULE_GROUPDN_3 = "groupdn=\"ldap:///cn=SomeGroup,dc=example,dc=com || ldap:///cn=SomeOtherGroup,dc=example,dc=com || ldap:///cn=SomeThirdGroup,dc=example,dc=com\""; |
| | | private static final String BIND_RULE_USERDN_FILTER = "userdn=\"ldap:///dc=example,dc=com??one?(|(ou=eng)(ou=acct))\""; |
| | | // @Checkstyle:on |
| | | |
| | | //bind rule user attr ACIs |
| | | private static final String BIND_RULE_USERATTR_USERDN = "userattr=\"manager#USERDN\""; |
| | |
| | | private static final String BIND_RULE_NOON_AND_AFTER = "timeofday>=\"1200\""; |
| | | private static final String BIND_RULE_BEFORE_NOON = "timeofday<\"1200\""; |
| | | private static final String BIND_RULE_NOON_AND_BEFORE = "timeofday<=\"1200\""; |
| | | // @Checkstyle:off |
| | | //targattrfilters |
| | | private static final String TARG_ATTR_FILTERS = "add=cn:(!(cn=superAdmin))"; |
| | | private static final String TARG_ATTR_FILTERS_1 = "add=cn:(!(cn=superAdmin)) && telephoneNumber:(telephoneNumber=123*)"; |
| | |
| | | private static final String TARG_ATTR_FILTERS_ATTR_TYPE_NAME = "del=cn:(&(cn=foo)(cn=f*)) && 1sn_:(1sn_=joe*)"; |
| | | |
| | | private static final String SELF_MODIFY_ACI = "aci: (targetattr=\"*\")(version 3.0; acl \"self modify\";allow(all) userdn=\"userdn=\"ldap:///self\";)"; |
| | | // @Checkstyle:on |
| | | |
| | | private static final String ALLOW_ALL_TO_ALL = |
| | | buildAciValue("name", "allow all", "targetattr", "*", "allow(all)", BIND_RULE_USERDN_ALL); |
| | | |
| | | // @Checkstyle:off |
| | | private static final String ALLOW_ALL_TO_COMPARE = |
| | | buildAciValue("name", "allow compare", "targetattr", "*", "target", "ldap:///cn=*," + OU_LEAF_DN, "allow(compare)", BIND_RULE_USERDN_ALL); |
| | | // @Checkstyle:on |
| | | |
| | | private static final String DENY_READ_CN_SN_IF_PERSON = buildAciValue("name", |
| | | "deny read cn sn if person", "targetfilter", "objectClass=person", |
| | |
| | | buildAciValue("name", "allow proxy to userdn level1", "targetattr", "*", |
| | | "allow(proxy)", BIND_RULE_USERDN_LEVEL_1); |
| | | |
| | | // @Checkstyle:off |
| | | private static final String ALLOW_ALL_TO_IMPORT_MGR_NEW = |
| | | buildAciValue("name", "allow import mgr new tree", "target", MGR_NEW_DN_URL, "allow(import)", BIND_RULE_USERDN_ALL); |
| | | |
| | |
| | | |
| | | private static final String ALLOW_SEARCH_OU_AND_PERSON_TO_SIMPLE = |
| | | buildAciValue("name", "allow search ou and person to localhost", "targetattr", "*", "targetfilter", "(|(objectclass=organizationalunit)(objectclass=person))", "allow(search, read)", BIND_RULE_AUTHMETHOD_SIMPLE); |
| | | |
| | | // @Checkstyle:on |
| | | |
| | | // ----------------------------------------------------------------------------- |
| | | // ----------------------------------------------------------------------------- |
| | |
| | | // Test each feature in isolation. |
| | | // <PASSES> |
| | | // // TARGETS |
| | | // @Checkstyle:off |
| | | buildAciValue("name", "self mod", "allow (write)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "parenthesis (dummy) and ( ) and () test", "allow (read)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "w/ target", "target", LDAP_URL_OU_INNER, "allow (write)", BIND_RULE_USERDN_SELF), |
| | |
| | | buildAciValue("name", "userattr", "targetattr", "*", "allow (read)", BIND_RULE_USERATTR_USERDN_INHERITANCE), |
| | | buildAciValue("name", "userattr", "targetattr", "*", "allow (read)", BIND_RULE_USERATTR_GROUPDN_INHERITANCE), |
| | | buildAciValue("name", "userattr", "targetattr", "*", "allow (read)", BIND_RULE_USERATTR_VALUE), |
| | | // @Checkstyle:on |
| | | // BUG! These work with DS 5.2p4, but not with OpenDS. |
| | | // <FAIL> |
| | | // DENY_ALL_TO_LOCALHOST_SUBNET, |
| | |
| | | buildAciValue("name", "invalid", "targetattr", "cn ||", "allow (write)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "invalid", "targetattr", "not/an/attr", "allow (write)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "invalid", "targetattr", "cn", "allow (write)", BIND_RULE_INVALID_DAY), |
| | | // @Checkstyle:off |
| | | /* Test cases for OPENDJ-433 */ |
| | | buildAciValue("name", "invalid", "targetattr", "cn", "garbage allow (read)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "invalid", "targetattr", "cn", "allow (read)", BIND_RULE_USERDN_SELF, "garbage allow (search)", BIND_RULE_USERDN_SELF), |
| | |
| | | // OpenDJ 2.5 doesn't support acis with options |
| | | buildAciValue("name", "unsupported option in targetattr", "targetattr", "locality;lang-fr-ca", "allow (write)", BIND_RULE_USERDN_SELF), |
| | | buildAciValue("name", "complicated unsupported option in targetattr", "targetattr", "1ocal_ity;lang-fr-ca", "allow (write)", BIND_RULE_USERDN_SELF), |
| | | |
| | | // @Checkstyle:on |
| | | // </PASSES> |
| | | }; |
| | | |
| | |
| | | |
| | | @DataProvider |
| | | public Object[][] validBasisOfValidityTests() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | TestCaseUtils.startServer(); // Apparently necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> acis = new ArrayList<>(); |
| | | for (String[] aciAndMask: INVALID_ACIS_IF_ANY_CHAR_REMOVED) { |
| | |
| | | * tests are valid acis. |
| | | */ |
| | | @Test(dataProvider = "validBasisOfValidityTests") |
| | | public void testBasisOfInvalidityTestsAreValid(String modifierDn, String modifierPw, String aciModLdif) throws Throwable { |
| | | public void testBasisOfInvalidityTestsAreValid(String modifierDn, String modifierPw, String aciModLdif) |
| | | throws Throwable { |
| | | if (TESTS_ARE_DISABLED) { // This is a hack to make sure we can disable the tests. |
| | | return; |
| | | } |
| | |
| | | |
| | | @DataProvider |
| | | public Object[][] validAcis() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | TestCaseUtils.startServer(); // Apparently necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | return buildAciValidationParams(Arrays.asList(VALID_ACIS), false /*test once per aci*/); |
| | | } |
| | | |
| | | @DataProvider |
| | | public Object[][] invalidAcis() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | TestCaseUtils.startServer(); // Apparently necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> invalid = newArrayList(INVALID_ACIS); |
| | | for (String[] aciAndMask: INVALID_ACIS_IF_ANY_CHAR_REMOVED) { |
| | |
| | | // Test that we can add entries with valid ACIs as well as set valid ACIs on a an entry |
| | | modEntries(aciModLdif, modifierDn, modifierPw); |
| | | } catch (Throwable e) { |
| | | System.err.println("Started with dit:\nldapmodify -a -D \"cn=Directory Manager\" -w etegrity -p 13324\n" + VALIDITY_TESTS_DIT + |
| | | "and as '" + modifierDn + "' failed to perform these modifications:\n" + |
| | | "ldapmodify -D \"" + modifierDn + "\" -w " + modifierPw + " -p 13324\n" + |
| | | aciModLdif); |
| | | System.err.println("Started with dit:\nldapmodify -a -D \"cn=Directory Manager\" -w etegrity -p 13324\n" |
| | | + VALIDITY_TESTS_DIT + "and as '" + modifierDn + "' failed to perform these modifications:\n" |
| | | + "ldapmodify -D \"" + modifierDn + "\" -w " + modifierPw + " -p 13324\n" |
| | | + aciModLdif); |
| | | throw e; |
| | | } |
| | | } |
| | |
| | | // Test that we can add entries with valid ACIs as well as set valid ACIs on a an entry |
| | | modEntriesExpectFailure(aciModLdif, modifierDn, modifierPw); |
| | | } catch (Throwable e) { |
| | | System.err.println("Started with dit:\nldapmodify -a -D \"cn=Directory Manager\" -w etegrity -p 13324\n" + VALIDITY_TESTS_DIT + |
| | | "and as '" + modifierDn + "' successfully added an invalid aci:\n" + |
| | | "ldapmodify -D \"" + modifierDn + "\" -w " + modifierPw + " -p 13324\n" + |
| | | aciModLdif); |
| | | System.err.println("Started with dit:\nldapmodify -a -D \"cn=Directory Manager\" -w etegrity -p 13324\n" |
| | | + VALIDITY_TESTS_DIT + "and as '" + modifierDn + "' successfully added an invalid aci:\n" |
| | | + "ldapmodify -D \"" + modifierDn + "\" -w " + modifierPw + " -p 13324\n" |
| | | + aciModLdif); |
| | | throw e; |
| | | } |
| | | } |
| | | |
| | | @DataProvider |
| | | public Object[][] invalidAcisMultiCombos() throws Exception { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | TestCaseUtils.startServer(); // Apparently necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | List<String> invalid = new ArrayList<>(); |
| | | invalid.add(INVALID_ACIS[0]); |
| | |
| | | |
| | | private static final String ADMIN_LDIF__SEARCH_TESTS = makeUserLdif(ADMIN_DN, "aci", "admin", ADMIN_PW); |
| | | private static final String USER_LDIF__SEARCH_TESTS = makeUserLdif(USER_DN, "some", "user", USER_PW); |
| | | // @Checkstyle:off |
| | | private static final String LEVEL_1_USER_LDIF__SEARCH_TESTS = makeUserLdif(LEVEL_1_USER_DN, "level1", "user", "pa$$word"); |
| | | private static final String LEVEL_2_USER_LDIF__SEARCH_TESTS = makeUserLdif(LEVEL_2_USER_DN, "level2", "user", "pa$$word"); |
| | | private static final String LEVEL_3_USER_LDIF__SEARCH_TESTS = makeUserLdif(LEVEL_3_USER_DN, "level3", "user", "pa$$word"); |
| | | private static final String PROXY_USER_LDIF__SEARCH_TESTS = |
| | | makeUserLdif(PROXY_USER_DN, "proxy", "user", "pa$$word"); |
| | | private static final String PROXY_USER_LDIF__SEARCH_TESTS = makeUserLdif(PROXY_USER_DN, "proxy", "user", "pa$$word"); |
| | | // @Checkstyle:on |
| | | |
| | | |
| | | private static final String SALES_USER_1__SEARCH_TESTS = |
| | |
| | | _equivalentAciLdifs = Arrays.asList(equivalentAciLdifs); |
| | | } |
| | | |
| | | private void addSingleSearch(String bindDn, String searchBaseDn, String searchFilter, String searchScope, String expectedResultsLdif) { |
| | | private void addSingleSearch( |
| | | String bindDn, String searchBaseDn, String searchFilter, String searchScope, String expectedResultsLdif) { |
| | | for (String equivalentAci: _equivalentAciLdifs) { |
| | | _searchTests.add(SingleSearchParams.nonProxiedSearch(bindDn, DN_TO_PW.get(bindDn), searchBaseDn, searchFilter, searchScope, expectedResultsLdif, _initialDitLdif, equivalentAci)); |
| | | _searchTests.add(SingleSearchParams.nonProxiedSearch(bindDn, DN_TO_PW.get(bindDn), searchBaseDn, |
| | | searchFilter, searchScope, expectedResultsLdif, _initialDitLdif, equivalentAci)); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | @DataProvider |
| | | private Object[][] searchTestParams() throws Throwable { |
| | | TestCaseUtils.startServer(); // This appears to be necessary since the DataProviders can be called before @BeforeClass. |
| | | TestCaseUtils.startServer(); // Apparently necessary since the DataProviders can be called before @BeforeClass. |
| | | |
| | | try { |
| | | List<Object[]> allTestParams = new ArrayList<>(); |
| | |
| | | } |
| | | anyAttr += ")"; |
| | | |
| | | Pattern pattern = Pattern.compile("^" + anyAttr + "\\:(.*?)^", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.DOTALL); |
| | | Pattern pattern = Pattern.compile("^" + anyAttr + "\\:(.*?)^", |
| | | Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.DOTALL); |
| | | return pattern.matcher(ldif).replaceAll(""); |
| | | } |
| | | |
| | |
| | | import org.assertj.core.api.SoftAssertions; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.server.config.server.ExternalChangelogDomainCfg; |
| | |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.AuthenticationInfo; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.LDIFWriter; |
| | |
| | | { |
| | | final ReplicationDomainDB domainDB = replicationServer.getChangelogDB().getReplicationDomainDB(); |
| | | CursorOptions options = new CursorOptions(GREATER_THAN_OR_EQUAL_TO_KEY, ON_MATCHING_KEY); |
| | | try (DBCursor<UpdateMsg> cursor = domainDB.getCursorFrom(replicaId.getBaseDN(), csn.getServerId(), csn, options)) |
| | | try (DBCursor<UpdateMsg> cursor = |
| | | domainDB.getCursorFrom(replicaId.getBaseDN(), csn.getServerId(), csn, options)) |
| | | { |
| | | assertTrue(cursor.next(), "Expected to find at least one change in replicaDB for " + replicaId); |
| | | assertEquals(cursor.getRecord().getCSN(), csn); |
| | |
| | | return new DeleteMsg(DN.valueOf(dn), csn, testName + "uuid" + testIndex); |
| | | } |
| | | |
| | | private UpdateMsg generateAddMsg(ReplicaId replicaId, CSN csn, String user1entryUUID, String testName) throws Exception |
| | | private UpdateMsg generateAddMsg(ReplicaId replicaId, CSN csn, String user1entryUUID, String testName) |
| | | throws Exception |
| | | { |
| | | assertSameServerId(replicaId, csn); |
| | | String baseUUID = "22222222-2222-2222-2222-222222222222"; |
| | |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRuleUse; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.util.Utils; |
| | |
| | | import org.opends.server.types.LDIFExportConfig; |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.LDIFImportResult; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRuleUse; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.util.CollectionUtils; |
| | |
| | | { |
| | | DN schemaDN = DN.valueOf("cn=schema"); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | DeleteOperationBasis deleteOperation = |
| | | new DeleteOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new DeleteOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | null, schemaDN); |
| | | |
| | | schemaBackend.deleteEntry(schemaDN, deleteOperation); |
| | |
| | | for (Pair<Long, Integer> region : regions) |
| | | { |
| | | buffer.position(region.getFirst().intValue()).limit(buffer.position() + region.getSecond()); |
| | | assertThat(toPairs(new FileRegion.Cursor("test", buffer.slice()))).containsExactlyElementsOf(content(contents[regionNumber])); |
| | | assertThat(toPairs(new FileRegion.Cursor("test", buffer.slice()))) |
| | | .containsExactlyElementsOf(content(contents[regionNumber])); |
| | | regionNumber++; |
| | | } |
| | | } |
| | |
| | | searchOperation = new InternalSearchOperation(connection, 1, 1, request, null); |
| | | searchOperation.run(); |
| | | assertThat(searchOperation.getResultCode()).isEqualTo(ResultCode.INSUFFICIENT_ACCESS_RIGHTS); |
| | | assertThat(searchOperation.getErrorMessage().toString()).contains("not have sufficient privileges", "unindexed search"); |
| | | assertThat(searchOperation.getErrorMessage().toString()) |
| | | .contains("not have sufficient privileges", "unindexed search"); |
| | | assertThat(searchOperation.getEntriesSent()).isEqualTo(0); |
| | | } |
| | | |
| | |
| | | assertEquals(backend.getNumberOfChildren(testBaseDN), 1, |
| | | "Not enough entries in DIT."); |
| | | /** -2 for baseDn and People entry */ |
| | | assertEquals(backend.getNumberOfChildren(testBaseDN.child(DN.valueOf("ou=People"))), getTotalNumberOfLDIFEntries() - 2, |
| | | assertEquals(backend.getNumberOfChildren(testBaseDN.child(DN.valueOf("ou=People"))), |
| | | getTotalNumberOfLDIFEntries() - 2, |
| | | "Not enough entries in DIT."); |
| | | |
| | | VerifyConfig config = new VerifyConfig(); |
| | |
| | | { |
| | | final EntryContainer entryContainer = backend.getRootContainer().getEntryContainers().iterator().next(); |
| | | |
| | | final Set<String> dirtyIndexes = new HashSet<>(Arrays.asList(new String[] { "sn", "uid", "telephoneNumber" })); |
| | | final Set<String> dirtyIndexes = new HashSet<>(Arrays.asList("sn", "uid", "telephoneNumber")); |
| | | assertThat(backendIndexes.keySet()).containsAll(dirtyIndexes); |
| | | |
| | | // Delete all the indexes |
| | |
| | | { |
| | | final Storage storage = backend.getRootContainer().getStorage(); |
| | | final DN2ID dn2ID = backend.getRootContainer().getEntryContainer(testBaseDN).getDN2ID(); |
| | | final ID2ChildrenCount id2ChildrenCount = backend.getRootContainer().getEntryContainer(testBaseDN).getID2ChildrenCount(); |
| | | final ID2ChildrenCount id2ChildrenCount = |
| | | backend.getRootContainer().getEntryContainer(testBaseDN).getID2ChildrenCount(); |
| | | |
| | | final VerifyConfig config = new VerifyConfig(); |
| | | config.setBaseDN(DN.valueOf("dc=test,dc=com")); |
| | |
| | | @Override |
| | | public void run(WriteableTransaction txn) throws Exception |
| | | { |
| | | txn.put(new TreeName("dc=test,dc=com", "id2entry"), ByteString.valueOfUtf8("key"), ByteString.valueOfUtf8("value")); |
| | | txn.put(new TreeName("dc=test,dc=com", "id2entry"), |
| | | ByteString.valueOfUtf8("key"), |
| | | ByteString.valueOfUtf8("value")); |
| | | } |
| | | }); |
| | | } |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | {false, "o=test:;" }, |
| | | {false, "o=test:000001210b6f21e904b100000002;" }, |
| | | {false, "o=test:000001210b6f21e904b100000001;o=test2:000001210b6f21e904b100000002;" }, |
| | | {false, "o=test:000001210b6f21e904b100000001 000001210b6f21e904b200000001;o=test2:000001210b6f21e904b100000002 000001210b6f21e904b200000002;" }, |
| | | {false, "o=test:000001210b6f21e904b100000001 000001210b6f21e904b200000001;" |
| | | + "o=test2:000001210b6f21e904b100000002 000001210b6f21e904b200000002;" }, |
| | | }; |
| | | } |
| | | |
| | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.controls.PasswordPolicyErrorType.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | SimpleBindRequest bindRequest = newSimpleBindRequest("uid=test.user,o=test", "password".toCharArray()) |
| | | .addControl(newPasswordPolicyControl()); |
| | | LDAPMessage bindMessage = conn.bind(bindRequest, false); |
| | | assertTrue(passwordPolicyControlExists(bindMessage.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(bindMessage.getControls(), CHANGE_AFTER_RESET)); |
| | | |
| | | AddRequest addRequest = newAddRequest("ou=People,o=test") |
| | | .addAttribute("objectClass", "organizationalUnit") |
| | |
| | | |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | LDAPMessage message = c.add(addRequest, false); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), INSUFFICIENT_PASSWORD_QUALITY)); |
| | | } |
| | | } |
| | | |
| | |
| | | LDAPMessage message = c.add(addRequest, false); |
| | | AddResponseProtocolOp addResponse = message.getAddResponseProtocolOp(); |
| | | assertNotEquals(addResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.INSUFFICIENT_PASSWORD_QUALITY)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), INSUFFICIENT_PASSWORD_QUALITY)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | |
| | | LDAPMessage message = c.bind(request, false); |
| | | assertNotEquals(message.getBindResponseProtocolOp().getResultCode(), LDAPResultCode.SUCCESS); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.ACCOUNT_LOCKED)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), ACCOUNT_LOCKED)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | CompareResponseProtocolOp compareResponse = message.getCompareResponseProtocolOp(); |
| | | assertNotEquals(compareResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | DeleteResponseProtocolOp deleteResponse = message.getDeleteResponseProtocolOp(); |
| | | assertNotEquals(deleteResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | pwpControl = (PasswordPolicyResponseControl)c; |
| | | } |
| | | if (changeAfterReset) { |
| | | assertEquals(pwpControl.getErrorType(), |
| | | PasswordPolicyErrorType.CHANGE_AFTER_RESET); |
| | | assertEquals(pwpControl.getErrorType(), CHANGE_AFTER_RESET); |
| | | } else { |
| | | assertNull(pwpControl.getErrorType()); |
| | | } |
| | |
| | | ModifyResponseProtocolOp modifyResponse = message.getModifyResponseProtocolOp(); |
| | | assertEquals(modifyResponse.getResultCode(), LDAPResultCode.CONSTRAINT_VIOLATION); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | ModifyResponseProtocolOp modifyResponse = message.getModifyResponseProtocolOp(); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.PASSWORD_MOD_NOT_ALLOWED)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PASSWORD_MOD_NOT_ALLOWED)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | ModifyResponseProtocolOp modifyResponse = message.getModifyResponseProtocolOp(); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.PASSWORD_IN_HISTORY)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PASSWORD_IN_HISTORY)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | ModifyResponseProtocolOp modifyResponse = message.getModifyResponseProtocolOp(); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.MUST_SUPPLY_OLD_PASSWORD)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), MUST_SUPPLY_OLD_PASSWORD)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | ModifyResponseProtocolOp modifyResponse = message.getModifyResponseProtocolOp(); |
| | | assertNotEquals(modifyResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.PASSWORD_TOO_YOUNG)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PASSWORD_TOO_YOUNG)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | ModifyDNResponseProtocolOp modifyDNResponse = message.getModifyDNResponseProtocolOp(); |
| | | assertNotEquals(modifyDNResponse.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | SearchResultDoneProtocolOp searchDone = message.getSearchResultDoneProtocolOp(); |
| | | assertNotEquals(searchDone.getResultCode(), LDAPResultCode.SUCCESS); |
| | | |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), PasswordPolicyErrorType.CHANGE_AFTER_RESET)); |
| | | assertTrue(passwordPolicyControlExists(message.getControls(), CHANGE_AFTER_RESET)); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (LDAPException expected) |
| | | { |
| | | assertEquals( |
| | | expected.getMessage(), |
| | | assertEquals(expected.getMessage(), |
| | | "The provided integer value indicated that there were no persistent search change types, which is not allowed"); |
| | | } |
| | | |
| | |
| | | { |
| | | // Send the abandon request to the server and wait a few seconds to ensure |
| | | // it has completed before closing the connection. |
| | | conn.writeMessage(new AbandonRequestProtocolOp(1), DisconnectClientPlugin.createDisconnectControlList("PreParse")); |
| | | conn.writeMessage(new AbandonRequestProtocolOp(1), |
| | | DisconnectClientPlugin.createDisconnectControlList("PreParse")); |
| | | |
| | | Thread.sleep(3000); |
| | | } |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for bind operations. |
| | | */ |
| | | /** A set of test cases for bind operations. */ |
| | | public class BindOperationTestCase |
| | | extends OperationTestCase |
| | | { |
| | |
| | | public Object[][] getSimpleBindOperations() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Control> noControls = new ArrayList<>(0); |
| | | ByteString nullOS = null; |
| | | DN nullDN = null; |
| | | |
| | | BindOperation[] simpleBinds = new BindOperation[] |
| | | { |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", ByteString.empty(), |
| | | ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", ByteString.empty(), |
| | | ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullOS, ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullOS, ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", ByteString.empty(), nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", ByteString.empty(), nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullOS, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullOS, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", |
| | | ByteString.valueOfUtf8("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.rootDN(), ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullDN, ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullDN, ByteString.empty()), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.rootDN(), nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullDN, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullDN, nullOS), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.valueOf("cn=Directory Manager"), |
| | | ByteString.valueOfUtf8("password")) |
| | | return new Object[][] { |
| | | // @formatter:off |
| | | { newBindOp(null, ByteString.empty(), ByteString.empty()) }, |
| | | { newBindOp(noControls, ByteString.empty(), ByteString.empty()) }, |
| | | { newBindOp(null, nullOS, ByteString.empty()) }, |
| | | { newBindOp(noControls, nullOS, ByteString.empty()) }, |
| | | { newBindOp(null, ByteString.empty(), nullOS) }, |
| | | { newBindOp(noControls, ByteString.empty(), nullOS) }, |
| | | { newBindOp(null, nullOS, nullOS) }, |
| | | { newBindOp(noControls, nullOS, nullOS) }, |
| | | { newBindOp(noControls, bs("cn=Directory Manager"), bs("password")) }, |
| | | { newBindOp(null, DN.rootDN(), ByteString.empty()) }, |
| | | { newBindOp(noControls, DN.rootDN(), ByteString.empty()) }, |
| | | { newBindOp(null, nullDN, ByteString.empty()) }, |
| | | { newBindOp(noControls, nullDN, ByteString.empty()) }, |
| | | { newBindOp(null, DN.rootDN(), nullOS) }, |
| | | { newBindOp(noControls, DN.rootDN(), nullOS) }, |
| | | { newBindOp(null, nullDN, nullOS) }, |
| | | { newBindOp(noControls, nullDN, nullOS) }, |
| | | { newBindOp(noControls, DN.valueOf("cn=Directory Manager"), bs("password")) }, |
| | | // @formatter:on |
| | | }; |
| | | |
| | | Object[][] array = new Object[simpleBinds.length][1]; |
| | | for (int i=0; i < simpleBinds.length; i++) |
| | | { |
| | | array[i][0] = simpleBinds[i]; |
| | | } |
| | | |
| | | return array; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of bind operation objects using SASL authentication. |
| | | * |
| | |
| | | public Object[][] getSASLBindOperations() |
| | | throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ArrayList<Control> noControls = new ArrayList<>(0); |
| | | ByteString nullOS = null; |
| | | DN nullDN = null; |
| | | |
| | | BindOperation[] saslBinds = new BindOperation[] |
| | | { |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", ByteString.empty(), "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", ByteString.empty(), "EXTERNAL", |
| | | null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullOS, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullOS, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", ByteString.empty(), "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", ByteString.empty(), "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullOS, "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullOS, "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.rootDN(), "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullDN, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullDN, "EXTERNAL", null), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", DN.rootDN(), "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", DN.rootDN(), "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | null, "3", nullDN, "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")), |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | noControls, "3", nullDN, "PLAIN", |
| | | ByteString.valueOfUtf8("\u0000u:test.user\u0000password")) |
| | | return new Object[][] { |
| | | // @formatter:off |
| | | { newBindOp(null, ByteString.empty(), "EXTERNAL", null) }, |
| | | { newBindOp(noControls, ByteString.empty(), "EXTERNAL", null) }, |
| | | { newBindOp(null, nullOS, "EXTERNAL", null) }, |
| | | { newBindOp(noControls, nullOS, "EXTERNAL", null) }, |
| | | { newBindOp(null, ByteString.empty(), "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(noControls, ByteString.empty(), "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(null, nullOS, "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(noControls, nullOS, "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(null, DN.rootDN(), "EXTERNAL", null) }, |
| | | { newBindOp(noControls, DN.rootDN(), "EXTERNAL", null) }, |
| | | { newBindOp(null, nullDN, "EXTERNAL", null) }, |
| | | { newBindOp(noControls, nullDN, "EXTERNAL", null) }, |
| | | { newBindOp(null, DN.rootDN(), "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(noControls, DN.rootDN(), "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(null, nullDN, "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | { newBindOp(noControls, nullDN, "PLAIN", bs("\u0000u:test.user\u0000password")) }, |
| | | // @formatter:on |
| | | }; |
| | | } |
| | | |
| | | Object[][] array = new Object[saslBinds.length][1]; |
| | | for (int i=0; i < saslBinds.length; i++) |
| | | private BindOperation newBindOp(List<Control> requestControls, ByteString rawBindDN, ByteString simplePassword) |
| | | { |
| | | array[i][0] = saslBinds[i]; |
| | | return new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, "3", rawBindDN, simplePassword); |
| | | } |
| | | |
| | | return array; |
| | | private BindOperation newBindOp(List<Control> requestControls, DN bindDN, ByteString simplePassword) |
| | | { |
| | | return new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, "3", bindDN, simplePassword); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | private BindOperation newBindOp(List<Control> requestControls, |
| | | ByteString rawBindDN, String saslMechanism, ByteString saslCredentials) |
| | | { |
| | | return new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, "3", rawBindDN, saslMechanism, saslCredentials); |
| | | } |
| | | |
| | | private BindOperation newBindOp(List<Control> requestControls, |
| | | DN bindDN, String saslMechanism, ByteString saslCredentials) |
| | | { |
| | | return new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | requestControls, "3", bindDN, saslMechanism, saslCredentials); |
| | | } |
| | | |
| | | private ByteString bs(String s) |
| | | { |
| | | return ByteString.valueOfUtf8(s); |
| | | } |
| | | |
| | | @Override |
| | | protected Operation[] createTestOperations() |
| | | throws Exception |
| | | protected Operation[] createTestOperations() throws Exception |
| | | { |
| | | Object[][] simpleBinds = getSimpleBindOperations(); |
| | | Object[][] saslBinds = getSASLBindOperations(); |
| | |
| | | return bindOps; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getAuthenticationType</CODE> method for simple bind |
| | | * operations. |
| | |
| | | assertEquals(o.getAuthenticationType(), AuthenticationType.SIMPLE); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getAuthenticationType</CODE> method for SASL bind |
| | | * operations. |
| | |
| | | assertEquals(o.getAuthenticationType(), AuthenticationType.SASL); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getGetProtocolVersion</CODE> method for simple bind |
| | | * operations. |
| | |
| | | assertTrue(o.getProtocolVersion().length() > 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getProtocolVersion</CODE> method for SASL bind operations. |
| | | * |
| | |
| | | assertTrue(o.getProtocolVersion().length() > 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getRawBindDN</CODE> method for simple bind operations. |
| | | * |
| | |
| | | assertNotNull(o.getRawBindDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getRawBindDN</CODE> method for SASL bind operations. |
| | | * |
| | |
| | | assertNotNull(o.getRawBindDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>setRawBindDN()</CODE> method for simple bind operations. |
| | | * |
| | |
| | | assertEquals(o.getRawBindDN(), originalRawBindDN); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>setRawBindDN()</CODE> method for SASL bind operations. |
| | | * |
| | |
| | | assertEquals(o.getRawBindDN(), originalRawBindDN); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getBindDN</CODE> method on bind operations using simple |
| | | * authentication. |
| | |
| | | o.getBindDN(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSimplePassword</CODE> method for bind operations using |
| | | * simple authentication. |
| | |
| | | assertNotNull(o.getSimplePassword()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSimplePassword</CODE> method for bind operations using |
| | | * SASL authentication. |
| | |
| | | assertNull(o.getSimplePassword()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLMechanism</CODE> method for bind operations using |
| | | * simple authentication. |
| | |
| | | assertNull(o.getSASLMechanism()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLMechanism</CODE> method for bind operations using |
| | | * SASL authentication. |
| | |
| | | assertNotNull(o.getSASLMechanism()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLCredentials</CODE> method for bind operations using |
| | | * simple authentication. |
| | |
| | | assertNull(o.getSASLCredentials()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLCredentials</CODE> method for bind operations using |
| | | * SASL authentication. |
| | |
| | | o.getSASLCredentials(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the ability to change a simple bind operation to a SASL bind |
| | | * operation and back again. |
| | |
| | | assertNull(o.getSASLCredentials()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the ability to change a SASL bind operation to a simple bind |
| | | * operation and back again. |
| | |
| | | assertNull(o.getSimplePassword()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getServerSASLCredentials</CODE> method for bind operations |
| | | * using simple authentication. |
| | |
| | | assertNull(o.getServerSASLCredentials()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getServerSASLCredentials</CODE> method for bind operations |
| | | * using SASL authentication. |
| | |
| | | assertNull(o.getServerSASLCredentials()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLAuthUserEntry</CODE> method for bind operations |
| | | * using simple authentication. |
| | |
| | | assertNull(o.getSASLAuthUserEntry()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLAuthUserEntry</CODE> method for bind operations |
| | | * using SASL authentication. |
| | |
| | | assertNull(o.getSASLAuthUserEntry()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getSASLAuthUserEntry</CODE> method for completed SASL bind |
| | | * operations in which this value will be set. |
| | |
| | | assertNotNull(bindOperation.getSASLAuthUserEntry()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getUserEntryDN</CODE> method for bind operations using |
| | | * simple authentication. |
| | |
| | | assertNull(o.getUserEntryDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getUserEntryDN</CODE> method for a completed bind operation |
| | | * using simple authentication in which this value will be set. |
| | |
| | | assertNotNull(bindOperation.getUserEntryDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getUserEntryDN</CODE> method for bind operations using SASL |
| | | * authentication. |
| | |
| | | assertNull(o.getUserEntryDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getUserEntryDN</CODE> method for a completed bind operation |
| | | * using SASL authentication in which this value will be set. |
| | |
| | | assertNotNull(bindOperation.getUserEntryDN()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getProcessingStartTime</CODE>, |
| | | * <CODE>getProcessingStopTime</CODE>, and <CODE>getProcessingTime()</CODE> |
| | |
| | | assertTrue(bindOperation.getProcessingTime() >= 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getProcessingStartTime</CODE>, |
| | | * <CODE>getProcessingStopTime</CODE>, and <CODE>getProcessingTime()</CODE> |
| | |
| | | assertTrue(bindOperation.getProcessingTime() >= 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getOperationType</CODE> method for bind operations using |
| | | * simple authentication. |
| | |
| | | assertEquals(o.getOperationType(), OperationType.BIND); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>getOperationType</CODE> method for bind operations using |
| | | * SASL authentication. |
| | |
| | | assertEquals(o.getOperationType(), OperationType.BIND); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a simple bind operation to ensure that all plugin types are invoked |
| | | * as expected. |
| | | */ |
| | | /** Tests a simple bind operation to ensure that all plugin types are invoked as expected. */ |
| | | @Test |
| | | public void testAllPluginsCalledSimple() |
| | | { |
| | |
| | | // assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that all plugin types are invoked |
| | | * as expected. |
| | | */ |
| | | /** Tests a SASL bind operation to ensure that all plugin types are invoked as expected. */ |
| | | @Test |
| | | public void testAllPluginsCalledSASL() |
| | | { |
| | |
| | | // assertTrue(InvocationCounterPlugin.getPostResponseCount() > 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an anonymous simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in pre-parse plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an anonymous simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in pre-operation plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an anonymous simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in post-operation plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an anonymous simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in post-response plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an authenticated simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in pre-parse plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an authenticated simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in post-operation plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an authenticated simple bind operation to ensure that it's treated |
| | | * properly if the client connection is lost in post-response plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that it's treated properly if the |
| | | * client connection is lost in pre-parse plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that it's treated properly if the |
| | | * client connection is lost in pre-operation plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that it's treated properly if the |
| | | * client connection is lost in post-operation plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an anonymous simple bind operation to ensure that it's treated |
| | | * properly if the operation gets short-circuited in pre-operation plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests an authenticated simple bind operation to ensure that it's treated |
| | | * properly if the operation gets short-circuited in pre-operation plugin |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that it's treated properly if the |
| | | * operation gets short-circuited in pre-parse plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests a SASL bind operation to ensure that it's treated properly if the |
| | | * operation gets short-circuited in pre-operation plugin processing. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with an invalid user DN. |
| | | */ |
| | | /** Tests performing a simple bind operation with an invalid user DN. */ |
| | | @Test |
| | | public void testSimpleBindInvalidDN() |
| | | { |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a SASL bind operation with an invalid user DN. |
| | | */ |
| | | /** Tests performing a SASL bind operation with an invalid user DN. */ |
| | | @Test |
| | | public void testSASLBindInvalidDN() |
| | | { |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with an unsupported control that |
| | | * is marked critical. |
| | |
| | | requestControls.add(new LDAPControl("1.2.3.4", true)); |
| | | |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | requestControls, "3", DN.rootDN(), |
| | | ByteString.empty()); |
| | | new BindOperationBasis(conn, nextOperationID(), nextMessageID(), |
| | | requestControls, "3", DN.rootDN(), ByteString.empty()); |
| | | bindOperation.run(); |
| | | assertEquals(bindOperation.getResultCode(), |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a SASL bind operation with an unsupported control that is |
| | | * marked critical. |
| | | */ |
| | | /** Tests performing a SASL bind operation with an unsupported control that is marked critical. */ |
| | | @Test |
| | | public void testSASLBindUnsupportedCriticalControl() |
| | | { |
| | |
| | | ResultCode.UNAVAILABLE_CRITICAL_EXTENSION); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with an unsupported control that |
| | | * is not marked critical. |
| | |
| | | requestControls.add(new LDAPControl("1.2.3.4", false)); |
| | | |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | requestControls, "3", DN.rootDN(), |
| | | ByteString.empty()); |
| | | new BindOperationBasis(conn, nextOperationID(), nextMessageID(), |
| | | requestControls, "3", DN.rootDN(), ByteString.empty()); |
| | | |
| | | bindOperation.run(); |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a SASL bind operation with an unsupported control that is |
| | | * is not marked critical. |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with the DN of a user that doesn't |
| | | * exist. |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with the DN of a valid user but |
| | | * without including a password in the request, with the server configured to |
| | |
| | | ResultCode.UNWILLING_TO_PERFORM); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with the DN of a valid user but |
| | | * without including a password in the request, with the server configured to |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation as a user who exists on |
| | | * another server for which a named subordinate reference exists. |
| | |
| | | assertEquals(referralURLs.get(0), "ldap://example.com:1389/uid=test,ou=people,o=test"); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests performing a simple bind operation with a valid DN but incorrect |
| | | * password. |
| | | */ |
| | | /** Tests performing a simple bind operation with a valid DN but incorrect password. */ |
| | | @Test |
| | | public void testSimpleBindWrongPassword() |
| | | { |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the returnBindErrorMessage configuration option. |
| | | */ |
| | | /** Tests the behavior of the returnBindErrorMessage configuration option. */ |
| | | @Test |
| | | public void testReturnBindErrorMessage() |
| | | { |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | assertThat(bindOperation.getErrorMessage()).isEmpty(); |
| | | |
| | | |
| | | // Change the server configuration so that error messages should be |
| | | // returned. |
| | | TestCaseUtils.dsconfig( |
| | |
| | | assertEquals(bindOperation.getResultCode(), ResultCode.INVALID_CREDENTIALS); |
| | | assertTrue(bindOperation.getErrorMessage().length() > 0); |
| | | |
| | | |
| | | // Change the configuration back and make sure that the error message goes |
| | | // away. |
| | | TestCaseUtils.dsconfig( |
| | |
| | | assertThat(bindOperation.getErrorMessage()).isEmpty(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that performing multiple binds on a client connection will |
| | | * cause the connection to no longer be associated with the previous identity. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that performing subtree delete will |
| | | * cause the connection to no longer be associated |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that performing subtree modify will |
| | | * cause the connection to be associated with new auth |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the "ignore" password policy state update policy |
| | | * works as expected. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the "reactive" password policy state update policy |
| | | * works as expected. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the "proactive" password policy state update policy |
| | | * works as expected. |
| | |
| | | assertNull(bindOperation.getCancelRequest()); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.AVA; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.requests.ModifyDNRequest; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | |
| | | import org.opends.server.types.CancelRequest; |
| | | import org.opends.server.types.CancelResult; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.LockManager.DNLock; |
| | | import org.opends.server.types.Operation; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.ResultCode.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class TestModifyDNOperation extends OperationTestCase |
| | | { |
| | |
| | | protected Operation[] createTestOperations() throws Exception |
| | | { |
| | | return new ModifyDNOperation[] { |
| | | newModifyDNOperationRaw("cn=test,ou=test", "cn=test2", true, "dc=example,dc=com"), |
| | | newModifyDNOperation("cn=test,ou=test", "cn=test2", true, "dc=example,dc=com") |
| | | newModifyDNOpRaw("cn=test,ou=test", "cn=test2", true, "dc=example,dc=com"), |
| | | newModifyDNOp("cn=test,ou=test", "cn=test2", true, "dc=example,dc=com") |
| | | }; |
| | | } |
| | | |
| | | private ModifyDNOperation runModifyDNOperation( |
| | | private ModifyDNOperation runModifyDNOp( |
| | | String entryDN, String newRDN, boolean deleteOldRDN, String newSuperior) throws DirectoryException |
| | | { |
| | | ModifyDNOperation op = newModifyDNOperation(entryDN, newRDN, deleteOldRDN, newSuperior); |
| | | ModifyDNOperation op = newModifyDNOp(entryDN, newRDN, deleteOldRDN, newSuperior); |
| | | op.run(); |
| | | return op; |
| | | } |
| | | |
| | | private ModifyDNOperation runModifyDNOperationRaw( |
| | | private ModifyDNOperation runModifyDNOpRaw( |
| | | String entryDN, String newRDN, boolean deleteOldRDN, String newSuperior) |
| | | { |
| | | ModifyDNOperation op = newModifyDNOperationRaw(entryDN, newRDN, deleteOldRDN, newSuperior); |
| | | ModifyDNOperation op = newModifyDNOpRaw(entryDN, newRDN, deleteOldRDN, newSuperior); |
| | | op.run(); |
| | | return op; |
| | | } |
| | | |
| | | private ModifyDNOperationBasis newModifyDNOperation( |
| | | private ModifyDNOperationBasis newModifyDNOp( |
| | | String entryDN, String newRDN, boolean deleteOldRDN, String newSuperior) throws DirectoryException |
| | | { |
| | | return new ModifyDNOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.<Control> emptyList(), dn(entryDN), rdn(newRDN), deleteOldRDN, dn(newSuperior)); |
| | | } |
| | | |
| | | private ModifyDNOperationBasis newModifyDNOperationRaw( |
| | | private ModifyDNOperationBasis newModifyDNOpRaw( |
| | | String entryDN, String newRDN, boolean deleteOldRDN, String newSuperior) |
| | | { |
| | | return new ModifyDNOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.<Control> emptyList(), b(entryDN), b(newRDN), deleteOldRDN, b(newSuperior)); |
| | | } |
| | | |
| | | private ModifyDNOperation runModifyDNOperation( |
| | | InternalClientConnection conn, String entryDN, String newRDN, boolean deleteOldRDN, Control control) throws DirectoryException |
| | | private ModifyDNOperation runModifyDNOp( |
| | | InternalClientConnection conn, String entryDN, String newRDN, boolean deleteOldRDN, Control control) |
| | | throws DirectoryException |
| | | { |
| | | ModifyDNOperation op = new ModifyDNOperationBasis(conn, nextOperationID(), nextMessageID(), |
| | | Collections.singletonList(control), dn(entryDN), rdn(newRDN), deleteOldRDN, null); |
| | |
| | | return op; |
| | | } |
| | | |
| | | private ModifyDNOperation runModifyDNOperationRaw( |
| | | private ModifyDNOperation runModifyDNOpRaw( |
| | | String entryDN, String newRDN, boolean deleteOldRDN, String newSuperior, Control control) |
| | | { |
| | | ModifyDNOperation op = new ModifyDNOperationBasis(proxyUserConn, nextOperationID(), nextMessageID(), |
| | |
| | | String newEntryDN = "uid=user.test0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperationRaw(oldEntryDN, "uid=user.test0", false, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOpRaw(oldEntryDN, "uid=user.test0", false, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, true, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperationRaw(newEntryDN, "uid=user.0", true, null); |
| | | modifyDNOperation = runModifyDNOpRaw(newEntryDN, "uid=user.0", true, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | String newEntryDN = "uid=user.test0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=user.test0", false, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=user.test0", false, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, true, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(newEntryDN, "uid=user.0", true, null); |
| | | modifyDNOperation = runModifyDNOp(newEntryDN, "uid=user.0", true, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | String newEntryDN = "uid=USER.0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=USER.0", true, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=USER.0", true, null); |
| | | assertSuccess(modifyDNOperation); |
| | | |
| | | Entry newEntry = DirectoryServer.getEntry(dn(oldEntryDN)); |
| | |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(newEntryDN, "uid=user.0", true, null); |
| | | modifyDNOperation = runModifyDNOp(newEntryDN, "uid=user.0", true, null); |
| | | assertSuccess(modifyDNOperation); |
| | | assertNotNull(DirectoryServer.getEntry(dn(oldEntryDN))); |
| | | examineCompletedOperation(modifyDNOperation); |
| | |
| | | String newEntryDN = "uid=UserID.0+cn=Test,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=UserID.0+cn=Test", false, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=UserID.0+cn=Test", false, null); |
| | | assertSuccess(modifyDNOperation); |
| | | assertEntryAttrValue(newEntryDN, "uid", "UserID.0"); |
| | | examineCompletedOperation(modifyDNOperation); |
| | |
| | | String newEntryDN = "uid=userid.0+sn=JENSEN,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=userid.0+sn=JENSEN", false, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=userid.0+sn=JENSEN", false, null); |
| | | assertSuccess(modifyDNOperation); |
| | | assertEntryAttrValue(newEntryDN, "sn", "JENSEN"); |
| | | examineCompletedOperation(modifyDNOperation); |
| | |
| | | String newEntryDN = "uid=user.test0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperationRaw(oldEntryDN, "uid=user.test0", true, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOpRaw(oldEntryDN, "uid=user.test0", true, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, false, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperationRaw(newEntryDN, "uid=user.0", true, null); |
| | | modifyDNOperation = runModifyDNOpRaw(newEntryDN, "uid=user.0", true, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | String newEntryDN = "uid=user.test0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=user.test0", true, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=user.test0", true, null); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, LocalizableMessage.raw("testCancelBeforeStartup")); |
| | | CancelResult cancelResult = modifyDNOperation.cancel(cancelRequest); |
| | |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(newEntryDN, "uid=user.0", true, null); |
| | | modifyDNOperation = runModifyDNOp(newEntryDN, "uid=user.0", true, null); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperationRaw(oldEntryDN, "uid=user.test0", true, "dc=example,dc=com"); |
| | | runModifyDNOpRaw(oldEntryDN, "uid=user.test0", true, "dc=example,dc=com"); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, false, true); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperationRaw(newEntryDN, "uid=user.0", true, "ou=People,dc=example,dc=com"); |
| | | modifyDNOperation = runModifyDNOpRaw(newEntryDN, "uid=user.0", true, "ou=People,dc=example,dc=com"); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | } |
| | |
| | | String newEntryDN = "uid=user.test0,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(oldEntryDN, "uid=user.test0", true, "dc=example,dc=com"); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp(oldEntryDN, "uid=user.test0", true, "dc=example,dc=com"); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, false, true); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(newEntryDN, "uid=user.0", true, "ou=People,dc=example,dc=com"); |
| | | modifyDNOperation = runModifyDNOp(newEntryDN, "uid=user.0", true, "ou=People,dc=example,dc=com"); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | } |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(oldEntryDN, "cn=Aaccf Amar Test", true, "dc=example,dc=com"); |
| | | runModifyDNOp(oldEntryDN, "cn=Aaccf Amar Test", true, "dc=example,dc=com"); |
| | | assertSuccess(modifyDNOperation); |
| | | Entry entry = assertCnAttrValues(newEntryDN, oldEntryDN); |
| | | assertThat(entry.getAttribute("uid")).isEmpty(); |
| | | examineCompletedOPNoExtraPluginCounts(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(newEntryDN, "uid=user.0", false, "ou=People,dc=example,dc=com"); |
| | | modifyDNOperation = runModifyDNOp(newEntryDN, "uid=user.0", false, "ou=People,dc=example,dc=com"); |
| | | assertSuccess(modifyDNOperation); |
| | | Entry newOldEntry = assertCnAttrValues(oldEntryDN, newEntryDN); |
| | | for(Attribute attribute : newOldEntry.getAttribute("uid")) |
| | |
| | | public void testInvalidEntryModify() throws Exception |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation( |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp( |
| | | "uid=user.invalid,ou=People,dc=example,dc=com", "uid=user.test0", true, "dc=example,dc=com"); |
| | | examineIncompleteOperation(modifyDNOperation, NO_SUCH_OBJECT); |
| | | } |
| | |
| | | public void testInvalidRDNModify() throws Exception |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation( |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp( |
| | | "uid=user.0,ou=People,dc=example,dc=com", "invalid=invalid", true, "dc=example,dc=com"); |
| | | examineIncompleteOperation(modifyDNOperation, OBJECTCLASS_VIOLATION); |
| | | } |
| | |
| | | public void testInvalidSuperiorModify() throws Exception |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation( |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp( |
| | | "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", true, "dc=invalid,dc=com"); |
| | | examineIncompleteOperation(modifyDNOperation, NO_SUCH_OBJECT); |
| | | } |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperationRaw("invalid DN", "uid=user.test0", true, "dc=example,dc=com"); |
| | | runModifyDNOpRaw("invalid DN", "uid=user.test0", true, "dc=example,dc=com"); |
| | | examineUnparsedOperation(modifyDNOperation, INVALID_DN_SYNTAX); |
| | | } |
| | | |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperationRaw("uid=user.0,ou=People,dc=example,dc=com", "invalid RDN", true, "dc=example,dc=com"); |
| | | runModifyDNOpRaw("uid=user.0,ou=People,dc=example,dc=com", "invalid RDN", true, "dc=example,dc=com"); |
| | | examineUnparsedOperation(modifyDNOperation, INVALID_DN_SYNTAX); |
| | | } |
| | | |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperationRaw("uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", true, "invalid superior"); |
| | | runModifyDNOpRaw("uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", true, "invalid superior"); |
| | | examineUnparsedOperation(modifyDNOperation, INVALID_DN_SYNTAX); |
| | | } |
| | | |
| | |
| | | public void testModifySuffix() throws Exception |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation("dc=example,dc=com", "dc=exampletest", true, null); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp("dc=example,dc=com", "dc=exampletest", true, null); |
| | | examineIncompleteOperation(modifyDNOperation, UNWILLING_TO_PERFORM); |
| | | } |
| | | |
| | |
| | | String newEntryDN = "uid=user.test0,ou=People,dc=example,dc=com"; |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperationRaw(oldEntryDN, "uid=user.test0", false, null, authV1Control); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOpRaw(oldEntryDN, "uid=user.test0", false, null, authV1Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, true, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperationRaw(newEntryDN, "uid=user.0", true, null, authV1Control); |
| | | modifyDNOperation = runModifyDNOpRaw(newEntryDN, "uid=user.0", true, null, authV1Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(proxyUserConn, oldEntryDN, "uid=user.test0", false, authV1Control); |
| | | runModifyDNOp(proxyUserConn, oldEntryDN, "uid=user.test0", false, authV1Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, true, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(proxyUserConn, newEntryDN, "uid=user.0", true, authV1Control); |
| | | modifyDNOperation = runModifyDNOp(proxyUserConn, newEntryDN, "uid=user.0", true, authV1Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV1Control); |
| | | runModifyDNOp(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV1Control); |
| | | examineIncompleteOperation(modifyDNOperation, AUTHORIZATION_DENIED); |
| | | } |
| | | |
| | |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(proxyUserConn, oldEntryDN, "uid=user.test0", false, authV2Control); |
| | | runModifyDNOp(proxyUserConn, oldEntryDN, "uid=user.test0", false, authV2Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, newEntryDN, true, true); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | modifyDNOperation = runModifyDNOperation(proxyUserConn, newEntryDN, "uid=user.0", true, authV2Control); |
| | | modifyDNOperation = runModifyDNOp(proxyUserConn, newEntryDN, "uid=user.0", true, authV2Control); |
| | | assertSuccessAndEntryExists(modifyDNOperation, oldEntryDN, true, false); |
| | | examineCompletedOperation(modifyDNOperation); |
| | | } |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV2Control); |
| | | runModifyDNOp(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV2Control); |
| | | examineIncompleteOperation(modifyDNOperation, AUTHORIZATION_DENIED); |
| | | } |
| | | |
| | |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ModifyDNOperation modifyDNOperation = |
| | | runModifyDNOperation(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV2Control); |
| | | runModifyDNOp(proxyUserConn, "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, authV2Control); |
| | | examineIncompleteOperation(modifyDNOperation, PROTOCOL_ERROR); |
| | | } |
| | | |
| | |
| | | LDAPControl assertControl = new LDAPControl("1.1.1.1.1.1", true); |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOperation(getRootConnection(), "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, assertControl); |
| | | ModifyDNOperation modifyDNOperation = runModifyDNOp( |
| | | getRootConnection(), "uid=user.0,ou=People,dc=example,dc=com", "uid=user.test0", false, assertControl); |
| | | examineIncompleteOperation(modifyDNOperation, UNAVAILABLE_CRITICAL_EXTENSION); |
| | | } |
| | | |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | ModifyDNOperation modifyDNOperation = newModifyDNOperation( |
| | | ModifyDNOperation modifyDNOperation = newModifyDNOp( |
| | | "uid=user.invalid,ou=People,dc=example,dc=com", "uid=user.test0", true, "dc=example,dc=com"); |
| | | |
| | | CancelRequest cancelRequest = new CancelRequest(false, |
| | |
| | | final String FILTER_CIPHER_KEY_LENGTH = |
| | | "(" + ATTR_CRYPTO_KEY_LENGTH_BITS + "=" + cipherKeyLength + ")"; |
| | | final String searchFilter = |
| | | "(&" + FILTER_OC_INSTANCE_KEY + FILTER_NOT_COMPROMISED + FILTER_CIPHER_TRANSFORMATION_NAME + FILTER_CIPHER_KEY_LENGTH + ")"; |
| | | "(&" |
| | | + FILTER_OC_INSTANCE_KEY |
| | | + FILTER_NOT_COMPROMISED |
| | | + FILTER_CIPHER_TRANSFORMATION_NAME |
| | | + FILTER_CIPHER_KEY_LENGTH |
| | | + ")"; |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter).addAttribute("dn"); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | | assertFalse(searchOp.getSearchEntries().isEmpty()); |
| | |
| | | package org.opends.server.crypto; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.admin.ads.ADSContext; |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.BeforeClass; |
| | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the symmetric key extended operation. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class GetSymmetricKeyExtendedOperationTestCase |
| | | extends CryptoTestCase { |
| | | /** |
| | |
| | | final DN baseDN = DN.valueOf(baseDNStr); |
| | | final String FILTER_OC_INSTANCE_KEY = "(objectclass=" + OC_CRYPTO_CIPHER_KEY + ")"; |
| | | final String FILTER_NOT_COMPROMISED = "(!(" + ATTR_CRYPTO_KEY_COMPROMISED_TIME + "=*))"; |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = "(" + ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME + "=" + cipherTransformationName + ")"; |
| | | final String FILTER_CIPHER_TRANSFORMATION_NAME = |
| | | "(" + ATTR_CRYPTO_CIPHER_TRANSFORMATION_NAME + "=" + cipherTransformationName + ")"; |
| | | final String FILTER_CIPHER_KEY_LENGTH = "(" + ATTR_CRYPTO_KEY_LENGTH_BITS + "=" + cipherKeyLength + ")"; |
| | | final String searchFilter = |
| | | "(&" + FILTER_OC_INSTANCE_KEY + FILTER_NOT_COMPROMISED + FILTER_CIPHER_TRANSFORMATION_NAME + FILTER_CIPHER_KEY_LENGTH + ")"; |
| | | "(&" |
| | | + FILTER_OC_INSTANCE_KEY |
| | | + FILTER_NOT_COMPROMISED |
| | | + FILTER_CIPHER_TRANSFORMATION_NAME |
| | | + FILTER_CIPHER_KEY_LENGTH |
| | | + ")"; |
| | | final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter) |
| | | .addAttribute(ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY); |
| | | InternalSearchOperation searchOp = getRootConnection().processSearch(request); |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.BindOperationBasis; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Control; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.BindOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * A set of test cases for the ANONYMOUS SASL mechanism handler. |
| | | */ |
| | | /** A set of test cases for the ANONYMOUS SASL mechanism handler. */ |
| | | public class AnonymousSASLMechanismHandlerTestCase |
| | | extends ExtensionsTestCase |
| | | { |
| | |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the process of initializing and finalizing the ANONYMOUS SASL |
| | | * mechanism handler. |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>isPasswordBased</CODE> method. |
| | | * |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>isSecure</CODE> method. |
| | | * |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>processSASLBind</CODE> method with no credentials. |
| | | * |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), "3", DN.rootDN(), |
| | | SASL_MECHANISM_ANONYMOUS, null); |
| | | handler.processSASLBind(bindOperation); |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>processSASLBind</CODE> method with an empty set of |
| | | * credentials. |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), "3", DN.rootDN(), |
| | | SASL_MECHANISM_ANONYMOUS, ByteString.empty()); |
| | | handler.processSASLBind(bindOperation); |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>processSASLBind</CODE> method with trace information. |
| | | * |
| | |
| | | AnonymousSASLMechanismHandler handler = new AnonymousSASLMechanismHandler(); |
| | | handler.initializeSASLMechanismHandler(null); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | BindOperationBasis bindOperation = |
| | | new BindOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new BindOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), "3", DN.rootDN(), |
| | | SASL_MECHANISM_ANONYMOUS, |
| | | ByteString.valueOfUtf8("Internal Trace String")); |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a SASL ANONYMOUS bind over LDAP with no credentials. |
| | | * |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a SASL ANONYMOUS bind over LDAP with trace information. |
| | | * |
| | |
| | | handler.finalizeSASLMechanismHandler(); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.AttributeValuePasswordValidatorCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | |
| | | ArrayList<Modification> mods = CollectionUtils.newArrayList( |
| | | new Modification(ModificationType.REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new ModifyOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private AttributeValuePasswordValidator initializePasswordValidator(Entry configEntry) throws ConfigException, InitializationException { |
| | | private AttributeValuePasswordValidator initializePasswordValidator(Entry configEntry) throws Exception { |
| | | return InitializationUtils.initializePasswordValidator( |
| | | new AttributeValuePasswordValidator(), configEntry, AttributeValuePasswordValidatorCfgDefn.getInstance()); |
| | | } |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * A set of test cases for the Bcrypt password storage scheme. |
| | | */ |
| | | /** A set of test cases for the Bcrypt password storage scheme. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class BcryptPasswordStorageSchemeTestCase |
| | | extends PasswordStorageSchemeTestCase |
| | |
| | | /** |
| | | * Retrieves a set of passwords (plain and bcrypt encrypted) that may |
| | | * be used to test the compatibility of bcrypt passwords. |
| | | * The encrypted versions have been provided by external tools or |
| | | * users |
| | | * The encrypted versions have been provided by external tools or users |
| | | * |
| | | * @return A set of couple (cleartext, encrypted) passwords that |
| | | * may be used to test the bcrypt password storage scheme |
| | | */ |
| | | |
| | | @DataProvider(name = "testBcryptPasswords") |
| | | public Object[][] getTestBcryptPasswords() |
| | | throws Exception |
| | | public Object[][] getTestBcryptPasswords() throws Exception |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "secret", "{BCRYPT}$2a$08$sxnezK9Dp9cQvU56LHRwIeI0RvfNn//fFzGnOgQ2l7TOZcZ1wbOVO" }, |
| | | new Object[] { "5[g&f:\"U;#99]!_T", "{BCRYPT}$2a$08$Ttmg4fCbAcq2636pT83d1eM8weXLHbn8OFyVRanP2Tjej5hiZBnyu" }, |
| | | new Object[] { "password", "{BCRYPT}$2a$05$bvIG6Nmid91Mu9RcmmWZfO5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe"}, |
| | | new Object[] { "Secret12!", "{BCRYPT}$2a$10$UOYhwLcHwGYdwWCYq1Xd2.66aPGYq8Q7HDzm8jzTRkdJyAjt/gfhO" }, |
| | | new Object[] { "correctbatteryhorsestapler", "{BCRYPT}$2a$12$mACnM5lzNigHMaf7O1py1O3vlf6.BA8k8x3IoJ.Tq3IB/2e7g61Km"}, |
| | | new Object[] { "TestingWith12%", "{BCRYPT}$2a$12$2nTgfUEOupc7Eb5PyGCnIOzoDG/VMEhIOTKTjIjY3UPjtTI..NoLO" } |
| | | return new Object[][] { |
| | | { "secret", "{BCRYPT}$2a$08$sxnezK9Dp9cQvU56LHRwIeI0RvfNn//fFzGnOgQ2l7TOZcZ1wbOVO" }, |
| | | { "5[g&f:\"U;#99]!_T", "{BCRYPT}$2a$08$Ttmg4fCbAcq2636pT83d1eM8weXLHbn8OFyVRanP2Tjej5hiZBnyu" }, |
| | | { "password", "{BCRYPT}$2a$05$bvIG6Nmid91Mu9RcmmWZfO5HJIMCT8riNW0hEp8f6/FuA2/mHZFpe"}, |
| | | { "Secret12!", "{BCRYPT}$2a$10$UOYhwLcHwGYdwWCYq1Xd2.66aPGYq8Q7HDzm8jzTRkdJyAjt/gfhO" }, |
| | | { "correctbatteryhorsestapler", "{BCRYPT}$2a$12$mACnM5lzNigHMaf7O1py1O3vlf6.BA8k8x3IoJ.Tq3IB/2e7g61Km"}, |
| | | { "TestingWith12%", "{BCRYPT}$2a$12$2nTgfUEOupc7Eb5PyGCnIOzoDG/VMEhIOTKTjIjY3UPjtTI..NoLO" } |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | testAuthPasswords("TestBCrypt", plaintextPassword, encodedPassword); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.meta.CharacterSetPasswordValidatorCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.server.config.meta.CharacterSetPasswordValidatorCfgDefn; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * A set of test cases for the character set password validator. |
| | | */ |
| | | /** A set of test cases for the character set password validator. */ |
| | | public class CharacterSetPasswordValidatorTestCase |
| | | extends ExtensionsTestCase |
| | | { |
| | |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of valid configuration entries that may be used to |
| | | * initialize the validator. |
| | |
| | | return array; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the process of initializing the server with valid configurations. |
| | | * |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "validConfigs", groups= { "slow" }) |
| | | @Test(dataProvider = "validConfigs", groups = "slow") |
| | | public void testInitializeWithValidConfigs(Entry e) |
| | | throws Exception |
| | | { |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private CharacterSetPasswordValidator initializePasswordValidator(Entry e) throws ConfigException, InitializationException { |
| | | private CharacterSetPasswordValidator initializePasswordValidator(Entry e) throws Exception { |
| | | return InitializationUtils.initializePasswordValidator( |
| | | new CharacterSetPasswordValidator(), e, CharacterSetPasswordValidatorCfgDefn.getInstance()); |
| | | } |
| | |
| | | return array; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the process of initializing the server with invalid configurations. |
| | | * |
| | |
| | | fail(buffer.toString()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves a set of data to use when testing a given password with a |
| | | * provided configuration. Each element of the returned array should be an |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code passwordIsAcceptable} method using the provided |
| | | * information. |
| | |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new ModifyOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "secret12", "{CRYPT}$1$X40CcMaA$dd3ndknBLcpkED4/RciyD1" }, |
| | | new Object[] { "#1 Strong Password!", "{CRYPT}$1$7jHbWKyy$gAmpOSdaYVap55MwsQnK5/" }, |
| | | new Object[] { "foo", "{CRYPT}$1$ac/Z7Q3s$5kTVLqMSq9KMqUVyEBfiw0" }, |
| | | new Object[] { "secret12", "{CRYPT}$5$miWe9yahchas7aiy$b/6oTh5QF3bqbdIDWmjtdOxD8df75426zTHwF.MJuyB" }, |
| | | new Object[] { "foo", "{CRYPT}$5$aZoothaeDai0nooG$5LDMuhK6gWtH6/mrrqZbRc5aIRROfrKri4Tvl/D6Z.0"}, |
| | | new Object[] { "#1 Strong Password!", "{CRYPT}$5$aZoothaeDai0nooG$6o0Sbx/RtTA4K/A8uflMsSCid3i7TYktcwWxIp5NFy2"}, |
| | | new Object[] { "secret12", "{CRYPT}$6$miWe9yahchas7aiy$RQASn5qZMCu2FDsR69RHk1RoLVi3skFUhS0qGNCo.MymgkYoWAedMji09UzxMFzOj8fW2GnzsXT4RVn9gcNmf0" }, |
| | | new Object[] { "#1 Strong Password!", "{CRYPT}$6$p0NJY6r4$VV2JfNtRaTmy8hBtVpdgeIUYQIAUyfdLyhiH6VxzsDIw.28oCsVeMQ5ARiL/PoOambM9dAU3vk4ll8uEB/nnx0"}, |
| | | new Object[] { "foo", "{CRYPT}$6$aZoothaeDai0nooG$1K9ePro8ujsqRy/Ag77OVuev8Y8hyN1Jp10S2t9S.1RMtkKn/SbxQbl2MezoL0UJFYjrEzL0zVdO8PcfT3yXS."} |
| | | { "secret12", "{CRYPT}$1$X40CcMaA$dd3ndknBLcpkED4/RciyD1" }, |
| | | { "#1 Strong Password!", "{CRYPT}$1$7jHbWKyy$gAmpOSdaYVap55MwsQnK5/" }, |
| | | { "foo", "{CRYPT}$1$ac/Z7Q3s$5kTVLqMSq9KMqUVyEBfiw0" }, |
| | | { "secret12", "{CRYPT}$5$miWe9yahchas7aiy$b/6oTh5QF3bqbdIDWmjtdOxD8df75426zTHwF.MJuyB" }, |
| | | { "foo", "{CRYPT}$5$aZoothaeDai0nooG$5LDMuhK6gWtH6/mrrqZbRc5aIRROfrKri4Tvl/D6Z.0"}, |
| | | { "#1 Strong Password!", "{CRYPT}$5$aZoothaeDai0nooG$6o0Sbx/RtTA4K/A8uflMsSCid3i7TYktcwWxIp5NFy2"}, |
| | | { "secret12", |
| | | "{CRYPT}$6$miWe9yahchas7aiy$RQASn5qZMCu2FDsR69RHk1RoLVi3skFUhS0qGNCo.MymgkYoWAedMji09UzxMFzOj8fW2GnzsXT4RVn9gcNmf0" }, |
| | | { "#1 Strong Password!", |
| | | "{CRYPT}$6$p0NJY6r4$VV2JfNtRaTmy8hBtVpdgeIUYQIAUyfdLyhiH6VxzsDIw.28oCsVeMQ5ARiL/PoOambM9dAU3vk4ll8uEB/nnx0"}, |
| | | { "foo", |
| | | "{CRYPT}$6$aZoothaeDai0nooG$1K9ePro8ujsqRy/Ag77OVuev8Y8hyN1Jp10S2t9S.1RMtkKn/SbxQbl2MezoL0UJFYjrEzL0zVdO8PcfT3yXS."} |
| | | }; |
| | | } |
| | | |
| | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.AfterClass; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.server.config.meta.DictionaryPasswordValidatorCfgDefn; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.types.Attributes; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.meta.DictionaryPasswordValidatorCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Modification; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | ArrayList<Modification> mods = newArrayList( |
| | | new Modification(REPLACE, Attributes.create("userpassword", password))); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | ModifyOperationBasis modifyOperation = |
| | | new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), |
| | | new ModifyOperationBasis(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | DN.valueOf("uid=test.user,o=test"), mods); |
| | | |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private DictionaryPasswordValidator initializePasswordValidator(Entry configEntry) |
| | | throws ConfigException, InitializationException { |
| | | private DictionaryPasswordValidator initializePasswordValidator(Entry configEntry) throws Exception { |
| | | return InitializationUtils.initializePasswordValidator( |
| | | new DictionaryPasswordValidator(), configEntry, DictionaryPasswordValidatorCfgDefn.getInstance()); |
| | | } |
| | |
| | | throws Exception |
| | | { |
| | | InitializationUtils.initializeStatusNotificationHandler( |
| | | new ErrorLogAccountStatusNotificationHandler(), configEntry, ErrorLogAccountStatusNotificationHandlerCfgDefn.getInstance()); |
| | | new ErrorLogAccountStatusNotificationHandler(), |
| | | configEntry, |
| | | ErrorLogAccountStatusNotificationHandlerCfgDefn.getInstance()); |
| | | } |
| | | |
| | | |
| | |
| | | mapper.finalizeIdentityMapper(); |
| | | } |
| | | |
| | | private ExactMatchIdentityMapper initializeIdentityMapper(Entry mapperEntry) |
| | | throws ConfigException, InitializationException { |
| | | private ExactMatchIdentityMapper initializeIdentityMapper(Entry mapperEntry) throws Exception { |
| | | return InitializationUtils.initializeIdentityMapper( |
| | | new ExactMatchIdentityMapper(), mapperEntry, ExactMatchIdentityMapperCfgDefn.getInstance()); |
| | | } |
| | |
| | | initializeKeyManagerProvider(e); |
| | | } |
| | | |
| | | private FileBasedKeyManagerProvider initializeKeyManagerProvider(Entry e) throws ConfigException, InitializationException { |
| | | private FileBasedKeyManagerProvider initializeKeyManagerProvider(Entry e) throws Exception { |
| | | return InitializationUtils.initializeKeyManagerProvider( |
| | | new FileBasedKeyManagerProvider(), e, FileBasedKeyManagerProviderCfgDefn.getInstance()); |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.io.FileWriter; |
| | | import java.util.List; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.FileBasedTrustManagerProviderCfgDefn; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.server.config.meta.FileBasedTrustManagerProviderCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private FileBasedTrustManagerProvider initializeTrustManagerProvider(Entry e) throws ConfigException, InitializationException { |
| | | private FileBasedTrustManagerProvider initializeTrustManagerProvider(Entry e) throws Exception { |
| | | return InitializationUtils.initializeTrustManagerProvider( |
| | | new FileBasedTrustManagerProvider(), e, FileBasedTrustManagerProviderCfgDefn.getInstance()); |
| | | } |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | public void testSearchhasSubordinatesAttrInMatchingFilter(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(hasSubordinates=" + hasSubs + ")") |
| | | final SearchRequest request = newSearchRequest(entryDN, BASE_OBJECT, "(hasSubordinates=" + hasSubs + ")") |
| | | .addAttribute("hasSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | |
| | | public void testSearchhasSubordinatesAttrInNonMatchingFilter(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | final SearchRequest request = |
| | | newSearchRequest(entryDN, SearchScope.BASE_OBJECT, "(hasSubordinates=wrong)").addAttribute("hasSubordinates"); |
| | | final SearchRequest request = newSearchRequest(entryDN, BASE_OBJECT, "(hasSubordinates=wrong)") |
| | | .addAttribute("hasSubordinates"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 0); |
| | | } |
| | |
| | | return mapper; |
| | | } |
| | | |
| | | public static <H extends ExtendedOperationHandler<C>, C extends ExtendedOperationHandlerCfg> H initializeExtendedOperationHandler( |
| | | public static <H extends ExtendedOperationHandler<C>, C extends ExtendedOperationHandlerCfg> H |
| | | initializeExtendedOperationHandler( |
| | | H handler, Entry e, ManagedObjectDefinition<?, C> cfgDefn) throws ConfigException, InitializationException { |
| | | handler.initializeExtendedOperationHandler(getConfiguration(cfgDefn, e)); |
| | | return handler; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.server.config.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy.*; |
| | | import static org.opends.server.extensions.LDAPPassThroughAuthenticationPolicyFactory.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | return this; |
| | | } |
| | | |
| | | MockPolicyCfg withMappedSearchBindPasswordEnvironmentVariable(final String value) |
| | | MockPolicyCfg withMappedSearchBindPasswordEnvVariable(final String value) |
| | | { |
| | | this.mappedSearchBindPasswordEnvVar = value; |
| | | return this; |
| | |
| | | { mockCfg().withSecondaryServer("test:1000000"), false }, |
| | | |
| | | // Test mapped search parameters. |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH), true }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindDN(null).withMappedSearchBindPassword(null), true }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPassword(null), false }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPasswordProperty("org.opendj.dummy.property"), false }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPasswordProperty("java.version"), true }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPasswordEnvironmentVariable("ORG_OPENDJ_DUMMY_ENVVAR"), false }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPasswordFile("dummy_file.txt"), false }, |
| | | { mockCfg().withMappingPolicy(MappingPolicy.MAPPED_SEARCH).withMappedSearchBindPasswordFile("config/admin-keystore.pin"), true }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH), true }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindDN(null).withMappedSearchBindPassword(null), true }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPassword(null), false }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPasswordProperty("org.opendj.dummy.property"), false }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPasswordProperty("java.version"), true }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPasswordEnvVariable("ORG_OPENDJ_DUMMY_ENVVAR"), false }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPasswordFile("dummy_file.txt"), false }, |
| | | { mockCfgWithPolicy(MAPPED_SEARCH).withMappedSearchBindPasswordFile("config/admin-keystore.pin"), true }, |
| | | |
| | | }; |
| | | // @formatter:on |
| | | } |
| | | |
| | | private MockPolicyCfg mockCfgWithPolicy(MappingPolicy mappingPolicy) |
| | | { |
| | | return mockCfg().withMappingPolicy(mappingPolicy); |
| | | } |
| | | |
| | | /** |
| | | * Tests that searches which fail on one server are automatically retried on |
| | | * another within the same LB. |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private LengthBasedPasswordValidator initializePasswordValidator(Entry validatorEntry) throws ConfigException, InitializationException { |
| | | private LengthBasedPasswordValidator initializePasswordValidator(Entry validatorEntry) throws Exception { |
| | | return InitializationUtils.initializePasswordValidator( |
| | | new LengthBasedPasswordValidator(), validatorEntry, LengthBasedPasswordValidatorCfgDefn.getInstance()); |
| | | } |
| | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.forgerock.opendj.ldap.requests.Requests; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.PasswordStorageScheme; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.forgerock.opendj.ldap.ModificationType.*; |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | PasswordPolicy p = (PasswordPolicy) DirectoryServer.getAuthenticationPolicy(dn); |
| | | final boolean previousValue = p.isAllowPreEncodedPasswords(); |
| | | |
| | | ModifyRequest modifyRequest = Requests.newModifyRequest("cn=Default Password Policy,cn=Password Policies,cn=config") |
| | | ModifyRequest modifyRequest = newModifyRequest("cn=Default Password Policy,cn=Password Policies,cn=config") |
| | | .addModification(REPLACE, "ds-cfg-allow-pre-encoded-passwords", allowPreencoded); |
| | | ModifyOperation modifyOperation = getRootConnection().processModify(modifyRequest); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | mapper.initializeIdentityMapper(configuration); |
| | | } |
| | | |
| | | private RegularExpressionIdentityMapper initializeIdentityMapper(Entry mapperEntry) |
| | | throws ConfigException, InitializationException { |
| | | private RegularExpressionIdentityMapper initializeIdentityMapper(Entry mapperEntry) throws Exception { |
| | | RegularExpressionIdentityMapperCfg configuration = getConfiguration(mapperEntry); |
| | | RegularExpressionIdentityMapper mapper = new RegularExpressionIdentityMapper(); |
| | | assertTrue(mapper.isConfigurationAcceptable(configuration, new LinkedList<LocalizableMessage>())); |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | new Object[] { "secret", "{SSHA512}8gRXO3lD2fGN3JIhbNJOsh31IRFKnWbDNl+cPH3HoJCkUpxZPG617TnN6Nvl2mVMSBLlzPu2eMpOhCDKoolNG6QCsYf2hppQTAVaqfx25PUJ1ngbuBiNDCpK6Xj5PYZiFwa+cpkY/Pzs77bLn3VMxmHhwa+vowfGhy5RRW+6npQ=" } |
| | | { "secret", "{SSHA512}8gRXO3lD2fGN3JIhbNJOsh31IRFKnWbDNl+cPH3HoJCkUpxZPG617TnN6Nvl2mVMSBLlzPu2eMpOhCD" |
| | | + "KoolNG6QCsYf2hppQTAVaqfx25PUJ1ngbuBiNDCpK6Xj5PYZiFwa+cpkY/Pzs77bLn3VMxmHhwa+vowfGhy5RRW+6npQ=" } |
| | | }; |
| | | } |
| | | |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.requests.ModifyRequest; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.SubjectDNToUserAttributeCertificateMapperCfgDefn; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.tools.LDAPSearch; |
| | |
| | | validator.finalizePasswordValidator(); |
| | | } |
| | | |
| | | private static UniqueCharactersPasswordValidator initializePasswordValidator0(Entry validatorEntry) throws ConfigException, InitializationException { |
| | | private static UniqueCharactersPasswordValidator initializePasswordValidator0(Entry validatorEntry) |
| | | throws ConfigException, InitializationException { |
| | | return initializePasswordValidator( |
| | | new UniqueCharactersPasswordValidator(), validatorEntry, UniqueCharactersPasswordValidatorCfgDefn.getInstance()); |
| | | new UniqueCharactersPasswordValidator(), |
| | | validatorEntry, |
| | | UniqueCharactersPasswordValidatorCfgDefn.getInstance()); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private ModifyOperationBasis modify(String entryDN, RawModification... rawMods) |
| | | { |
| | | return new ModifyOperationBasis(getRootConnection(), 1, 1, null, ByteString.valueOfUtf8(entryDN), newArrayList(rawMods)); |
| | | return new ModifyOperationBasis( |
| | | getRootConnection(), 1, 1, null, ByteString.valueOfUtf8(entryDN), newArrayList(rawMods)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 Manuel Gaupp |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.asn1; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.opends.server.protocols.asn1.GSERParser; |
| | | import org.opends.server.protocols.asn1.GSERException; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This class tests the GSERParser. |
| | | */ |
| | | /** This class tests the GSERParser. */ |
| | | public class GSERParserTestCase extends DirectoryServerTestCase |
| | | { |
| | | |
| | | /** |
| | | * Try to create a GSER Parser with <CODE>null</CODE> as parameter. |
| | | */ |
| | | @Test(expectedExceptions = { NullPointerException.class }) |
| | | /** Try to create a GSER Parser with <CODE>null</CODE> as parameter. */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testGSERParserInitWithNull () throws Exception |
| | | { |
| | | GSERParser parser = new GSERParser(null); |
| | | new GSERParser(null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the <CODE>hasNext</CODE> method. |
| | | */ |
| | | /** Test the <CODE>hasNext</CODE> method. */ |
| | | @Test |
| | | public void testHasNext() throws Exception |
| | | { |
| | |
| | | assertFalse(parser.hasNext()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the <CODE>skipSP</CODE> method. |
| | | */ |
| | | /** Test the <CODE>skipSP</CODE> method. */ |
| | | @Test |
| | | public void testSkipSP() throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the <CODE>skipMSP</CODE> method. |
| | | */ |
| | | /** Test the <CODE>skipMSP</CODE> method. */ |
| | | @Test |
| | | public void testSkipMSP() throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Verify that <CODE>skipMSP</CODE> requires at least one space. |
| | | */ |
| | | @Test(expectedExceptions = { GSERException.class }) |
| | | /** Verify that <CODE>skipMSP</CODE> requires at least one space. */ |
| | | @Test(expectedExceptions = GSERException.class) |
| | | public void testSkipMSPwithZeroSpaces() throws Exception |
| | | { |
| | | GSERParser parser = new GSERParser("42"); |
| | | parser.skipMSP(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testSequence</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testSequence</CODE> test case. */ |
| | | @DataProvider(name="sequenceValues") |
| | | public Object[][] createSequenceValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test sequence parsing. |
| | | */ |
| | | /** Test sequence parsing. */ |
| | | @Test(dataProvider="sequenceValues") |
| | | public void testSequence(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | assertEquals(expectedResult,result); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testString</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testString</CODE> test case. */ |
| | | @DataProvider(name="stringValues") |
| | | public Object[][] createStringValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the parsing of String values. |
| | | */ |
| | | /** Test the parsing of String values. */ |
| | | @Test(dataProvider="stringValues") |
| | | public void testString(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | assertEquals(expectedResult,result); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testInteger</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testInteger</CODE> test case. */ |
| | | @DataProvider(name="integerValues") |
| | | public Object[][] createIntegerValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testBigInteger</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testBigInteger</CODE> test case. */ |
| | | @DataProvider(name="bigIntegerValues") |
| | | public Object[][] createBigIntegerValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the parsing of Integer values. |
| | | */ |
| | | /** Test the parsing of Integer values. */ |
| | | @Test(dataProvider="integerValues") |
| | | public void testInteger(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | assertEquals(expectedResult,result); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the parsing of BigInteger values. |
| | | */ |
| | | /** Test the parsing of BigInteger values. */ |
| | | @Test(dataProvider="bigIntegerValues") |
| | | public void testBigInteger(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | assertEquals(expectedResult,result); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testNamedValueIdentifier</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testNamedValueIdentifier</CODE> test case. */ |
| | | @DataProvider(name="namedValueIdentifierValues") |
| | | public Object[][] createNamedValueIdentifierValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the parsing of NamedValue identifiers. |
| | | */ |
| | | /** Test the parsing of NamedValue identifiers. */ |
| | | @Test(dataProvider="namedValueIdentifierValues") |
| | | public void testNamedValueIdentifier(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | assertEquals(expectedResult,result); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Create data for the <CODE>testIdentifiedChoiceIdentifier</CODE> test case. |
| | | */ |
| | | /** Create data for the <CODE>testIdentifiedChoiceIdentifier</CODE> test case. */ |
| | | @DataProvider(name="identifiedChoicdeIdentifierValues") |
| | | public Object[][] createIdentifiedChoicdeIdentifierValues() |
| | | { |
| | |
| | | }; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test the parsing of IdentifiedChoice identifiers. |
| | | */ |
| | | /** Test the parsing of IdentifiedChoice identifiers. */ |
| | | @Test(dataProvider="identifiedChoicdeIdentifierValues") |
| | | public void testIdentifiedChoicdeIdentifier(String value, boolean expectedResult) throws Exception |
| | | { |
| | |
| | | public void testConstructor1WithListener() throws Exception |
| | | { |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener()); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), |
| | | request, new TestInternalSearchListener()); |
| | | } |
| | | |
| | | |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.opends.server.protocols.ldap.ASN1ByteChannelReader; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.IOException; |
| | | import java.nio.channels.Channels; |
| | | import java.nio.channels.IllegalBlockingModeException; |
| | | |
| | | /** |
| | | * Test class for ASN1ByteChannelReader. |
| | | */ |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** Test class for ASN1ByteChannelReader. */ |
| | | public class ASN1ByteChannelReaderTestCase extends ASN1ReaderTestCase |
| | | { |
| | | @Override |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsNull() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsInteger() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsEnumerated() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsBoolean() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsOctetString() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeShortArrayAsSequence() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeLengthMismatchArrayAsBoolean() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeLengthMismatchArrayAsInteger() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeLengthMismatchArrayAsEnumerated() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeLengthMismatchArrayAsOctetString() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsBoolean() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsInteger() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsEnumerated() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsNull() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsOctetString() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeTruncatedLengthArrayAsSequence() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testDecodeSequencePrematureEof() |
| | | throws Exception |
| | | { |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Override |
| | | @Test(expectedExceptions = { IllegalBlockingModeException.class }) |
| | | @Test(expectedExceptions = IllegalBlockingModeException.class) |
| | | public void testSkipElementIncompleteRead() |
| | | throws Exception |
| | | { |
| | |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.server.config.meta.LDAPConnectionHandlerCfgDefn; |
| | | import org.forgerock.opendj.server.config.server.LDAPConnectionHandlerCfg; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ServerContext; |
| | | import org.opends.server.extensions.InitializationUtils; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.opends.server.types.LDAPException; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.testng.annotations.Test; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.ModifyDNRequestProtocolOp class. |
| | | */ |
| | | public class TestModifyDNRequestProtocolOp extends DirectoryServerTestCase { |
| | | /** |
| | | * The protocol op type for modify DN requests. |
| | | */ |
| | | /** The protocol op type for modify DN requests. */ |
| | | public static final byte OP_TYPE_MODIFY_DN_REQUEST = 0x6C; |
| | | |
| | | |
| | | |
| | | /** |
| | | * The protocol op type for modify DN responses. |
| | | */ |
| | | /** The protocol op type for modify DN responses. */ |
| | | public static final byte OP_TYPE_MODIFY_DN_RESPONSE = 0x6D; |
| | | |
| | | /** |
| | | * The DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString dn = |
| | | ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The alt DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altDn = |
| | | ByteString.valueOfUtf8("dc=alt,dc=example,dc=com"); |
| | | |
| | | /** |
| | | * The new DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString newRdn = |
| | | ByteString.valueOfUtf8("dc=example-new"); |
| | | |
| | | /** |
| | | * The alt new DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altNewRdn = |
| | | ByteString.valueOfUtf8("ou=alt,dc=example-new"); |
| | | |
| | | /** |
| | | * The new superiour DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString newSuperiorDn = |
| | | ByteString.valueOfUtf8("dc=widget,dc=com"); |
| | | |
| | | /** |
| | | * The alt new superiour DN for modify DN requests in this test case. |
| | | */ |
| | | private static final ByteString altNewSuperiorDn = |
| | | ByteString.valueOfUtf8("dc=alt,dc=widget,dc=com"); |
| | | /** The DN for modify DN requests in this test case. */ |
| | | private static final ByteString dn = ByteString.valueOfUtf8("dc=example,dc=com"); |
| | | /** The alt DN for modify DN requests in this test case. */ |
| | | private static final ByteString altDn = ByteString.valueOfUtf8("dc=alt,dc=example,dc=com"); |
| | | /** The new DN for modify DN requests in this test case. */ |
| | | private static final ByteString newRdn = ByteString.valueOfUtf8("dc=example-new"); |
| | | /** The alt new DN for modify DN requests in this test case. */ |
| | | private static final ByteString altNewRdn = ByteString.valueOfUtf8("ou=alt,dc=example-new"); |
| | | /** The new superiour DN for modify DN requests in this test case. */ |
| | | private static final ByteString newSuperiorDn = ByteString.valueOfUtf8("dc=widget,dc=com"); |
| | | /** The alt new superiour DN for modify DN requests in this test case. */ |
| | | private static final ByteString altNewSuperiorDn = ByteString.valueOfUtf8("dc=alt,dc=widget,dc=com"); |
| | | |
| | | /** |
| | | * Test to make sure the class processes the right LDAP op type. |
| | |
| | | { |
| | | ModifyDNRequestProtocolOp modifyRequest; |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | modifyRequest = new ModifyDNRequestProtocolOp(dn, newRdn, true, |
| | | newSuperiorDn); |
| | | modifyRequest = new ModifyDNRequestProtocolOp(dn, newRdn, true, newSuperiorDn); |
| | | modifyRequest.toString(buffer); |
| | | |
| | | key.append("ModifyDNRequest(dn=").append(dn).append(", newRDN=").append(newRdn).append(", ").append("deleteOldRDN=").append(true).append(", newSuperior=") |
| | | .append(newSuperiorDn).append(")"); |
| | | String expected = |
| | | "ModifyDNRequest(dn=" + dn + ", newRDN=" + newRdn + ", " + "deleteOldRDN=" + true + ", newSuperior=" |
| | | + newSuperiorDn + ")"; |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | assertEquals(buffer.toString(), expected); |
| | | } |
| | | |
| | | /** |
| | |
| | | "objectClass: organization", |
| | | "entryuuid: " + stringUID(1)); |
| | | |
| | | replServer = newReplicationServer(replServerId, addSequenceLength * 5 + 100, "dependencyTestAddModDelDependencyTestDb"); |
| | | replServer = newReplicationServer( |
| | | replServerId, addSequenceLength * 5 + 100, "dependencyTestAddModDelDependencyTestDb"); |
| | | |
| | | ReplicationBroker broker = openReplicationSession( |
| | | baseDN, brokerId, 1000, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID); |
| | |
| | | "objectClass: top", |
| | | "objectClass: organization"); |
| | | |
| | | replServer = newReplicationServer(replServerId, 5 * addSequenceLength + 100, "dependencyTestAddDelAddDependencyTestDb"); |
| | | replServer = newReplicationServer( |
| | | replServerId, 5 * addSequenceLength + 100, "dependencyTestAddDelAddDependencyTestDb"); |
| | | |
| | | ReplicationBroker broker = openReplicationSession( |
| | | baseDN, brokerId, 100, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID); |
| | |
| | | "objectClass: top", |
| | | "objectClass: organization"); |
| | | |
| | | replServer = newReplicationServer(replServerId, 5 * addSequenceLength + 100, "dependencyTestAddModdnDependencyTestDb"); |
| | | replServer = newReplicationServer( |
| | | replServerId, 5 * addSequenceLength + 100, "dependencyTestAddModdnDependencyTestDb"); |
| | | |
| | | ReplicationBroker broker = openReplicationSession( |
| | | baseDN, brokerId, 100, replServer.getReplicationPort(), 1000, CLEAN_DB_GENERATION_ID); |
| | |
| | | AddMsg addMsg = (AddMsg) msg; |
| | | |
| | | Operation receivedOp = addMsg.createOperation(connection); |
| | | assertEquals(OperationType.ADD.compareTo(receivedOp.getOperationType()), 0, "The received Replication message is not an ADD msg"); |
| | | assertEquals(OperationType.ADD.compareTo(receivedOp.getOperationType()), 0, |
| | | "The received Replication message is not an ADD msg"); |
| | | |
| | | assertEquals(addMsg.getDN(), personEntry.getName(), |
| | | "The received ADD Replication message is not for the excepted DN"); |
| | |
| | | private static ReplicationMsg waitForSpecificMsgs(Session session, ReplicationBroker broker, Class<?>... msgTypes) |
| | | throws Exception |
| | | { |
| | | assertTrue(session != null || broker != null, "One of Session or ReplicationBroker parameter must not be null"); |
| | | assertTrue(session == null || broker == null, "Only one of Session or ReplicationBroker parameter must not be null"); |
| | | assertTrue(session != null || broker != null, |
| | | "One of Session or ReplicationBroker parameter must not be null"); |
| | | assertTrue(session == null || broker == null, |
| | | "Only one of Session or ReplicationBroker parameter must not be null"); |
| | | |
| | | List<Class<?>> msgTypes2 = Arrays.asList(msgTypes); |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | protected void waitConnected(int dsId, int rsId, int rsPort, LDAPReplicationDomain rd, String msg) throws InterruptedException |
| | | protected void waitConnected(int dsId, int rsId, int rsPort, LDAPReplicationDomain rd, String msg) |
| | | throws InterruptedException |
| | | { |
| | | final int secTimeout = 30; |
| | | int nSec = 0; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.common; |
| | | |
| | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test {@link CSN} and {@link CSNGenerator}. |
| | | */ |
| | | /** Test {@link CSN} and {@link CSNGenerator}. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class CSNTest extends ReplicationTestCase |
| | | { |
| | | |
| | | /** |
| | | * Create CSN Data. |
| | | */ |
| | | /** Create CSN Data. */ |
| | | @DataProvider(name = "csnData") |
| | | public Object[][] createConstructorData() { |
| | | long time = 0x12ABC; |
| | |
| | | new CSN(time, seq, id+1); |
| | | } |
| | | |
| | | /** |
| | | * Test toString and constructor from String. |
| | | */ |
| | | /** Test toString and constructor from String. */ |
| | | @Test(dataProvider = "csnData") |
| | | public void csnEncodeDecode(long time, int seq, int id, String str) throws Exception |
| | | { |
| | |
| | | "The encoding/decoding of CSN is not reversible for toString()"); |
| | | } |
| | | |
| | | /** |
| | | * Create CSN. |
| | | */ |
| | | /** Create CSN. */ |
| | | @DataProvider(name = "createCSN") |
| | | public Object[][] createCSNData() |
| | | { |
| | |
| | | @Test(dataProvider = "createCSN") |
| | | public void csnCompare(CSN csn1, CSN csn2, CSN csn3, CSN csn4, CSN csn5) throws Exception |
| | | { |
| | | assertTrue(CSN.compare(null, null) == 0); |
| | | assertEquals(CSN.compare(null, null), 0); |
| | | assertTrue(CSN.compare(null, csn2) < 0); |
| | | assertTrue(CSN.compare(csn1, null) > 0); |
| | | assertTrue(CSN.compare(csn1, csn2) == 0); |
| | | assertEquals(CSN.compare(csn1, csn2), 0); |
| | | assertTrue(CSN.compare(csn1, csn3) < 0); |
| | | assertTrue(CSN.compare(csn3, csn1) > 0); |
| | | assertTrue(CSN.compare(csn1, csn4) < 0); |
| | |
| | | assertFalse(csn1.isNewerThanOrEqualTo(csn5)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Create a {@link CSNGenerator}, then call {@link CSNGenerator#newCSN()} and |
| | | * {@link CSNGenerator#adjust()} |
| | |
| | | assertTrue(csn1.compareTo(csn2) != 0 ); |
| | | } |
| | | |
| | | /** |
| | | * Test the difference in seq num between 2 CSNs. |
| | | */ |
| | | /** Test the difference in seq num between 2 CSNs. */ |
| | | @Test |
| | | public void csnDiffSeqNum() throws Exception |
| | | { |
| | |
| | | assertEquals(csn1.hashCode(), csn2.hashCode()); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | { "o=test1:", "o=test1:;" }, |
| | | { ";;o=test1:;;", ":;o=test1:;" }, |
| | | { cookie, cookie + ";" }, |
| | | { "o=test1:" + csn1 + ";o=test2:" + csn2 + ";;o=test6:", ":;o=test1:" + csn1 + ";o=test2:" + csn2 + ";o=test6:;" }, |
| | | { "o=test1:" + csn1 + ";o=test2:" + csn2 + ";;o=test6:", |
| | | ":;o=test1:" + csn1 + ";o=test2:" + csn2 + ";o=test6:;" }, |
| | | }; |
| | | } |
| | | |
| | |
| | | List<Modification> mods2 = new LinkedList<>(mods); |
| | | replayModifies(entry, hist, 12, mods); |
| | | assertEquals(hist.encodeAndPurge(), attrDel); |
| | | assertThat(mods).as("DEL one value, del by Replace of the same attribute was not correct").containsExactly(mod1, mod2); |
| | | assertThat(mods) |
| | | .as("DEL one value, del by Replace of the same attribute was not correct") |
| | | .containsExactly(mod1, mod2); |
| | | |
| | | // Replay the same modifs again |
| | | replayModifies(entry, hist, 12, mods2); |
| | |
| | | * DS2 sends reset gen id order with bad gen id: DS1 should go in bad gen id status |
| | | * (from degraded status this time) |
| | | */ |
| | | resetGenId(ds2, -1); // -1 to allow next step full update and flush RS db so that DS1 can reconnect after full update |
| | | // -1 to allow next step full update and flush RS db so that DS1 can reconnect after full |
| | | // update |
| | | resetGenId(ds2, -1); |
| | | waitUntilStatusEquals(ds1, ServerStatus.BAD_GEN_ID_STATUS); |
| | | bw.pause(); |
| | | |
| | |
| | | * @param domain The domain whose status we want to test |
| | | * @param expectedStatus The expected domain status |
| | | */ |
| | | private void waitUntilStatusEquals(final LDAPReplicationDomain domain, final ServerStatus expectedStatus) throws Exception |
| | | private void waitUntilStatusEquals(final LDAPReplicationDomain domain, final ServerStatus expectedStatus) |
| | | throws Exception |
| | | { |
| | | assertNotNull(domain); |
| | | assertNotNull(expectedStatus); |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.messages.ReplicationMessages.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | Attribute eattr2 = Attributes.create("namingcontexts", "eav naming contexts"); |
| | | List<Attribute> entryAttrList = newArrayList(eattr1, eattr2); |
| | | |
| | | // @Checkstyle:off |
| | | return new Object[][] { |
| | | { csn1, "dc=test", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte) 0, null }, |
| | | { csn2, "dc=cn2", mods1, true, AssuredMode.SAFE_READ_MODE, (byte) 1, entryAttrList }, |
| | |
| | | { csn2, "dc=test with long mod", mods4, true, AssuredMode.SAFE_READ_MODE, (byte) 120, entryAttrList }, |
| | | { csn2, "dc=testDsaOperation", mods5, true, AssuredMode.SAFE_DATA_MODE, (byte) 99, null }, |
| | | }; |
| | | // @Checkstyle:on |
| | | } |
| | | |
| | | /** |
| | |
| | | Attribute eattr2 = Attributes.create("namingcontexts", "eav naming contexts"); |
| | | List<Attribute> entryAttrList = newArrayList(eattr1, eattr2); |
| | | |
| | | // @Checkstyle:off |
| | | return new Object[][] { |
| | | {"dc=test,dc=com", "dc=new", "11111111-1111-1111-1111-111111111111", "22222222-2222-2222-2222-222222222222", false, "dc=change", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte)0, null}, |
| | | {"dc=test,dc=com", "dc=new", "33333333-3333-3333-3333-333333333333", "44444444-4444-4444-4444-444444444444", true, "dc=change", mods2, true, AssuredMode.SAFE_READ_MODE, (byte)1, entryAttrList}, |
| | |
| | | {"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn", |
| | | "dc=new", "77777777-7777-7777-7777-777777777777", "88888888-8888-8888-8888-888888888888",true, null, mods4, true, AssuredMode.SAFE_DATA_MODE, (byte)99, entryAttrList}, |
| | | }; |
| | | // @Checkstyle:on |
| | | } |
| | | |
| | | /** |
| | |
| | | "ldaps://host:port/dc=foobar2??sub?(sn=Another Entry 2)"); |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, "", 26, 154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | false, SAFE_DATA_MODE, (byte)12, (byte)132, urls1, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | DSInfo dsInfo2 = new DSInfo(-436, "", 493, -227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | true, SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | DSInfo dsInfo3 = new DSInfo(2436, "", 591, 0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | false, SAFE_READ_MODE, (byte)17, (byte)0, urls3, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | DSInfo dsInfo4 = new DSInfo(415, "", 146, 0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | true, SAFE_DATA_MODE, (byte)2, (byte)15, urls4, new HashSet<String>(), new HashSet<String>(), (short)-1); |
| | | |
| | | Set<DSInfo> dsList1 = newHashSet(dsInfo1); |
| | | Set<DSInfo> dsList2 = newHashSet(); |
| | |
| | | @DataProvider(name = "createEntryMsgV3") |
| | | public Object[][] createEntryMsgV3() |
| | | { |
| | | // @Checkstyle:off |
| | | return new Object[][] { |
| | | {"0c32003100646e3a206f753d50656f706c652c64633d6578616d706c652c64633d636f6d0a6f626a656374436c6173733a20746f700a6f626a656374436c6173733a206f7267616e697a6174696f6e616c556e69740a6f753a2050656f706c650a656e747279555549443a2032313131313131312d313131312d313131312d313131312d3131313131313131313131320a0a00", |
| | | 1, 2}}; |
| | | // @Checkstyle:on |
| | | } |
| | | @Test(dataProvider = "createEntryMsgV3") |
| | | public void entryMsgPDUV3(String pduV3, int dest, int sender) throws Exception |
| | |
| | | @DataProvider(name = "createErrorMsgV3") |
| | | public Object[][] createErrorMsgV3() |
| | | { |
| | | // @Checkstyle:off |
| | | return new Object[][] { |
| | | {"0e380039003135313338383933004f6e207375666669782064633d6578616d706c652c64633d636f6d2c207265706c69636174696f6e2073657276657220392070726573656e7465642067656e65726174696f6e2049443d2d31207768656e2065787065637465642067656e65726174696f6e2049443d343800", |
| | | 9, 8, "On suffix dc=example,dc=com, replication server 9 presented generation ID=-1 when expected generation ID=48"}}; |
| | | // @Checkstyle:on |
| | | } |
| | | @Test(dataProvider = "createErrorMsgV3") |
| | | public void errorMsgPDUV3( |
| | |
| | | import static org.forgerock.opendj.ldap.requests.Requests.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.replication.common.AssuredMode.*; |
| | | import static org.opends.server.replication.protocol.OperationContext.*; |
| | | import static org.opends.server.replication.protocol.ProtocolVersion.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | |
| | | |
| | | List<Attribute> eclIncludes = getEntryAttributes(); |
| | | return new Object[][] { |
| | | { csn1, "dc=test", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte)0, null}, |
| | | { csn2, "dc=cn2", mods1, true, AssuredMode.SAFE_READ_MODE, (byte)1, eclIncludes}, |
| | | { csn1, "dc=test", mods1, false, SAFE_DATA_MODE, (byte)0, null}, |
| | | { csn2, "dc=cn2", mods1, true, SAFE_READ_MODE, (byte)1, eclIncludes}, |
| | | { csn2, "dc=test with a much longer dn in case this would " |
| | | + "make a difference", mods1, true, AssuredMode.SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test, cn=with a, o=more complex, ou=dn", mods1, false, AssuredMode.SAFE_READ_MODE, (byte)5, eclIncludes}, |
| | | { csn2, "cn=use\\, backslash", mods1, true, AssuredMode.SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test with several mod", mods2, false, AssuredMode.SAFE_DATA_MODE, (byte)16, eclIncludes}, |
| | | { csn2, "dc=test with several values", mods3, false, AssuredMode.SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test with long mod", mods4, true, AssuredMode.SAFE_READ_MODE, (byte)120, eclIncludes}, |
| | | { csn2, "dc=testDsaOperation", mods5, true, AssuredMode.SAFE_DATA_MODE, (byte)99, null}, |
| | | { csn3, "dc=serverIdLargerThan32767", mods1, true, AssuredMode.SAFE_READ_MODE, (byte)1, null}, |
| | | + "make a difference", mods1, true, SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test, cn=with a, o=more complex, ou=dn", mods1, false, SAFE_READ_MODE, (byte)5, eclIncludes}, |
| | | { csn2, "cn=use\\, backslash", mods1, true, SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test with several mod", mods2, false, SAFE_DATA_MODE, (byte)16, eclIncludes}, |
| | | { csn2, "dc=test with several values", mods3, false, SAFE_READ_MODE, (byte)3, null}, |
| | | { csn2, "dc=test with long mod", mods4, true, SAFE_READ_MODE, (byte)120, eclIncludes}, |
| | | { csn2, "dc=testDsaOperation", mods5, true, SAFE_DATA_MODE, (byte)99, null}, |
| | | { csn3, "dc=serverIdLargerThan32767", mods1, true, SAFE_READ_MODE, (byte)1, null}, |
| | | }; |
| | | } |
| | | |
| | |
| | | assertEquals(msg.isAssured(), isAssured); |
| | | |
| | | // Check assured mode |
| | | assertEquals(msg.getAssuredMode(), AssuredMode.SAFE_DATA_MODE); |
| | | assertEquals(msg.getAssuredMode(), SAFE_DATA_MODE); |
| | | msg.setAssuredMode(assuredMode); |
| | | assertEquals(msg.getAssuredMode(), assuredMode); |
| | | |
| | |
| | | |
| | | List<Attribute> entryAttrList = getEntryAttributes(); |
| | | return new Object[][] { |
| | | {"dc=test,dc=com", "dc=new", false, "dc=change", mods1, false, AssuredMode.SAFE_DATA_MODE, (byte)0, entryAttrList}, |
| | | {"dc=test,dc=com", "dc=new", true, "dc=change", mods2, true, AssuredMode.SAFE_READ_MODE, (byte)1, null}, |
| | | {"dc=test,dc=com", "dc=new", false, "dc=change", mods1, false, SAFE_DATA_MODE, (byte)0, entryAttrList}, |
| | | {"dc=test,dc=com", "dc=new", true, "dc=change", mods2, true, SAFE_READ_MODE, (byte)1, null}, |
| | | // testNG does not like null argument so use "" for the newSuperior instead of null |
| | | {"dc=test,dc=com", "dc=new", false, "", mods3, true, AssuredMode.SAFE_READ_MODE, (byte)3, entryAttrList}, |
| | | {"dc=test,dc=com", "dc=new", false, "", mods3, true, SAFE_READ_MODE, (byte)3, entryAttrList}, |
| | | {"dc=delete,dc=an,dc=entry,dc=with,dc=a,dc=long dn", |
| | | "dc=new", true, "", mods4, true, AssuredMode.SAFE_DATA_MODE, (byte)99, null}, |
| | | "dc=new", true, "", mods4, true, SAFE_DATA_MODE, (byte)99, null}, |
| | | }; |
| | | } |
| | | |
| | |
| | | { |
| | | List<Attribute> entryAttrList = getEntryAttributes(); |
| | | return new Object[][] { |
| | | {"dc=example,dc=com", false, AssuredMode.SAFE_DATA_MODE, (byte)0, entryAttrList}, |
| | | {"o=test", true, AssuredMode.SAFE_READ_MODE, (byte)1, null}, |
| | | {"o=group,dc=example,dc=com", true, AssuredMode.SAFE_READ_MODE, (byte)3, entryAttrList}}; |
| | | {"dc=example,dc=com", false, SAFE_DATA_MODE, (byte)0, entryAttrList}, |
| | | {"o=test", true, SAFE_READ_MODE, (byte)1, null}, |
| | | {"o=group,dc=example,dc=com", true, SAFE_READ_MODE, (byte)3, entryAttrList}}; |
| | | } |
| | | |
| | | @Test(enabled=true,dataProvider = "createAddData") |
| | |
| | | Set<String> a4 = newHashSet(); |
| | | |
| | | DSInfo dsInfo1 = new DSInfo(13, "dsHost1:111", 26, 154631, ServerStatus.FULL_UPDATE_STATUS, |
| | | false, AssuredMode.SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1); |
| | | false, SAFE_DATA_MODE, (byte)12, (byte)132, urls1, a1, a1, (short)1); |
| | | DSInfo dsInfo2 = new DSInfo(-436, "dsHost2:222", 493, -227896, ServerStatus.DEGRADED_STATUS, |
| | | true, AssuredMode.SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2); |
| | | true, SAFE_READ_MODE, (byte)-7, (byte)-265, urls2, a2, a2, (short)2); |
| | | DSInfo dsInfo3 = new DSInfo(2436, "dsHost3:333", 591, 0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3); |
| | | false, SAFE_READ_MODE, (byte)17, (byte)0, urls3, a3, a3, (short)3); |
| | | DSInfo dsInfo4 = new DSInfo(415, "dsHost4:444", 146, 0, ServerStatus.BAD_GEN_ID_STATUS, |
| | | true, AssuredMode.SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4); |
| | | true, SAFE_DATA_MODE, (byte)2, (byte)15, urls4, a4, a4, (short)4); |
| | | DSInfo dsInfo5 = new DSInfo(452436, "dsHost5:555", 45591, 0, ServerStatus.NORMAL_STATUS, |
| | | false, AssuredMode.SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5); |
| | | false, SAFE_READ_MODE, (byte)17, (byte)0, urls3, a1, a1, (short)5); |
| | | |
| | | List<DSInfo> dsList1 = newArrayList(dsInfo1); |
| | | List<DSInfo> dsList2 = newArrayList(); |
| | |
| | | Set<String> a3 = newHashSet("dc", "uid"); |
| | | |
| | | return new Object[][]{ |
| | | {ServerStatus.NORMAL_STATUS, urls1, true, AssuredMode.SAFE_DATA_MODE, (byte)1, a1}, |
| | | {ServerStatus.DEGRADED_STATUS, urls2, false, AssuredMode.SAFE_READ_MODE, (byte)123, a2}, |
| | | {ServerStatus.FULL_UPDATE_STATUS, urls3, false, AssuredMode.SAFE_DATA_MODE, (byte)111, a3}, |
| | | {ServerStatus.NORMAL_STATUS, urls4, true, AssuredMode.SAFE_READ_MODE, (byte)-1, a1}, |
| | | {ServerStatus.DEGRADED_STATUS, urls5, true, AssuredMode.SAFE_DATA_MODE, (byte)97, a2}, |
| | | {ServerStatus.FULL_UPDATE_STATUS, urls6, false, AssuredMode.SAFE_READ_MODE, (byte)-13, a3} |
| | | {ServerStatus.NORMAL_STATUS, urls1, true, SAFE_DATA_MODE, (byte)1, a1}, |
| | | {ServerStatus.DEGRADED_STATUS, urls2, false, SAFE_READ_MODE, (byte)123, a2}, |
| | | {ServerStatus.FULL_UPDATE_STATUS, urls3, false, SAFE_DATA_MODE, (byte)111, a3}, |
| | | {ServerStatus.NORMAL_STATUS, urls4, true, SAFE_READ_MODE, (byte)-1, a1}, |
| | | {ServerStatus.DEGRADED_STATUS, urls5, true, SAFE_DATA_MODE, (byte)97, a2}, |
| | | {ServerStatus.FULL_UPDATE_STATUS, urls6, false, SAFE_READ_MODE, (byte)-13, a3} |
| | | }; |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.Socket; |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeoutException; |
| | | |
| | | import org.assertj.core.api.SoftAssertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.ReplicationDomainCfgDefn.AssuredType; |
| | | import org.forgerock.opendj.server.config.server.ReplicationDomainCfg; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.*; |
| | | import org.opends.server.replication.plugin.DomainFakeCfg; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.protocol.*; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.HostPort; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static java.util.Arrays.*; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.Socket; |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | import java.util.UUID; |
| | | import java.util.concurrent.TimeoutException; |
| | | |
| | | import org.assertj.core.api.SoftAssertions; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.meta.ReplicationDomainCfgDefn.AssuredType; |
| | | import org.forgerock.opendj.server.config.server.ReplicationDomainCfg; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.AssuredMode; |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | | import org.opends.server.replication.common.DSInfo; |
| | | import org.opends.server.replication.common.RSInfo; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.common.ServerStatus; |
| | | import org.opends.server.replication.plugin.DomainFakeCfg; |
| | | import org.opends.server.replication.plugin.MultimasterReplication; |
| | | import org.opends.server.replication.protocol.AckMsg; |
| | | import org.opends.server.replication.protocol.DeleteMsg; |
| | | import org.opends.server.replication.protocol.ErrorMsg; |
| | | import org.opends.server.replication.protocol.ReplServerStartMsg; |
| | | import org.opends.server.replication.protocol.ReplSessionSecurity; |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.opends.server.replication.protocol.Session; |
| | | import org.opends.server.replication.protocol.TopologyMsg; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.HostPort; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test Server part of the assured feature in both safe data and |
| | | * safe read modes. |
| | |
| | | public void runAsserts() |
| | | { |
| | | final SoftAssertions softly = new SoftAssertions(); |
| | | softly.assertThat(domain.getAssuredSrSentUpdates()).as("sentUpdates").isEqualTo(sentUpdates); |
| | | softly.assertThat(domain.getAssuredSrAcknowledgedUpdates()).as("acknowledgedUpdates").isEqualTo(acknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrNotAcknowledgedUpdates()).as("notAcknowledgedUpdates").isEqualTo(notAcknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrTimeoutUpdates()).as("timeoutUpdates").isEqualTo(timeoutUpdates); |
| | | softly.assertThat(domain.getAssuredSrWrongStatusUpdates()).as("wrongStatusUpdates").isEqualTo(wrongStatusUpdates); |
| | | softly.assertThat(domain.getAssuredSrReplayErrorUpdates()).as("replayErrorUpdates").isEqualTo(replayErrorUpdates); |
| | | softly.assertThat(domain.getAssuredSrServerNotAcknowledgedUpdates()).as("serverNotAcknowledgedUpdates").isEqualTo( |
| | | serverNotAcknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdates()).as("receivedUpdates").isEqualTo(receivedUpdates); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdatesAcked()).as("receivedUpdatesAcked").isEqualTo(receivedUpdatesAcked); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdatesNotAcked()).as("receivedUpdatesNotAcked").isEqualTo(receivedUpdatesNotAcked); |
| | | softly.assertThat(domain.getAssuredSrSentUpdates()) |
| | | .as("sentUpdates").isEqualTo(sentUpdates); |
| | | softly.assertThat(domain.getAssuredSrAcknowledgedUpdates()) |
| | | .as("acknowledgedUpdates").isEqualTo(acknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrNotAcknowledgedUpdates()) |
| | | .as("notAcknowledgedUpdates").isEqualTo(notAcknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrTimeoutUpdates()) |
| | | .as("timeoutUpdates").isEqualTo(timeoutUpdates); |
| | | softly.assertThat(domain.getAssuredSrWrongStatusUpdates()) |
| | | .as("wrongStatusUpdates").isEqualTo(wrongStatusUpdates); |
| | | softly.assertThat(domain.getAssuredSrReplayErrorUpdates()) |
| | | .as("replayErrorUpdates").isEqualTo(replayErrorUpdates); |
| | | softly.assertThat(domain.getAssuredSrServerNotAcknowledgedUpdates()) |
| | | .as("serverNotAcknowledgedUpdates").isEqualTo(serverNotAcknowledgedUpdates); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdates()) |
| | | .as("receivedUpdates").isEqualTo(receivedUpdates); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdatesAcked()) |
| | | .as("receivedUpdatesAcked").isEqualTo(receivedUpdatesAcked); |
| | | softly.assertThat(domain.getAssuredSrReceivedUpdatesNotAcked()) |
| | | .as("receivedUpdatesNotAcked").isEqualTo(receivedUpdatesNotAcked); |
| | | softly.assertAll(); |
| | | } |
| | | |
| | |
| | | long sendUpdateTime = System.currentTimeMillis() - startTime; |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | if (mainDsGid == DEFAULT_GID) |
| | | { |
| | | // Check monitoring values (check that ack has been correctly received) |
| | |
| | | assertEquals(fakeRd1.getAssuredSdServerTimeoutUpdates().size(), 0); |
| | | |
| | | // Sanity check |
| | | Thread.sleep(500); // Let time to update to reach other servers |
| | | sleepWhileUpdatePropagates(500); |
| | | fakeRd1.assertReceivedUpdates(0); |
| | | if (otherFakeDS) |
| | | { |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO} |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, |
| | | DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO} |
| | | }; |
| | | } |
| | | |
| | |
| | | * See testSafeDataLevelHigh comment. |
| | | */ |
| | | @Test(dataProvider = "testSafeDataLevelHighPrecommitProvider", groups = "slow", enabled = true) |
| | | public void testSafeDataLevelHighPrecommit(int sdLevel, boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId, |
| | | int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, |
| | | public void testSafeDataLevelHighPrecommit(int sdLevel, |
| | | boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId, |
| | | int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, |
| | | int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, |
| | | int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) throws Exception |
| | | { |
| | | testSafeDataLevelHigh(sdLevel, otherFakeDS, otherFakeDsGid, otherFakeDsGenId, |
| | |
| | | { |
| | | return new Object[][] |
| | | { |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO} |
| | | |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, TIMEOUT_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 2, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, TIMEOUT_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, REPLY_OK_RS_SCENARIO, OTHER_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, DEFAULT_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, OTHER_GID, OTHER_GENID, TIMEOUT_RS_SCENARIO, OTHER_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO}, |
| | | { 3, true, DEFAULT_GID, DEFAULT_GENID, DEFAULT_GID, OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | OTHER_GENID, REPLY_OK_RS_SCENARIO, DEFAULT_GID, |
| | | DEFAULT_GENID, REPLY_OK_RS_SCENARIO} |
| | | }; |
| | | } |
| | | |
| | |
| | | * See testSafeDataLevelHigh comment. |
| | | */ |
| | | @Test(dataProvider = "testSafeDataLevelHighNightlyProvider", groups = "slow", enabled = true) |
| | | public void testSafeDataLevelHighNightly(int sdLevel, boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId, |
| | | int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, |
| | | public void testSafeDataLevelHighNightly(int sdLevel, |
| | | boolean otherFakeDS, int otherFakeDsGid, long otherFakeDsGenId, |
| | | int fakeRs1Gid, long fakeRs1GenId, int fakeRs1Scen, |
| | | int fakeRs2Gid, long fakeRs2GenId, int fakeRs2Scen, |
| | | int fakeRs3Gid, long fakeRs3GenId, int fakeRs3Scen) throws Exception |
| | | { |
| | | testSafeDataLevelHigh(sdLevel, otherFakeDS, otherFakeDsGid, otherFakeDsGenId, |
| | |
| | | int acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | | int timeoutUpdates = fakeRd1.getAssuredSdTimeoutUpdates(); |
| | | Map<Integer,Integer> serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | // Compute the list of servers that are eligible for receiving an assured update |
| | | List<Integer> eligibleServers = computeEligibleServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs2Gid, fakeRs2GenId, fakeRs3Gid, fakeRs3GenId); |
| | | // Compute the list of servers that are eligible for receiving an assured update and that are expected to effectively ack the update |
| | | List<Integer> expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, fakeRs3Gid, fakeRs3GenId, fakeRs3Scen); |
| | | List<Integer> eligibleServers = computeEligibleServersSafeData( |
| | | fakeRs1Gid, fakeRs1GenId, fakeRs2Gid, fakeRs2GenId, fakeRs3Gid, fakeRs3GenId); |
| | | List<Integer> expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, |
| | | fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, |
| | | fakeRs3Gid, fakeRs3GenId, fakeRs3Scen); |
| | | |
| | | // Send update |
| | | long startTime = System.currentTimeMillis(); |
| | | fakeRd1.sendNewFakeUpdate(); |
| | | long sendUpdateTime = System.currentTimeMillis() - startTime; |
| | | |
| | | sleepWhileUpdatePropagates(500); |
| | | // Check |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked and let time the update to reach other servers |
| | | checkTimeAndMonitoringSafeData(1, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(1, otherFakeDS, otherFakeDsGenId, fakeRs1GenId, fakeRs2GenId, fakeRs3GenId, expectedServers); |
| | | checkTimeAndMonitoringSafeData(1, acknowledgedUpdates, timeoutUpdates, serverErrors, |
| | | sendUpdateTime, nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(1, otherFakeDS, otherFakeDsGenId, |
| | | fakeRs1GenId, fakeRs2GenId, fakeRs3GenId, expectedServers); |
| | | |
| | | /*********************************************************************** |
| | | * Send update from DS 1 (2 fake RSs available) and check what happened |
| | |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | | timeoutUpdates = fakeRd1.getAssuredSdTimeoutUpdates(); |
| | | serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | // Compute the list of servers that are eligible for receiving an assured update |
| | | eligibleServers = computeEligibleServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs2Gid, fakeRs2GenId, -1, -1L); |
| | | // Compute the list of servers that are eligible for receiving an assured update and that are expected to effectively ack the update |
| | | expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, -1, -1L, -1); |
| | | expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, |
| | | fakeRs2Gid, fakeRs2GenId, fakeRs2Scen, |
| | | -1, -1L, -1); |
| | | |
| | | // Send update |
| | | startTime = System.currentTimeMillis(); |
| | | fakeRd1.sendNewFakeUpdate(); |
| | | sendUpdateTime = System.currentTimeMillis() - startTime; |
| | | |
| | | sleepWhileUpdatePropagates(500); |
| | | // Check |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked and let time the update to reach other servers |
| | | checkTimeAndMonitoringSafeData(2, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(2, otherFakeDS, otherFakeDsGenId, fakeRs1GenId, fakeRs2GenId, -1L, expectedServers); |
| | | checkTimeAndMonitoringSafeData(2, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, |
| | | nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(2, otherFakeDS, otherFakeDsGenId, |
| | | fakeRs1GenId, fakeRs2GenId, -1L, expectedServers); |
| | | |
| | | /*********************************************************************** |
| | | * Send update from DS 1 (1 fake RS available) and check what happened |
| | |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | | timeoutUpdates = fakeRd1.getAssuredSdTimeoutUpdates(); |
| | | serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | // Compute the list of servers that are eligible for receiving an assured update |
| | | eligibleServers = computeEligibleServersSafeData(fakeRs1Gid, fakeRs1GenId, -1, -1L, -1, -1L); |
| | | // Compute the list of servers that are eligible for receiving an assured update and that are expected to effectively ack the update |
| | | expectedServers = computeExpectedServersSafeData(fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, -1, -1L, -1, -1, -1L, -1); |
| | | expectedServers = computeExpectedServersSafeData( |
| | | fakeRs1Gid, fakeRs1GenId, fakeRs1Scen, -1, -1L, -1, -1, -1L, -1); |
| | | |
| | | // Send update |
| | | startTime = System.currentTimeMillis(); |
| | |
| | | sendUpdateTime = System.currentTimeMillis() - startTime; |
| | | |
| | | // Check |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked and let time the update to reach other servers |
| | | checkTimeAndMonitoringSafeData(3, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, nWishedServers, eligibleServers, expectedServers); |
| | | sleepWhileUpdatePropagates(500); |
| | | checkTimeAndMonitoringSafeData(3, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, |
| | | nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(3, otherFakeDS, otherFakeDsGenId, fakeRs1GenId, -1L, -1L, expectedServers); |
| | | |
| | | /*********************************************************************** |
| | |
| | | acknowledgedUpdates = fakeRd1.getAssuredSdAcknowledgedUpdates(); |
| | | timeoutUpdates = fakeRd1.getAssuredSdTimeoutUpdates(); |
| | | serverErrors = fakeRd1.getAssuredSdServerTimeoutUpdates(); |
| | | // Compute the list of servers that are eligible for receiving an assured update |
| | | eligibleServers = computeEligibleServersSafeData(-1, -1L, -1, -1L, -1, -1L); |
| | | // Compute the list of servers that are eligible for receiving an assured update and that are expected to effectively ack the update |
| | | expectedServers = computeExpectedServersSafeData(-1, -1L, -1, -1, -1L, -1, -1, -1L, -1); |
| | | |
| | | // Send update |
| | |
| | | sendUpdateTime = System.currentTimeMillis() - startTime; |
| | | |
| | | // Check |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked and let time the update to reach other servers |
| | | checkTimeAndMonitoringSafeData(4, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, nWishedServers, eligibleServers, expectedServers); |
| | | sleepWhileUpdatePropagates(500); |
| | | checkTimeAndMonitoringSafeData(4, acknowledgedUpdates, timeoutUpdates, serverErrors, sendUpdateTime, |
| | | nWishedServers, eligibleServers, expectedServers); |
| | | checkWhatHasBeenReceivedSafeData(4, otherFakeDS, otherFakeDsGenId, -1L, -1L, -1L, expectedServers); |
| | | } finally |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sleep a while: |
| | | * counters are updated just after sending thread is unblocked |
| | | * and let time for the update to reach other servers. |
| | | */ |
| | | private void sleepWhileUpdatePropagates(int millis) throws InterruptedException |
| | | { |
| | | Thread.sleep(millis); |
| | | } |
| | | |
| | | /** |
| | | * Check that the DSs and the fake RSs of the topology have received/acked |
| | | * what is expected according to the test step (the number of updates). |
| | | * -1 for a gen id means no need to test the matching fake RS |
| | | */ |
| | | private void checkWhatHasBeenReceivedSafeData(int nSentUpdates, boolean otherFakeDS, long otherFakeDsGenId, long fakeRs1GenId, long fakeRs2GenId, long fakeRs3GenId, List<Integer> expectedServers) |
| | | private void checkWhatHasBeenReceivedSafeData(int nSentUpdates, boolean otherFakeDS, long otherFakeDsGenId, |
| | | long fakeRs1GenId, long fakeRs2GenId, long fakeRs3GenId, List<Integer> expectedServers) |
| | | { |
| | | final FakeReplicationDomain fakeRd1 = fakeRDs[1]; |
| | | final FakeReplicationDomain fakeRd2 = fakeRDs[2]; |
| | |
| | | * Check the time the sending of the safe data assured update took and the monitoring |
| | | * values according to the test configuration. |
| | | */ |
| | | private void checkTimeAndMonitoringSafeData(int nSentUpdates, int prevNAckUpdates, int prevNTimeoutUpdates, Map<Integer,Integer> prevNServerErrors, long sendUpdateTime, |
| | | int nWishedServers, List<Integer> eligibleServers, List<Integer> expectedServers) |
| | | private void checkTimeAndMonitoringSafeData(int nSentUpdates, int prevNAckUpdates, int prevNTimeoutUpdates, |
| | | Map<Integer, Integer> prevNServerErrors, long sendUpdateTime, int nWishedServers, |
| | | List<Integer> eligibleServers, List<Integer> expectedServers) |
| | | { |
| | | final FakeReplicationDomain fakeRd1 = fakeRDs[1]; |
| | | assertEquals(fakeRd1.getAssuredSdSentUpdates(), nSentUpdates); |
| | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), prevNAckUpdates + 1); |
| | | assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), prevNTimeoutUpdates); |
| | | checkServerErrors(fakeRd1.getAssuredSdServerTimeoutUpdates(), prevNServerErrors, null); // Should have same value as previous one |
| | | // Should have same value as previous one |
| | | checkServerErrors(fakeRd1.getAssuredSdServerTimeoutUpdates(), prevNServerErrors, null); |
| | | } |
| | | |
| | | private void checkTimeOutOccured(long sendUpdateTime, int prevNAckUpdates, |
| | |
| | | * <li>if expectedServersInError is null or empty, both map should be equal</li> |
| | | * </ul> |
| | | */ |
| | | private void checkServerErrors(Map<Integer,Integer> measuredServerErrors, Map<Integer,Integer> prevServerErrors, Set<Integer> expectedServersInError) |
| | | private void checkServerErrors( |
| | | Map<Integer, Integer> measuredServerErrors, |
| | | Map<Integer, Integer> prevServerErrors, |
| | | Set<Integer> expectedServersInError) |
| | | { |
| | | if (expectedServersInError != null) |
| | | { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Compute the list of servers that are eligible for receiving a safe data |
| | | * assured update according to their group id and generation id. If -1 is |
| | | * used, the server is out of scope |
| | | * Compute the list of servers that are eligible for receiving a safe data assured update |
| | | * according to their group id and generation id. |
| | | * <p> |
| | | * If -1 is used, the server is out of scope |
| | | */ |
| | | private List<Integer> computeEligibleServersSafeData(int fakeRs1Gid, long fakeRs1GenId, int fakeRs2Gid, long fakeRs2GenId, int fakeRs3Gid, long fakeRs3GenId) |
| | | private List<Integer> computeEligibleServersSafeData( |
| | | int fakeRs1Gid, long fakeRs1GenId, int fakeRs2Gid, long fakeRs2GenId, int fakeRs3Gid, long fakeRs3GenId) |
| | | { |
| | | List<Integer> eligibleServers = new ArrayList<>(3); |
| | | if (areGroupAndGenerationIdOk(fakeRs1Gid, fakeRs1GenId)) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Compute the list of fake servers that are eligible for receiving a safe |
| | | * data assured update and that are expected to effectively ack the update. If |
| | | * -1 is used, the server is out of scope |
| | | * Compute the list of fake servers that are eligible for receiving a safe data assured update |
| | | * and that are expected to effectively ack the update. |
| | | * <p> |
| | | * If -1 is used, the server is out of scope. |
| | | */ |
| | | private List<Integer> computeExpectedServersSafeData( |
| | | int rs1Gid, long rs1GenId, int rs1Scen, |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | assertEquals(fakeRd1.getAssuredSdSentUpdates(), 1); |
| | | assertEquals(fakeRd1.getAssuredSdAcknowledgedUpdates(), 1); |
| | | assertEquals(fakeRd1.getAssuredSdTimeoutUpdates(), 0); |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | checkDSSentAndAcked(fakeRd1, 1); |
| | | fakeRd1.assertReceivedUpdates(0); |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | final FakeReplicationDomain fakeRd2 = fakeRDs[2]; |
| | | checkDSSentAndAcked(fakeRd1, 2); |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | checkDSSentAndAcked(fakeRd1, 3); |
| | | checkDSReceivedAndAcked(fakeRd2, 2); |
| | | |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | checkDSSentAndAcked(fakeRd1, 4); |
| | | |
| | | // Sanity check |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | checkDSSentAndAcked(fakeRd1, 5); |
| | | fakeRd1.assertReceivedUpdates(0); |
| | |
| | | // Other additional DS generation id |
| | | objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID); |
| | | // Other additional DS scenario |
| | | objectArrayList = addPossibleParameters(objectArrayList, REPLY_OK_DS_SCENARIO, TIMEOUT_DS_SCENARIO, REPLAY_ERROR_DS_SCENARIO); |
| | | objectArrayList = addPossibleParameters(objectArrayList, |
| | | REPLY_OK_DS_SCENARIO, TIMEOUT_DS_SCENARIO, REPLAY_ERROR_DS_SCENARIO); |
| | | // Other additional RS group id |
| | | objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GID, OTHER_GID); |
| | | // Other additional RS generation id |
| | | objectArrayList = addPossibleParameters(objectArrayList, DEFAULT_GENID, OTHER_GENID); |
| | | // Other additional RS scenario |
| | | objectArrayList = addPossibleParameters(objectArrayList, REPLY_OK_RS_SCENARIO, TIMEOUT_RS_SCENARIO, DS_TIMEOUT_RS_SCENARIO_SAFE_READ, DS_WRONG_STATUS_RS_SCENARIO_SAFE_READ, DS_REPLAY_ERROR_RS_SCENARIO_SAFE_READ); |
| | | objectArrayList = addPossibleParameters(objectArrayList, |
| | | REPLY_OK_RS_SCENARIO, TIMEOUT_RS_SCENARIO, DS_TIMEOUT_RS_SCENARIO_SAFE_READ, |
| | | DS_WRONG_STATUS_RS_SCENARIO_SAFE_READ, DS_REPLAY_ERROR_RS_SCENARIO_SAFE_READ); |
| | | |
| | | return toDataProvider(objectArrayList); |
| | | } |
| | | |
| | | /** |
| | | * Test safe read mode with only one real RS deployment. |
| | | * Test that the RS is able to acknowledge SR updates with level higher than 1 |
| | | * and also to return errors is some errors occur. |
| | | * - 1 main fake DS connected to the RS |
| | | * - 1 other fake DS connected to the RS, with same GID as RS and same GENID as RS and always acking without error |
| | | * - 1 other fake DS connected to the RS, with GID, GENID, scenario...changed through the provider |
| | | * - 1 fake RS connected to the RS (emulating one fake DS connected to it), with same GID as RS and always acking without error |
| | | * - 1 other fake RS connected to the RS (emulating one fake DS connected to it), with GID scenario...changed through the provider |
| | | * |
| | | * Test safe read mode with only one real RS deployment. Test that the RS is able to acknowledge |
| | | * SR updates with level higher than 1 and also to return errors is some errors occur. |
| | | * <ul> |
| | | * <li>1 main fake DS connected to the RS</li> |
| | | * <li>1 other fake DS connected to the RS, with same GID as RS and same GENID as RS and always |
| | | * acking without error</li> |
| | | * <li>1 other fake DS connected to the RS, with GID, GENID, scenario...changed through the |
| | | * provider</li> |
| | | * <li>1 fake RS connected to the RS (emulating one fake DS connected to it), with same GID as RS |
| | | * and always acking without error</li> |
| | | * <li>1 other fake RS connected to the RS (emulating one fake DS connected to it), with GID |
| | | * scenario...changed through the provider</li> |
| | | * <ul> |
| | | * All possible combinations tested thanks to the provider. |
| | | * <p> |
| | | * Note: it is working but disabled as 17.5 minutes to run |
| | | */ |
| | | @Test(dataProvider = "testSafeReadOneRSComplexProvider", groups = "slow", enabled = false) // Working but disabled as 17.5 minutes to run |
| | | @Test(dataProvider = "testSafeReadOneRSComplexProvider", groups = "slow", enabled = false) |
| | | public void testSafeReadOneRSComplex(int otherFakeDsGid, long otherFakeDsGenId, int otherFakeDsScen, |
| | | int otherFakeRsGid, long otherFakeRsGenId, int otherFakeRsScen) throws Exception |
| | | { |
| | |
| | | boolean shouldSeeTimeout = false; |
| | | boolean shouldSeeWrongStatus = false; |
| | | boolean shouldSeeReplayError = false; |
| | | // Booleans to tell if we expect to see the ds, rs and virtual ds connected to fake rs in server id error list |
| | | // Booleans to tell if we expect to see the ds, rs and virtual ds connected to fake rs |
| | | // in server id error list |
| | | boolean shouldSeeDsIdInError = false; |
| | | boolean shouldSeeRsIdInError = false; |
| | | boolean shouldSeeDsRsIdInError = false; |
| | |
| | | assertBetweenInclusive(sendUpdateTime, SMALL_TIMEOUT, LONG_TIMEOUT); |
| | | } |
| | | |
| | | // Sleep a while as counters are updated just after sending thread is unblocked |
| | | Thread.sleep(500); |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | // Check monitoring values in DS 1 |
| | | final SafeReadAssertions srAssertsRD1 = fakeRd1.newSafeReadAssertions().sentUpdates(1); |
| | | if ((otherFakeDsGid == DEFAULT_GID && otherFakeDsGenId == DEFAULT_GENID && otherFakeDsScen != REPLY_OK_DS_SCENARIO) |
| | | || (otherFakeRsGid == DEFAULT_GID && otherFakeRsGenId == DEFAULT_GENID && otherFakeRsScen != REPLY_OK_RS_SCENARIO)) |
| | | if ((otherFakeDsGid == DEFAULT_GID && otherFakeDsGenId == DEFAULT_GENID |
| | | && otherFakeDsScen != REPLY_OK_DS_SCENARIO) |
| | | || (otherFakeRsGid == DEFAULT_GID && otherFakeRsGenId == DEFAULT_GENID |
| | | && otherFakeRsScen != REPLY_OK_RS_SCENARIO)) |
| | | { |
| | | srAssertsRD1.notAcknowledgedUpdates(1); |
| | | } |
| | |
| | | + "> inclusive"); |
| | | } |
| | | |
| | | private void addExpectedErrors(SafeReadAssertions srAsserts, boolean dsInError, boolean rsInError, boolean dsRsInError) |
| | | private void addExpectedErrors( |
| | | SafeReadAssertions srAsserts, boolean dsInError, boolean rsInError, boolean dsRsInError) |
| | | { |
| | | if (dsInError) |
| | | { |
| | |
| | | int numberOfRealRSs = 4; |
| | | |
| | | // Create real RS 1, 2, 3 |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs2 = createReplicationServer(RS2_ID, DEFAULT_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs3 = createReplicationServer(RS3_ID, DEFAULT_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | rs2 = createReplicationServer(RS2_ID, DEFAULT_GID, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | rs3 = createReplicationServer(RS3_ID, DEFAULT_GID, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | |
| | | // Create real RS 4 (different GID 2) |
| | | rs4 = createReplicationServer(RS4_ID, OTHER_GID_BIS, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs4 = createReplicationServer(RS4_ID, OTHER_GID_BIS, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | |
| | | /* |
| | | * Start DS 1 that will send assured updates |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(1000); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(1000); |
| | | |
| | | checkDSSentAndAcked(fakeRd1, 1); |
| | | |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(1000); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(1000); |
| | | |
| | | checkDSSentAndAcked(fakeRd1, 2); |
| | | |
| | |
| | | int numberOfRealRSs = 2; |
| | | |
| | | // Create real RS 1, 2 |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs2 = createReplicationServer(RS2_ID, OTHER_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | rs2 = createReplicationServer(RS2_ID, OTHER_GID, SMALL_TIMEOUT, testCase, numberOfRealRSs); |
| | | |
| | | /* |
| | | * Start DSs with GID=DEFAULT_GID, connected to RS1 |
| | |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | checkDSSentAndAcked(fakeRDs[1], 1); |
| | | checkDSReceivedAndAcked(fakeRDs[2], 1); |
| | |
| | | int numberOfRealRSs = 2; |
| | | |
| | | // Create real RS 1, 2 |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT + 1000, // Be sure DS2 timeout is seen from DS1 |
| | | // Be sure DS2 timeout is seen from DS1 |
| | | rs1 = createReplicationServer(RS1_ID, DEFAULT_GID, SMALL_TIMEOUT + 1000, |
| | | testCase, numberOfRealRSs); |
| | | rs2 = createReplicationServer(RS2_ID, DEFAULT_GID, SMALL_TIMEOUT, |
| | | testCase, numberOfRealRSs); |
| | |
| | | } |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | |
| | | final FakeReplicationDomain fakeRd2 = fakeRDs[2]; |
| | | if (fakeDsIsEligible) |
| | |
| | | // Wait for DS2 being degraded |
| | | expectStatusForDS(fakeRd1, ServerStatus.DEGRADED_STATUS, FDS2_ID); |
| | | |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | fakeRd1.newSafeReadAssertions() |
| | | .sentUpdates(4) |
| | | .notAcknowledgedUpdates(4) |
| | |
| | | // RS should ack quickly as DS2 degraded and not eligible for assured |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | fakeRd1.newSafeReadAssertions() |
| | | .sentUpdates(5) |
| | | .acknowledgedUpdates(1) |
| | |
| | | // RS should ack quickly as DS2 degraded and not eligible for assured |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | | sleepWhileUpdatePropagates(500); |
| | | fakeRd1.newSafeReadAssertions() |
| | | .sentUpdates(6) |
| | | .acknowledgedUpdates(2) |
| | |
| | | String chDir = "monitorTest" + changelogId + suffix + "Db"; |
| | | ReplServerFakeConfiguration conf = new ReplServerFakeConfiguration(chPort, chDir, 0, changelogId, 0, 100, servers); |
| | | final DN testBaseDN = this.baseDN; |
| | | ReplicationServer replicationServer = new ReplicationServer(conf, new DSRSShutdownSync(), new ECLEnabledDomainPredicate() |
| | | ReplicationServer replicationServer = new ReplicationServer(conf, new DSRSShutdownSync(), |
| | | new ECLEnabledDomainPredicate() |
| | | { |
| | | @Override |
| | | public boolean isECLEnabledDomain(DN baseDN) |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.server.changelog.api.ChangelogException; |
| | | import org.opends.server.replication.server.changelog.api.DBCursor; |
| | | import org.opends.server.replication.server.changelog.file.CompositeDBCursor; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings({ "javadoc", "unchecked" }) |
| | | public class CompositeDBCursorTest extends DirectoryServerTestCase |
| | | { |
| | | |
| | | private final class ConcreteCompositeDBCursor extends CompositeDBCursor<String> |
| | | { |
| | | @Override |
| | |
| | | assertSame(compCursor.getRecord(), expected.getFirst()); |
| | | assertSame(compCursor.getData(), expected.getSecond()); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.mockito.Mock; |
| | | import org.mockito.MockitoAnnotations; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.server.changelog.api.ChangelogException; |
| | | import org.opends.server.replication.server.changelog.api.ReplicationDomainDB; |
| | | import org.opends.server.replication.server.changelog.api.DBCursor.CursorOptions; |
| | | import org.opends.server.replication.server.changelog.file.ECLEnabledDomainPredicate; |
| | | import org.opends.server.replication.server.changelog.file.ECLMultiDomainDBCursor; |
| | | import org.opends.server.replication.server.changelog.file.MultiDomainDBCursor; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.replication.server.changelog.api.ReplicationDomainDB; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*; |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.KeyMatchingStrategy.*; |
| | | import static org.opends.server.replication.server.changelog.api.DBCursor.PositionStrategy.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class ECLMultiDomainDBCursorTest extends DirectoryServerTestCase |
| | | { |
| | | |
| | | @Mock |
| | | private ReplicationDomainDB domainDB; |
| | | private CursorOptions options; |
| | |
| | | } |
| | | }; |
| | | |
| | | |
| | | @BeforeMethod |
| | | public void setup() throws Exception |
| | | { |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2014-2015 ForgeRock AS. |
| | | * Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.replication.protocol.ReplicaOfflineMsg; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.replication.server.changelog.api.DBCursor; |
| | | import org.opends.server.replication.server.changelog.file.ReplicaCursor; |
| | | import org.testng.annotations.BeforeTest; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | |
| | | /** |
| | | * Test the {@link ReplicaCursor} class. |
| | | */ |
| | | /** Test the {@link ReplicaCursor} class. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class ReplicaCursorTest extends ReplicationTestCase |
| | | { |
| | | |
| | | private int timestamp; |
| | | private DBCursor<UpdateMsg> delegateCursor; |
| | | |
| | |
| | | { |
| | | return new ReplicaCursor(delegateCursor, offlineCSN, null, null); |
| | | } |
| | | |
| | | } |
| | |
| | | try |
| | | { |
| | | File rootPath = new File(TEST_DIRECTORY_CHANGELOG); |
| | | List<DN> domainDNs = Arrays.asList(DN.valueOf(DN1_AS_STRING), DN.valueOf(DN2_AS_STRING), DN.valueOf(DN3_AS_STRING)); |
| | | List<DN> domainDNs = Arrays.asList( |
| | | DN.valueOf(DN1_AS_STRING), DN.valueOf(DN2_AS_STRING), DN.valueOf(DN3_AS_STRING)); |
| | | ReplicationEnvironment environment = createReplicationEnv(rootPath); |
| | | cnDB = environment.getOrCreateCNIndexDB(); |
| | | for (int i = 0; i <= 2 ; i++) |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2015 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.server.changelog.file; |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | class SequentialDBCursor implements DBCursor<UpdateMsg> |
| | | { |
| | | |
| | | private final List<UpdateMsg> msgs; |
| | | private UpdateMsg current; |
| | | |
| | |
| | | this.msgs.add(msg); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public UpdateMsg getRecord() |
| | | { |
| | | return current; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean next() |
| | | { |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void close() |
| | | { |
| | | // nothing to do |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return getClass().getSimpleName() + "(currentRecord=" + current |
| | | + " nextMessages=" + msgs + ")"; |
| | | return getClass().getSimpleName() + "(currentRecord=" + current + " nextMessages=" + msgs + ")"; |
| | | } |
| | | |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the JPEGSyntax. |
| | | */ |
| | | /** Test the JPEGSyntax. */ |
| | | @RemoveOnceSDKSchemaIsUsed |
| | | @Test |
| | | public class JPEGSyntaxTest extends BinaryAttributeSyntaxTest |
| | | { |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | protected AttributeSyntax<?> getRule() |
| | | { |
| | | return new JPEGSyntax(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | @DataProvider(name="acceptableValues") |
| | | public Object[][] createAcceptableValues() |
| | |
| | | return new Object[][] {}; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.RemoveOnceSDKSchemaIsUsed; |
| | |
| | | {" ( 2.5.4.3 DESC ' syntax description' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test syntax' X-SCHEMA-FILE '00-core.ldif' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-SUBST Extensions' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-SUBST Extensions' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' X-SCHEMA-FILE '00-core.ldif' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-SUBST Extensions' X-SCHEMA-FILE '00-core.ldif' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-SUBST Extensions' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' X-SCHEMA-FILE '00-core.ldif' )", |
| | | true}, |
| | | {"( 2.5.4.3 DESC 'Test X-SUBST Extensions' X-SCHEMA-FILE '00-core.ldif' X-SUBST '1.3.6.1.4.1.1466.115.121.1.15' )", |
| | | true}, |
| | | {"( 2.5.4.3 DESC 'Test X-PATTERN Extensions' X-PATTERN '[0-9]+' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-PATTERN Extensions' X-PATTERN '[0-9]+' X-SCHEMA-FILE '00-core.ldif' )", true}, |
| | | {"( 2.5.4.3 DESC 'Test X-ENUM Extensions' X-ENUM ( 'black' 'white' ) )", true}, |
| | |
| | | import com.sun.management.snmp.manager.SnmpRequest; |
| | | import com.sun.management.snmp.manager.SnmpSession; |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.Map.Entry; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.config.AbstractManagedObjectDefinition; |
| | | import org.forgerock.opendj.config.server.AdminTestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.SNMPConnectionHandlerCfgDefn; |
| | | import org.forgerock.opendj.server.config.server.SNMPConnectionHandlerCfg; |
| | | import org.opends.server.core.ModifyOperationBasis; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.forgerock.opendj.config.server.ConfigChangeResult; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Modification; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.snmp; |
| | | |
| | |
| | | return socketFactory.createSocket(host, port); |
| | | } |
| | | |
| | | public LDAPMessage bind(SimpleBindRequest bindRequest) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage bind(SimpleBindRequest bindRequest) throws IOException, LDAPException |
| | | { |
| | | return bind(bindRequest, true); |
| | | } |
| | | |
| | | public LDAPMessage bind(SimpleBindRequest bindRequest, boolean throwOnExceptionalResultCode) throws IOException, |
| | | LDAPException, LdapException |
| | | public LDAPMessage bind(SimpleBindRequest bindRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException |
| | | { |
| | | return bind(bindRequest.getName(), bindRequest.getPassword(), throwOnExceptionalResultCode, bindRequest |
| | | .getControls()); |
| | | return bind(bindRequest.getName(), bindRequest.getPassword(), |
| | | throwOnExceptionalResultCode, bindRequest.getControls()); |
| | | } |
| | | |
| | | public void bind(String bindDN, String bindPassword, Control... controls) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | bind(bindDN, bindPassword.getBytes(), true, Arrays.asList(controls)); |
| | | } |
| | | |
| | | private LDAPMessage bind(String bindDN, byte[] bindPassword, boolean throwOnExceptionalResultCode, |
| | | List<Control> controls) throws IOException, LDAPException, LdapException |
| | | List<Control> controls) throws IOException, LDAPException |
| | | { |
| | | writeMessage(new BindRequestProtocolOp(bs(bindDN), 3, bs(bindPassword)), to(controls)); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | return message; |
| | | } |
| | | |
| | | public void unbind() throws IOException, LDAPException, LdapException |
| | | public void unbind() throws IOException, LDAPException |
| | | { |
| | | writeMessage(new UnbindRequestProtocolOp()); |
| | | } |
| | | |
| | | public LDAPMessage add(AddRequest addRequest) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage add(AddRequest addRequest) throws IOException, LDAPException |
| | | { |
| | | return add(addRequest, true); |
| | | } |
| | | |
| | | public LDAPMessage add(AddRequest addRequest, boolean throwOnExceptionalResultCode) throws IOException, |
| | | LDAPException, LdapException |
| | | public LDAPMessage add(AddRequest addRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(addProtocolOp(addRequest), to(addRequest.getControls())); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | return new AddRequestProtocolOp(bs(add.getName()), to(add.getAllAttributes())); |
| | | } |
| | | |
| | | public void search(String baseDN, SearchScope scope, String filterString, String... attributes) throws IOException, |
| | | LDAPException |
| | | public void search(String baseDN, SearchScope scope, String filterString, String... attributes) |
| | | throws IOException, LDAPException |
| | | { |
| | | search(newSearchRequest(baseDN, scope, filterString, attributes)); |
| | | } |
| | | |
| | | public void search(SearchRequest searchRequest) throws IOException, LDAPException, LdapException |
| | | public void search(SearchRequest searchRequest) throws IOException, LDAPException |
| | | { |
| | | writeMessage(searchProtocolOp(searchRequest), to(searchRequest.getControls())); |
| | | } |
| | |
| | | private SearchRequestProtocolOp searchProtocolOp(SearchRequest r) throws LDAPException |
| | | { |
| | | return new SearchRequestProtocolOp(bs(r.getName()), r.getScope(), r.getDereferenceAliasesPolicy(), |
| | | r.getSizeLimit(), r.getTimeLimit(), r.isTypesOnly(), to(r.getFilter()), new LinkedHashSet<>(r.getAttributes())); |
| | | r.getSizeLimit(), r.getTimeLimit(), r.isTypesOnly(), to(r.getFilter()), |
| | | new LinkedHashSet<>(r.getAttributes())); |
| | | } |
| | | |
| | | public List<SearchResultEntryProtocolOp> readEntries() throws LDAPException, IOException |
| | |
| | | return entries; |
| | | } |
| | | |
| | | public LDAPMessage modify(ModifyRequest modifyRequest) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage modify(ModifyRequest modifyRequest) throws IOException, LDAPException |
| | | { |
| | | return modify(modifyRequest, true); |
| | | } |
| | | |
| | | public LDAPMessage modify(ModifyRequest modifyRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(modifyProtocolOp(modifyRequest), to(modifyRequest.getControls())); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | } |
| | | |
| | | public ModifyDNResponseProtocolOp modifyDN(String entryDN, String newRDN, boolean deleteOldRDN) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(new ModifyDNRequestProtocolOp(bs(entryDN), bs(newRDN), deleteOldRDN)); |
| | | return r.readMessage().getModifyDNResponseProtocolOp(); |
| | | } |
| | | |
| | | public LDAPMessage modifyDN(ModifyDNRequest modifyDNRequest) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage modifyDN(ModifyDNRequest modifyDNRequest) throws IOException, LDAPException |
| | | { |
| | | return modifyDN(modifyDNRequest, true); |
| | | } |
| | | |
| | | public LDAPMessage modifyDN(ModifyDNRequest modifyDNRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(modDNProtocolOp(modifyDNRequest), to(modifyDNRequest.getControls())); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | |
| | | private ModifyDNRequestProtocolOp modDNProtocolOp(ModifyDNRequest r) |
| | | { |
| | | return new ModifyDNRequestProtocolOp(bs(r.getName()), bs(r.getNewRDN()), r.isDeleteOldRDN(), bs(r.getNewSuperior())); |
| | | return new ModifyDNRequestProtocolOp( |
| | | bs(r.getName()), bs(r.getNewRDN()), r.isDeleteOldRDN(), bs(r.getNewSuperior())); |
| | | } |
| | | |
| | | public LDAPMessage compare(CompareRequest compareRequest, boolean throwOnExceptionalResultCode) throws IOException, |
| | | LDAPException, LdapException |
| | | public LDAPMessage compare(CompareRequest compareRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(compareProtocolOp(compareRequest), to(compareRequest.getControls())); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | return new CompareRequestProtocolOp(bs(r.getName()), r.getAttributeDescription().toString(), r.getAssertionValue()); |
| | | } |
| | | |
| | | public LDAPMessage delete(DeleteRequest deleteRequest) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage delete(DeleteRequest deleteRequest) throws IOException, LDAPException |
| | | { |
| | | return delete(deleteRequest, true); |
| | | } |
| | | |
| | | public LDAPMessage delete(DeleteRequest deleteRequest, boolean throwOnExceptionalResultCode) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(new DeleteRequestProtocolOp(bs(deleteRequest.getName())), to(deleteRequest.getControls())); |
| | | LDAPMessage message = r.readMessage(); |
| | |
| | | return message; |
| | | } |
| | | |
| | | public LDAPMessage extendedRequest(String oid) throws IOException, LDAPException, LdapException |
| | | public LDAPMessage extendedRequest(String oid) throws IOException, LDAPException |
| | | { |
| | | return extendedRequest(oid, null); |
| | | } |
| | | |
| | | public LDAPMessage extendedRequest(String oid, ByteString requestValue) |
| | | throws IOException, LDAPException, LdapException |
| | | throws IOException, LDAPException |
| | | { |
| | | writeMessage(new ExtendedRequestProtocolOp(oid, requestValue)); |
| | | return r.readMessage(); |
| | |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools.dsconfig; |
| | | |
| | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | |
| | | import org.forgerock.opendj.ldap.AttributeDescription; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.testng.Assert; |
| | |
| | | cnType = DirectoryServer.getAttributeType("cn"); |
| | | Assert.assertNotNull(cnType); |
| | | |
| | | cnValue = ByteString.valueOfUtf8("john doe"); |
| | | cnValue = bs("john doe"); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value1"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | // Note duplicate values. |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertTrue(builder.addAll(Arrays.asList(bs("value1"), bs("value1"), bs("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Add same values. |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertFalse(builder.addAll(Arrays.asList(bs("value1"), bs("value1"), bs("value2")))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value1"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | Assert.assertFalse(builder.add(cnValue)); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Assert.assertTrue(builder.add(ByteString.valueOfUtf8("jane doe"))); |
| | | Assert.assertTrue(builder.add(bs("jane doe"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(cnValue)); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("jane doe"))); |
| | | Assert.assertTrue(a.contains(bs("jane doe"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value1"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOfUtf8("value1"))); |
| | | assertTrue(builder.add(bs("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertFalse(builder.add(ByteString.valueOfUtf8("value1"))); |
| | | assertFalse(builder.add(bs("value1"))); |
| | | assertEquals(builder.size(), 1); |
| | | |
| | | assertTrue(builder.add(ByteString.valueOfUtf8("value2"))); |
| | | assertTrue(builder.add(bs("value2"))); |
| | | assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | assertEquals(a.size(), 2); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("value1"))); |
| | | assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | assertTrue(a.contains(bs("value1"))); |
| | | assertTrue(a.contains(bs("value2"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | Assert.assertTrue(builder.contains(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(builder.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertFalse(builder.contains(ByteString.valueOfUtf8("value3"))); |
| | | Assert.assertTrue(builder.contains(bs("value1"))); |
| | | Assert.assertTrue(builder.contains(bs("value2"))); |
| | | Assert.assertFalse(builder.contains(bs("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, twoValues)); |
| | | |
| | | ByteString av1 = ByteString.valueOfUtf8("value1"); |
| | | ByteString av2 = ByteString.valueOfUtf8("value2"); |
| | | ByteString av3 = ByteString.valueOfUtf8("value3"); |
| | | ByteString av1 = bs("value1"); |
| | | ByteString av2 = bs("value2"); |
| | | ByteString av3 = bs("value3"); |
| | | |
| | | Assert.assertTrue(builder.containsAll(Collections.<ByteString> emptySet())); |
| | | |
| | |
| | | |
| | | builder.add("value1"); |
| | | Assert.assertTrue(builder.iterator().hasNext()); |
| | | Assert.assertEquals(builder.iterator().next(), ByteString.valueOfUtf8("value1")); |
| | | Assert.assertEquals(builder.iterator().next(), bs("value1")); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | Assert.assertTrue(a.contains(bs("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Remove existing values. |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertTrue(builder.removeAll(Arrays.asList(bs("value1"), bs("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove removed values. |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(ByteString.valueOfUtf8("value1"), ByteString.valueOfUtf8("value2")))); |
| | | Assert.assertFalse(builder.removeAll(Arrays.asList(bs("value1"), bs("value2")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | // Remove nothing. |
| | |
| | | |
| | | // Remove non existent value. |
| | | Assert.assertFalse(builder.removeAll(Collections |
| | | .singleton(ByteString.valueOfUtf8("value4")))); |
| | | .singleton(bs("value4")))); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | Assert.assertTrue(a.contains(bs("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | Assert.assertTrue(builder.remove(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertTrue(builder.remove(bs("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Already removed. |
| | | Assert.assertFalse(builder.remove(ByteString.valueOfUtf8("value1"))); |
| | | Assert.assertFalse(builder.remove(bs("value1"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | // Non existent. |
| | | Assert.assertFalse(builder.remove(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertFalse(builder.remove(bs("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value3"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value3"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | // Note duplicate values. |
| | | builder.replaceAll(Arrays.asList(ByteString.valueOfUtf8("value2"), |
| | | ByteString.valueOfUtf8("value2"), ByteString.valueOfUtf8("value4"))); |
| | | builder.replaceAll(Arrays.asList(bs("value2"), |
| | | bs("value2"), bs("value4"))); |
| | | Assert.assertEquals(builder.size(), 2); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 2); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value2"))); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertTrue(a.contains(bs("value2"))); |
| | | Assert.assertTrue(a.contains(bs("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(cnType); |
| | | builder.addAll(createAttribute(cnType, "cn", noOptions, threeValues)); |
| | | |
| | | builder.replace(ByteString.valueOfUtf8("value4")); |
| | | builder.replace(bs("value4")); |
| | | Assert.assertEquals(builder.size(), 1); |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertTrue(a.contains(bs("value4"))); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | Attribute a = builder.toAttribute(); |
| | | Assert.assertEquals(a.size(), 1); |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8("value4"))); |
| | | Assert.assertTrue(a.contains(bs("value4"))); |
| | | } |
| | | |
| | | /** |
| | |
| | | // Check contains(). |
| | | for (String value : values) |
| | | { |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8(value))); |
| | | Assert.assertTrue(a.contains(bs(value))); |
| | | |
| | | // Assumes internal normalization to lower-case. |
| | | Assert.assertTrue(a.contains(ByteString.valueOfUtf8(value.toUpperCase()))); |
| | | Assert.assertTrue(a.contains(bs(value.toUpperCase()))); |
| | | } |
| | | |
| | | Assert.assertFalse(a.contains(ByteString.valueOfUtf8("xxxx"))); |
| | | Assert.assertFalse(a.contains(bs("xxxx"))); |
| | | } |
| | | |
| | | |
| | |
| | | Set<ByteString> expectedValues = new HashSet<>(); |
| | | for (String value : values) |
| | | { |
| | | expectedValues.add(ByteString.valueOfUtf8(value)); |
| | | expectedValues.add(bs(value)); |
| | | } |
| | | |
| | | Assert.assertTrue(a.containsAll(Collections.<ByteString> emptySet())); |
| | |
| | | } |
| | | |
| | | Set<ByteString> bigSet = new HashSet<>(expectedValues); |
| | | bigSet.add(ByteString.valueOfUtf8("xxxx")); |
| | | bigSet.add(bs("xxxx")); |
| | | Assert.assertFalse(a.containsAll(bigSet)); |
| | | |
| | | expectedValues.clear(); |
| | | for (String value : values) |
| | | { |
| | | // Assumes internal normalization to lower-case. |
| | | expectedValues.add(ByteString.valueOfUtf8(value.toUpperCase())); |
| | | expectedValues.add(bs(value.toUpperCase())); |
| | | } |
| | | Assert.assertTrue(a.containsAll(expectedValues)); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Tests {@link Attribute#hasAllOptions(Collection)}. |
| | | * Tests {@link Attribute#hasAllOptions(java.util.Collection)}. |
| | | * |
| | | * @param testCase |
| | | * Test case index (useful for debugging). |
| | |
| | | Assert.assertTrue(i.hasNext()); |
| | | |
| | | ByteString v = i.next(); |
| | | ByteString nv = a.getAttributeDescription().getAttributeType().getEqualityMatchingRule().normalizeAttributeValue(v); |
| | | Assert.assertEquals(nv, ByteString.valueOfUtf8(value)); |
| | | MatchingRule equalityMatchingRule = a.getAttributeDescription().getAttributeType().getEqualityMatchingRule(); |
| | | ByteString nv = equalityMatchingRule.normalizeAttributeValue(v); |
| | | Assert.assertEquals(nv, bs(value)); |
| | | |
| | | try |
| | | { |
| | |
| | | assertThat(a3.isNormalized()).isTrue(); |
| | | |
| | | // no normalization on contains for 0-element and 1-element set |
| | | a1.contains(ByteString.valueOfUtf8("one")); |
| | | a1.contains(bs("one")); |
| | | assertThat(a1.isNormalized()).isFalse(); |
| | | |
| | | // normalization on contains for 1-element set |
| | | a2.contains(ByteString.valueOfUtf8("one")); |
| | | a2.contains(bs("one")); |
| | | assertThat(a2.isNormalized()).isTrue(); |
| | | } |
| | | |
| | |
| | | builder.addAllStrings(Arrays.asList(values)); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | private ByteString bs(String s) |
| | | { |
| | | return ByteString.valueOfUtf8(s); |
| | | } |
| | | } |
| | |
| | | * Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | * information: "Portions Copyright [year] [name of copyright owner]". |
| | | * |
| | | * Copyright 2013-2014 ForgeRock AS. |
| | | * Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | @Test |
| | | public void decodeComplexSampleWithUrlDecode() throws Exception |
| | | { |
| | | final String sample = |
| | | "ld%2Fap://ldap.netsca%2Fpe.com:1389/ou=Sa%2Fles,o=Netscape,c=US?c%2Fn,tel,mail?sub?(objectclass=per%2Fson)?ext%2F1,ext%2F2,ext%2F3"; |
| | | final String sample = "ld%2Fap://ldap.netsca%2Fpe.com:1389/ou=Sa%2Fles,o=Netscape," |
| | | + "c=US?c%2Fn,tel,mail?sub?(objectclass=per%2Fson)?ext%2F1,ext%2F2,ext%2F3"; |
| | | final LDAPURL ldapURL = LDAPURL.decode(sample, true); |
| | | assertThat(ldapURL.getScheme()).isEqualTo("ld/ap"); |
| | | assertThat(ldapURL.getHost()).isEqualTo("ldap.netsca/pe.com"); |
| | |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | runRecreateFilterTest(originalFilter, expectedToStringFilter); |
| | | } |
| | | |
| | | private void runRecreateFilterTest( |
| | | String originalFilter, |
| | | String expectedToStringFilter |
| | | ) throws DirectoryException { |
| | | private void runRecreateFilterTest(String originalFilter, String expectedToStringFilter) throws DirectoryException { |
| | | String regenerated = SearchFilter.createFilterFromString(originalFilter).toString(); |
| | | Assert.assertEquals(regenerated, expectedToStringFilter, "original=" + originalFilter + ", expected=" + expectedToStringFilter); |
| | | assertEquals(regenerated, expectedToStringFilter, |
| | | "original=" + originalFilter + ", expected=" + expectedToStringFilter); |
| | | } |
| | | |
| | | /** These are valid filters. */ |
| | |
| | | |
| | | |
| | | @Test(dataProvider = "equalsTest") |
| | | public void testEquals(String stringFilter1, String stringFilter2, boolean expectEquals, boolean expectStringEquals) throws Exception { |
| | | public void testEquals(String stringFilter1, String stringFilter2, boolean expectEquals, boolean expectStringEquals) |
| | | throws Exception { |
| | | SearchFilter filter1 = SearchFilter.createFilterFromString(stringFilter1); |
| | | SearchFilter filter2 = SearchFilter.createFilterFromString(stringFilter2); |
| | | |
| | |
| | | import java.util.List; |
| | | import java.util.ListIterator; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backupable; |
| | | import org.opends.server.types.BackupConfig; |
| | | import org.opends.server.types.BackupDirectory; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.RestoreConfig; |
| | | |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.Reporter; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | @Test(groups = { "precommit" }, sequential = true) |
| | | @Test(groups = "precommit", sequential = true) |
| | | public class BackupManagerTestCase extends DirectoryServerTestCase |
| | | { |
| | | |
| | | private static final String ENTRY_DN = "dc=example,dc=com"; |
| | | |
| | | private static final String FILE_NAME_PREFIX = "file_"; |
| | |
| | | |
| | | @DataProvider |
| | | Object[][] backupData() throws Exception { |
| | | |
| | | // For each case is provided |
| | | // - a label identifying the case (not used in method but allow to identify easily the case in IDE) |
| | | // - a mock of a backupable (building the mock also involves creating directory and files to backup) |
| | |
| | | * |
| | | * It allows to ensure that a backup can actually be restored. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreateIncrementalBackupThenRestoreThenRemove() throws Exception |
| | | { |
| | | Path sourceDirectory = createSourceDirectory("incremental"); |
| | |
| | | { |
| | | File backupDirectory = TestCaseUtils.createTemporaryDirectory("backupDirectory-" + label + "-"); |
| | | Reporter.log("Create backup directory:" + backupDirectory, true); |
| | | BackupDirectory backupDir = new BackupDirectory(backupDirectory.getAbsolutePath(), DN.valueOf(ENTRY_DN)); |
| | | return backupDir; |
| | | return new BackupDirectory(backupDirectory.getAbsolutePath(), DN.valueOf(ENTRY_DN)); |
| | | } |
| | | |
| | | private Backupable buildBackupable(Path sourceDirectory, int numberOfFiles) throws Exception |
| | |
| | | } |
| | | |
| | | /** |
| | | * Create files in source directory + additional files under a subdirectory of source directory |
| | | * Create files in source directory + additional files under a subdirectory of source directory. |
| | | */ |
| | | private Backupable buildBackupableForMultipleDirectoriesCase(Path sourceDirectory, int numberOfFiles) |
| | | throws Exception |
| | |
| | | close(output); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2007 Brighton Consulting, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | * Portions Copyright 2014-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | import org.opends.server.TestCaseUtils; |
| | | |
| | | import java.io.File; |
| | | import java.util.List; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.testng.Assert; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * {@link org.opends.server.util.Crypt} class. |
| | | * This class defines a set of tests for the {@link org.opends.server.util.Crypt} class. |
| | | * <p> |
| | | * In the "slow" group, since they are unlikely to break and since there are 4K+ they can take a |
| | | * while |
| | | */ |
| | | @Test(groups = { "slow" }, sequential = true) // Make them slow, since they are unlikely to break and since there are 4K+ they can take a while |
| | | @Test(groups = { "slow" }, sequential = true) |
| | | public final class TestCrypt extends UtilTestCase { |
| | | private Crypt crypt = new Crypt(); |
| | | |
| | |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.testng.Assert; |
| | |
| | | * This class defines a set of tests for the |
| | | * {@link org.opends.server.util.StaticUtils} class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public final class TestStaticUtils extends UtilTestCase { |
| | | /** Lower case hex digit lookup table. */ |
| | | private static final char[] HEX_DIGITS_LOWER = new char[] { '0', '1', |
| | |
| | | } |
| | | |
| | | /** |
| | | * Tests the {@link StaticUtils#needsBase64Encoding(ByteSequence)} method. |
| | | * Tests the {@link StaticUtils#needsBase64Encoding(org.forgerock.opendj.ldap.ByteSequence)} method. |
| | | * |
| | | * @param s |
| | | * The test string. |
| | |
| | | public void testMoveFileNonExistentSrc() throws Exception { |
| | | File src = File.createTempFile("src", null); |
| | | File dst = TestCaseUtils.createTemporaryDirectory("dst"); |
| | | File newSrc = new File(dst, src.getName()); |
| | | |
| | | src.delete(); |
| | | |
| | | try { |
| | | StaticUtils.moveFile(src, dst); |
| | | } finally { |
| | | src.delete(); |
| | | dst.delete(); |
| | | newSrc.delete(); |
| | | } |
| | | moveFile(src, dst); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testMoveFileNonExistentDst() throws Exception { |
| | | File src = File.createTempFile("src", null); |
| | | File dst = TestCaseUtils.createTemporaryDirectory("dst"); |
| | | File newSrc = new File(dst, src.getName()); |
| | | |
| | | dst.delete(); |
| | | |
| | | try { |
| | | StaticUtils.moveFile(src, dst); |
| | | } finally { |
| | | src.delete(); |
| | | dst.delete(); |
| | | newSrc.delete(); |
| | | } |
| | | moveFile(src, dst); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testMoveFileSrcNotFile() throws Exception { |
| | | File src = TestCaseUtils.createTemporaryDirectory("src"); |
| | | File dst = TestCaseUtils.createTemporaryDirectory("dst"); |
| | | File newSrc = new File(dst, src.getName()); |
| | | |
| | | try { |
| | | StaticUtils.moveFile(src, dst); |
| | | } finally { |
| | | src.delete(); |
| | | dst.delete(); |
| | | newSrc.delete(); |
| | | } |
| | | moveFile(src, dst); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testMoveFileDstNotDirectory() throws Exception { |
| | | File src = File.createTempFile("src", null); |
| | | File dst = File.createTempFile("dst", null); |
| | | File newSrc = new File(dst, src.getName()); |
| | | |
| | | moveFile(src, dst); |
| | | } |
| | | |
| | | private void moveFile(File src, File dst) throws IOException |
| | | { |
| | | File newSrc = new File(dst, src.getName()); |
| | | try { |
| | | StaticUtils.moveFile(src, dst); |
| | | } finally { |
| | |
| | | |
| | | /** |
| | | * Tests the |
| | | * {@link StaticUtils#toLowerCase(ByteSequence, StringBuilder, boolean)} |
| | | * {@link StaticUtils#toLowerCase(org.forgerock.opendj.ldap.ByteSequence, StringBuilder, boolean)} |
| | | * method. |
| | | * |
| | | * @param input |
| | |
| | | } |
| | | |
| | | /** |
| | | * Create test strings for the {@link StaticUtils#toLowerCase(ByteSequence, StringBuilder, boolean)} method |
| | | * with trimming enabled. |
| | | * Create test strings for the |
| | | * {@link StaticUtils#toLowerCase(org.forgerock.opendj.ldap.ByteSequence, StringBuilder, boolean)} |
| | | * method with trimming enabled. |
| | | * |
| | | * @return Returns an array of test data. |
| | | */ |
| | |
| | | @Test |
| | | public void testStackTraceHasCause() throws Exception |
| | | { |
| | | boolean hasCause = StaticUtils.stackTraceContainsCause(new RuntimeException(new ArithmeticException()), ArithmeticException.class); |
| | | boolean hasCause = StaticUtils.stackTraceContainsCause( |
| | | new RuntimeException(new ArithmeticException()), ArithmeticException.class); |
| | | Assert.assertTrue(hasCause, "First case : ArithmeticException should be detected as a cause"); |
| | | |
| | | hasCause = StaticUtils.stackTraceContainsCause(new RuntimeException(new RuntimeException()), ArithmeticException.class); |
| | | hasCause = StaticUtils.stackTraceContainsCause( |
| | | new RuntimeException(new RuntimeException()), ArithmeticException.class); |
| | | Assert.assertFalse(hasCause, "Second case : ArithmeticException should not be detected as a cause"); |
| | | |
| | | hasCause = StaticUtils.stackTraceContainsCause(new RuntimeException(new IllegalThreadStateException()), IllegalArgumentException.class); |
| | | hasCause = StaticUtils.stackTraceContainsCause( |
| | | new RuntimeException(new IllegalThreadStateException()), IllegalArgumentException.class); |
| | | Assert.assertTrue(hasCause, "Third case : IllegalThreadStateException should be detected as a cause"); |
| | | } |
| | | } |