Converted opendj3 code to use SearchRequest like API
InternalSearchOperation.java:
Removed one constructor, and replaced it with the use of the ones with SearchRequest parameter.
| | |
| | | { |
| | | final int messageID = nextMessageID.getAndIncrement(); |
| | | return enqueueOperation(new SearchOperationBasis(clientConnection, messageID, messageID, |
| | | to(request.getControls()), valueOf(request.getName()), |
| | | to(request.getControls()), to(request.getName()), |
| | | request.getScope(), request.getDereferenceAliasesPolicy(), |
| | | request.getSizeLimit(), request.getTimeLimit(), |
| | | request.isTypesOnly(), to(request.getFilter()), |
| | | request.isTypesOnly(), toSearchFilter(request.getFilter()), |
| | | new LinkedHashSet<String>(request.getAttributes())), entryHandler); |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.core.*; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.forgerock.opendj.ldap.ByteSequenceReader; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.protocols.ldap.*; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.forgerock.opendj.ldap.DecodeException.*; |
| | | import static org.opends.messages.ProtocolMessages.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class provides an implementation of a |
| | | * {@code java.io.OutputStream} that can be used to facilitate |
| | |
| | | throws IOException |
| | | { |
| | | int messageID = message.getMessageID(); |
| | | SearchRequestProtocolOp request = |
| | | message.getSearchRequestProtocolOp(); |
| | | SearchRequestProtocolOp request = message.getSearchRequestProtocolOp(); |
| | | |
| | | InternalClientConnection conn = socket.getConnection(); |
| | | InternalSearchOperation op = |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | messageID, message.getControls(), request.getBaseDN(), |
| | | request.getScope(), request.getDereferencePolicy(), |
| | | request.getSizeLimit(), request.getTimeLimit(), |
| | | request.getTypesOnly(), request.getFilter(), |
| | | request.getAttributes(), this); |
| | | DN baseDN = null; |
| | | SearchFilter filter; |
| | | try |
| | | { |
| | | baseDN = DN.valueOf(request.getBaseDN().toString()); |
| | | filter = request.getFilter().toSearchFilter(); |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | final String cause = (baseDN == null ? "baseDN" : "filter"); |
| | | throw error(LocalizableMessage.raw("Could not decode " + cause), e); |
| | | } |
| | | SearchRequest sr = newSearchRequest(baseDN, request.getScope(), filter) |
| | | .setDereferenceAliasesPolicy(request.getDereferencePolicy()) |
| | | .setSizeLimit(request.getSizeLimit()) |
| | | .setTimeLimit(request.getTimeLimit()) |
| | | .setTypesOnly(request.getTypesOnly()) |
| | | .addAttribute(request.getAttributes()) |
| | | .addControl(message.getControls()); |
| | | InternalSearchOperation op = new InternalSearchOperation( |
| | | conn, nextOperationID(), messageID, sr, this); |
| | | op.run(); |
| | | |
| | | SearchResultDoneProtocolOp searchDone = |
| | |
| | | * @param searchEntry The matching search result entry to be |
| | | * processed. |
| | | */ |
| | | @Override |
| | | @org.opends.server.types.PublicAPI( |
| | | stability=org.opends.server.types.StabilityLevel.PRIVATE, |
| | | mayInstantiate=false, |
| | |
| | | * @param searchReference The search result reference to be |
| | | * processed. |
| | | */ |
| | | @Override |
| | | @org.opends.server.types.PublicAPI( |
| | | stability=org.opends.server.types.StabilityLevel.PRIVATE, |
| | | mayInstantiate=false, |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.api.ClientConnection; |
| | |
| | | /** The set of search references returned for this search. */ |
| | | private List<SearchResultReference> referenceList; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new internal search operation with the provided |
| | | * information. |
| | | * |
| | | * @param internalConnection The internal client connection with |
| | | * which this internal search operation |
| | | * is associated. |
| | | * @param operationID The operation ID for this internal |
| | | * search. |
| | | * @param messageID The message ID for this internal |
| | | * search. |
| | | * @param requestControls The set of request controls for this |
| | | * internal search. |
| | | * @param rawBaseDN The raw base DN for this internal |
| | | * search. |
| | | * @param scope The scope for this internal search. |
| | | * @param derefPolicy The alias dereferencing policy for |
| | | * this internal search. |
| | | * @param sizeLimit The size limit for this internal |
| | | * search. |
| | | * @param timeLimit The time limit for this internal |
| | | * search. |
| | | * @param typesOnly The typesOnly flag for this internal |
| | | * search. |
| | | * @param rawFilter The raw filter for this internal |
| | | * search. |
| | | * @param attributes The names of the requested attributes |
| | | * for this internal search. |
| | | * @param searchListener The internal search listener that |
| | | * should be used to process the |
| | | * results, or <CODE>null</CODE> if |
| | | * they should be collected internally. |
| | | */ |
| | | public InternalSearchOperation( |
| | | ClientConnection internalConnection, |
| | | long operationID, int messageID, |
| | | List<Control> requestControls, ByteString rawBaseDN, |
| | | SearchScope scope, DereferenceAliasesPolicy derefPolicy, |
| | | int sizeLimit, int timeLimit, boolean typesOnly, |
| | | RawFilter rawFilter, Set<String> attributes, |
| | | InternalSearchListener searchListener) |
| | | { |
| | | super(internalConnection, operationID, messageID, requestControls, |
| | | rawBaseDN, scope, derefPolicy, sizeLimit, timeLimit, |
| | | typesOnly, rawFilter, attributes); |
| | | |
| | | |
| | | |
| | | |
| | | if (searchListener == null) |
| | | { |
| | | this.searchListener = null; |
| | | this.entryList = new LinkedList<SearchResultEntry>(); |
| | | this.referenceList = new LinkedList<SearchResultReference>(); |
| | | } |
| | | else |
| | | { |
| | | this.searchListener = searchListener; |
| | | this.entryList = null; |
| | | this.referenceList = null; |
| | | } |
| | | |
| | | setInternalOperation(true); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Creates a new internal search operation with the provided information. |
| | | * |
| | |
| | | searchListener); |
| | | } |
| | | |
| | | // TODO JNR remove?? |
| | | private InternalSearchOperation( |
| | | ClientConnection internalConnection, |
| | | long operationID, int messageID, |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | |
| | | import org.opends.server.plugins.UpdatePreOpPlugin; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.BindRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.BindResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPAttribute; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.LDAPModification; |
| | | import org.opends.server.protocols.ldap.ModifyRequestProtocolOp; |
| | |
| | | |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "baseDNs") |
| | | public void testSuccessReplaceExistingWithNew(String baseDN) |
| | | throws Exception |
| | | public void testSuccessReplaceExistingWithNew(String baseDN) throws Exception |
| | | { |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user," + baseDN, |
| | |
| | | "userPassword: password", |
| | | "mail: foo"); |
| | | |
| | | String dn = "uid=test.user," + baseDN; |
| | | LDAPAttribute attr = newLDAPAttribute("uid", "test.user"); |
| | | ModifyOperation modifyOperation = processModify("uid=test.user," + baseDN, replace(attr)); |
| | | ModifyOperation modifyOperation = processModify(dn, replace(attr)); |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("uid=test.user," + baseDN), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(uid=test.user)"), |
| | | null, null); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(dn, SearchScope.WHOLE_SUBTREE, "(uid=test.user)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(baseDN), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(cn=Test User)"), |
| | | null, null); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, "(cn=Test User)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the ability to perform a modification that deletes one value of an |
| | | * attribute containing two values, the values are the same but the attribute |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test(dataProvider = "baseDNs") |
| | | public void testSuccessDeleteAttributeWithOption(String baseDN) |
| | | throws Exception |
| | | public void testSuccessDeleteAttributeWithOption(String baseDN) throws Exception |
| | | { |
| | | TestCaseUtils.addEntry( |
| | | "dn: uid=test.user," + baseDN, |
| | |
| | | assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS); |
| | | retrieveSuccessfulOperationElements(modifyOperation); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(baseDN), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(givenName;lang-de=X)"), |
| | | null, null); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, "(givenName;lang-de=X)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | @Override |
| | | protected Operation[] createTestOperations() throws Exception |
| | | { |
| | | return new Operation[] |
| | | { |
| | | new SearchOperationBasis( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | -1, |
| | | -1, |
| | | false, |
| | | LDAPFilter.objectClassPresent(), |
| | | null) |
| | | }; |
| | | return new Operation[0]; |
| | | } |
| | | |
| | | /** |
| | |
| | | // assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1); |
| | | } |
| | | |
| | | private Entry searchInternalForSingleEntry( |
| | | InternalSearchOperation searchOperation) |
| | | private Entry getSingleEntry(InternalSearchOperation searchOperation) |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | searchOperation.run(); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = newInternalSearchOperation(LDAPFilter.objectClassPresent()); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 4); |
| | | assertEquals(searchOperation.getReferencesSent(), 2); |
| | |
| | | @Test |
| | | public void testSearchInternalUnspecifiedAttributes() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)")); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)"); |
| | | Entry resultEntry = getSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | | |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchInternalUnspecifiedAttributesOmitValues() |
| | | throws Exception |
| | | public void testSearchInternalUnspecifiedAttributesOmitValues() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | true, |
| | | LDAPFilter.decode("(objectclass=inetorgperson)"), |
| | | null, null); |
| | | |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | SearchRequest request = Requests.newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=inetorgperson)") |
| | | .setTimeLimit(Integer.MAX_VALUE) |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTypesOnly(true); |
| | | Entry resultEntry = getSingleEntry(getRootConnection().processSearch(request)); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses().size(), 0); |
| | | |
| | |
| | | @Test |
| | | public void testSearchInternalAllOperationalAttributes() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "+"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)", "+"); |
| | | Entry resultEntry = getSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses().size(), 0); |
| | | assertEquals(resultEntry.getUserAttributes().size(), 0); |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchInternalAllUserAndOperationalAttributes() |
| | | throws Exception |
| | | public void testSearchInternalAllUserAndOperationalAttributes() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "+"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)", "*", "+"); |
| | | Entry resultEntry = getSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | | assertTrue(resultEntry.getOperationalAttributes().size() > 0); |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchInternalAllUserAttributesPlusSelectedOperational() |
| | | throws Exception |
| | | public void testSearchInternalAllUserAttributesPlusSelectedOperational() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "createtimestamp"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | newInternalSearchOperation("(objectclass=inetorgperson)", "*", "createtimestamp"); |
| | | Entry resultEntry = getSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses()); |
| | | |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchInternalSelectedAttributes() |
| | | throws Exception |
| | | public void testSearchInternalSelectedAttributes() throws Exception |
| | | { |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "uid", "createtimestamp"); |
| | | Entry resultEntry = searchInternalForSingleEntry(searchOperation); |
| | | newInternalSearchOperation("(objectclass=inetorgperson)", "uid", "createtimestamp"); |
| | | Entry resultEntry = getSingleEntry(searchOperation); |
| | | |
| | | assertEquals(resultEntry.getObjectClasses().size(), 0); |
| | | assertEquals(resultEntry.getUserAttributes().size(), 1); |
| | | assertEquals(resultEntry.getOperationalAttributes().size(), 1); |
| | | } |
| | | |
| | | private InternalSearchOperation newInternalSearchOperation(LDAPFilter filter, String... attributes) |
| | | private InternalSearchOperation newInternalSearchOperation(String filter, String... attributes) throws Exception |
| | | { |
| | | return new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, Integer.MAX_VALUE, Integer.MAX_VALUE, false, |
| | | filter, new LinkedHashSet<String>(Arrays.asList(attributes)), null); |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, filter) |
| | | .addAttribute(attributes); |
| | | return getRootConnection().processSearch(request); |
| | | } |
| | | |
| | | @Test |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)")); |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=inetorgperson)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getReferencesSent(), 2); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(ou=*)"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest(BASE, SearchScope.SINGLE_LEVEL, "(ou=*)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getReferencesSent(), 1); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(objectclass=ldapsubentry)")); |
| | | searchOperation.run(); |
| | | |
| | | SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=ldapsubentry)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.singletonList((Control)new SubentriesControl(true, true)), |
| | | ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | |
| | | SearchRequest request = Requests.newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE) |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE) |
| | | .addControl(new SubentriesControl(true, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | Collections.singletonList((Control) new LDAPControl( |
| | | OID_LDUP_SUBENTRIES, true)), ByteString.valueOf(BASE), |
| | | SearchScope.WHOLE_SUBTREE, DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, Integer.MAX_VALUE, false, |
| | | LDAPFilter.objectClassPresent(), null, null); |
| | | |
| | | searchOperation.run(); |
| | | |
| | | SearchRequest request = Requests.newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE) |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE) |
| | | .addControl(new LDAPControl(OID_LDUP_SUBENTRIES, true)); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(&(cn=*)(objectclass=ldapsubentry))")); |
| | | searchOperation.run(); |
| | | SearchRequest request1 = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(&(cn=*)(objectclass=ldapsubentry))"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request1); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | assertEquals(searchOperation.getErrorMessage().length(), 0); |
| | | |
| | | searchOperation = newInternalSearchOperation(LDAPFilter.decode("(&(&(cn=*)(objectclass=ldapsubentry)))")); |
| | | searchOperation.run(); |
| | | SearchRequest request2 = |
| | | newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(&(&(cn=*)(objectclass=ldapsubentry)))"); |
| | | searchOperation = getRootConnection().processSearch(request2); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | newInternalSearchOperation(LDAPFilter.decode("(|(objectclass=ldapsubentry)(objectclass=top))")); |
| | | searchOperation.run(); |
| | | SearchRequest request = |
| | | newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(|(objectclass=ldapsubentry)(objectclass=top))"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 5); |
| | |
| | | |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("ou=nonexistent,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.objectClassPresent(), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | |
| | | SearchRequest request = newSearchRequest(DN.valueOf("ou=nonexistent,o=test"), SearchScope.WHOLE_SUBTREE); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT); |
| | | assertNotNull(searchOperation.getMatchedDN()); |
| | | } |
| | |
| | | |
| | | assertEquals(err,0); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.SINGLE_LEVEL, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(objectclass=organizationalUnit)"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = |
| | | newSearchRequest("dc=example,dc=com", SearchScope.SINGLE_LEVEL, "(objectclass=organizationalUnit)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getSearchEntries().size(),3); |
| | | //restore the allid threshold. |
| | |
| | | */ |
| | | package org.opends.server.protocols.internal; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashSet; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchResultEntry; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testConstructor1WithoutListener() |
| | | throws Exception |
| | | @Test |
| | | public void testConstructor1WithoutListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testConstructor1WithListener() |
| | | throws Exception |
| | | @Test |
| | | public void testConstructor1WithListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), new ArrayList<Control>(), |
| | | ByteString.empty(), SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, |
| | | false, LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener()); |
| | | } |
| | | |
| | | |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetSearchEntriesAndReferences() throws Exception |
| | | { |
| | | SearchRequest request = Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | |
| | | @Test() |
| | | public void testAddSearchEntryWithoutListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry("dn: ", |
| | | "objectClass: top", |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddSearchEntryWithListener() |
| | | throws Exception |
| | | @Test |
| | | public void testAddSearchEntryWithListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener()); |
| | | |
| | | Entry e = TestCaseUtils.makeEntry("dn: ", |
| | | "objectClass: top", |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the <CODE>addSearchReference</CODE> method without a search listener. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddSearchReferenceWithoutListener() |
| | | throws Exception |
| | | @Test |
| | | public void testAddSearchReferenceWithoutListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), null); |
| | | new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request); |
| | | |
| | | SearchResultReference reference = |
| | | new SearchResultReference("ldap://server.example.com:389/"); |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testAddSearchReferenceWithListener() |
| | | throws Exception |
| | | @Test |
| | | public void testAddSearchReferenceWithListener() throws Exception |
| | | { |
| | | InternalClientConnection conn = getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation(conn, nextOperationID(), |
| | | nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.empty(), |
| | | SearchScope.BASE_OBJECT, |
| | | DereferenceAliasesPolicy.NEVER, 0, 0, false, |
| | | LDAPFilter.objectClassPresent(), |
| | | new LinkedHashSet<String>(), |
| | | new TestInternalSearchListener()); |
| | | SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT); |
| | | InternalSearchOperation searchOperation = new InternalSearchOperation( |
| | | getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener()); |
| | | |
| | | SearchResultReference reference = |
| | | new SearchResultReference("ldap://server.example.com:389/"); |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.util.Base64; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | * functionality across different protocol versions of LDAP. |
| | | */ |
| | | public class LDAPBinaryOptionTestCase extends LdapTestCase { |
| | | // Exported LDIF file. |
| | | private File ldif = null; |
| | | //LDIFExportConfig used for exporting entries. |
| | | private LDIFExportConfig exportConfig = null; |
| | | //LDIFImportConfig used for importing entries. |
| | | private LDIFImportConfig importConfig = null; |
| | | //Test Backend. |
| | | private Backend backend = null; |
| | | /** Exported LDIF file. */ |
| | | private File ldif; |
| | | /** LDIFExportConfig used for exporting entries. */ |
| | | private LDIFExportConfig exportConfig; |
| | | /** LDIFImportConfig used for importing entries. */ |
| | | private LDIFImportConfig importConfig; |
| | | /** Test Backend. */ |
| | | private Backend<?> backend; |
| | | |
| | | //Constant value of userCertificate attribute. |
| | | /** Constant value of userCertificate attribute. */ |
| | | private static final String CERT= |
| | | "MIIB5TCCAU6gAwIBAgIERloIajANBgkqhkiG9" + |
| | | "w0BAQUFADA3MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRXhhbXBs" + |
| | |
| | | "LDAPBinaryOptionTestCase.binaryAttributeAddV3"}) |
| | | public void binaryAttributeSearchV3() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(uid=user.1)"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "(uid=user.1)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | Attribute a = attrs.get(0); |
| | | assertNotNull(a); |
| | | assertTrue(a.getOptions().contains("binary")); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Test to verify a SEARCH using the ;binary transfer option using a V3 |
| | |
| | | "LDAPBinaryOptionTestCase.binaryAttributeAddV3"}) |
| | | public void invalidBinaryAttributeSearchV3() throws Exception |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | LinkedHashSet<String> attrs = new LinkedHashSet<String>(); |
| | | attrs.add("cn;binary"); |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(uid=user.1)"), |
| | | attrs, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "(uid=user.1)") |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE) |
| | | .addAttribute("cn;binary"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | | assertNotNull(e); |
| | | List<Attribute> list = e.getAttributes(); |
| | | assertEquals(list.size(), 0); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | for(LDAPAttribute a:searchResultEntry.getAttributes()) |
| | | { |
| | | //Shouldn't be userCertificate;binary. |
| | | if(a.getAttributeType().equalsIgnoreCase("userCertificate")) |
| | | certWithNoOption=true; |
| | | else if(a.getAttributeType().equalsIgnoreCase("sn")) |
| | | if ("userCertificate".equalsIgnoreCase(a.getAttributeType())) |
| | | { |
| | | List<ByteString> lVal = a.getValues(); |
| | | for(ByteString v:lVal) |
| | | certWithNoOption=true; |
| | | } |
| | | else if ("sn".equalsIgnoreCase(a.getAttributeType())) |
| | | { |
| | | for (ByteString v : a.getValues()) |
| | | { |
| | | String val = v.toString(); |
| | | if(val.equals("sn#1") || val.equals("sn#2") |
| | |
| | | else //All the values should match. |
| | | snWithMultiVal = false; |
| | | } |
| | | |
| | | } |
| | | } |
| | | assertTrue(snWithMultiVal && certWithNoOption); |
| | |
| | | //modifies the binary option from the ldif and re-imports it.A re-export of |
| | | //the last import should have the binary option even though it wasn't |
| | | //there in the imported ldif. |
| | | assert(ldif.exists()); |
| | | assertTrue(ldif.exists()); |
| | | importLDIF(); |
| | | assertTrue(containsBinary()); |
| | | //Remove the binary option and re-import it. |
| | |
| | | if(line.startsWith(userCert)) |
| | | { |
| | | builder.append("userCertificate:"); |
| | | builder.append(line.substring(userCert.length()+1, line.length())); |
| | | builder.append(line, userCert.length()+1, line.length()); |
| | | } |
| | | else |
| | | { |
| | | builder.append(line); |
| | | } |
| | | builder.append("\n"); |
| | | } |
| | | buf.close(); |
| | |
| | | while((line=buf.readLine())!=null) |
| | | { |
| | | if(line.startsWith("userCertificate;binary")) |
| | | { |
| | | found = true; |
| | | } |
| | | } |
| | | buf.close(); |
| | | return found; |
| | |
| | | { |
| | | //Initialize necessary instance variables. |
| | | if(ldif==null) |
| | | { |
| | | ldif = File.createTempFile("LDAPBinaryOptionTestCase", ".ldif"); |
| | | } |
| | | exportConfig = new LDIFExportConfig(ldif.getAbsolutePath(), |
| | | ExistingFileBehavior.OVERWRITE); |
| | | backend = DirectoryServer.getBackend("test"); |
| | |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.i18n.LocalizableMessageBuilder; |
| | | import java.util.ArrayList; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.types.Control; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testXAPPROXExtension() |
| | | throws Exception |
| | | @Test |
| | | public void testXAPPROXExtension() throws Exception |
| | | { |
| | | // Create and register the approximate matching rule for testing purposes. |
| | | EqualLengthApproximateMatchingRule testApproxRule = |
| | |
| | | * |
| | | * @throws Exception In case of an error. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testMixedEqualityAndSubstringMatchingRules() throws Exception |
| | | { |
| | | //Add an attribute with directory string syntax. |
| | |
| | | "add: objectclasses", |
| | | "objectClasses: ( gvRightsTest-oid NAME 'gvRightsTest' DESC 'Test' SUP top AUXILIARY " + |
| | | "MUST ( objectClass $ gvRights ) )"); |
| | | assertTrue(resultCode == 0); |
| | | assertEquals(resultCode, 0); |
| | | TestCaseUtils.initializeTestBackend(true); |
| | | //add the test entry. |
| | | TestCaseUtils.addEntry( |
| | | "dn: cn=gvrightstest,o=test", |
| | | "objectclass: person", |
| | | "objectclass: gvRightsTest", |
| | | "cn: gvrightstest", |
| | | "sn: test", |
| | | "gvRights: gvApplId=test2,ou=Applications,dc=bla$test2-T"); |
| | | "dn: cn=gvrightstest,o=test", |
| | | "objectclass: person", |
| | | "objectclass: gvRightsTest", |
| | | "cn: gvrightstest", |
| | | "sn: test", |
| | | "gvRights: gvApplId=test2,ou=Applications,dc=bla$test2-T"); |
| | | |
| | | //Search for the entry using substring matching rule filter. |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | ByteString.valueOf("cn=gvrightstest,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("(&(gvrights=*ApplId=test2,ou=*)" + |
| | | "(gvrights=*test2,ou=A*))"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = "(&(gvrights=*ApplId=test2,ou=*)" + "(gvrights=*test2,ou=A*))"; |
| | | SearchRequest request = newSearchRequest("cn=gvrightstest,o=test", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | assertEquals(searchOperation.getEntriesSent(), 1); |
| | | } |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.controls.ServerSideSortRequestControl; |
| | | import org.opends.server.controls.VLVRequestControl; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DN; |
| | |
| | | public void searchCollationEqualityUsingOID() throws Exception |
| | | { |
| | | //Search the collation rule with OID of en and no suffix in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("cn:1.3.6.1.4.1.42.2.27.9.4.34.1:=sanchez"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = |
| | | newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "cn:1.3.6.1.4.1.42.2.27.9.4.34.1:=sanchez"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | { |
| | | //Search the collation rule with language tag of en and no suffix |
| | | //in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("cn:en:=sanchez"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "cn:en:=sanchez"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Test to search the collation Less than matching rule using OID and suffix. |
| | | */ |
| | |
| | | public void searchCollationLTUsingOIDSuffix() throws Exception |
| | | { |
| | | //Search the collation rule with OID of es and suffix in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.1:=abc120"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = "departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.1:=abc120"; |
| | | SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | public void searchCollationLTEUsingLanguageSuffix() throws Exception |
| | | { |
| | | //Search the collation rule with tag of fr and suffix in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("carLicense:fr.2:=ebe2"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "carLicense:fr.2:=ebe2"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | public void searchCollationGTUsingLanguage() throws Exception |
| | | { |
| | | //Search the collation rule with tag of fr in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("carLicense:fr.5:=ebe1"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "carLicense:fr.5:=ebe1"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | public void searchCollationGTEUsingLanguage() throws Exception |
| | | { |
| | | //Search the collation rule with tag of es and suffix in the filter. |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("departmentnumber:es.4:=abc111"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = |
| | | newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "departmentnumber:es.4:=abc111"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | *It searches for string quebec against the value of sn which is |
| | | * Qu\u00e9bec. |
| | | */ |
| | | InternalClientConnection conn = getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, nextOperationID(), nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("uid=user,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("sn:en.6:=*u*bec"), |
| | | null, null); |
| | | SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "sn:en.6:=*u*bec") |
| | | .setSizeLimit(Integer.MAX_VALUE) |
| | | .setTimeLimit(Integer.MAX_VALUE); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.AttributeSyntax; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Tests whether an implemented syntax can't be substituted by another. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSubstitutionSyntaxForInvalidSubstitution() throws Exception |
| | | { |
| | | try |
| | |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSubstitutionSyntaxSearch() throws Exception |
| | | { |
| | | try |
| | | { |
| | | addSubtitutionSyntax(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(); |
| | | attrList.add("ldapsyntaxes"); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("cn=schema"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("objectclass=ldapsubentry"), |
| | | attrList, null); |
| | | SearchRequest request = newSearchRequest("cn=schema", SearchScope.WHOLE_SUBTREE, "objectclass=ldapsubentry") |
| | | .addAttribute("ldapsyntaxes"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSubsitutionSyntaxAddValues() throws Exception |
| | | { |
| | | try |
| | |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRegexSyntaxAddValues() throws Exception |
| | | { |
| | | try |
| | |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRegexSyntaxSearch() throws Exception |
| | | { |
| | | try |
| | |
| | | "sn: xyz", |
| | | "test-attr-regex: host:0.0.0"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("cn=test,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("test-attr-regex=host:0.0.0"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = |
| | | newSearchRequest("cn=test,o=test", SearchScope.WHOLE_SUBTREE, "test-attr-regex=host:0.0.0"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | /** |
| | | * Tests whether it is possible to add values after an enum syntax |
| | | * has been added. |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testEnumSyntaxAddValues() throws Exception |
| | | { |
| | | try |
| | |
| | | |
| | | /** |
| | | * Tests the equality-based search using enum syntax. |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testEnumSyntaxEqualitySearch() throws Exception |
| | | { |
| | | try |
| | |
| | | "sn: xyz", |
| | | "test-attr-enum: wednesday"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("cn=test,o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("test-attr-enum=wednesday"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("cn=test,o=test", SearchScope.WHOLE_SUBTREE, "test-attr-enum=wednesday"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | |
| | | /** |
| | | * Tests the ordering-based search using enum syntax. |
| | | * |
| | | * @throws java.lang.Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testEnumSyntaxOrderingSearch() throws Exception |
| | | { |
| | | try |
| | |
| | | "sn: xyz", |
| | | "test-attr-enum: tuesday"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("o=test"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode("test-attr-enum>=tuesday"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "test-attr-enum>=tuesday"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | SearchResultEntry e = entries.get(0); |
| | |
| | | import org.forgerock.opendj.ldap.Assertion; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This Test Class tests various matching rules for their compatibility |
| | | * against RFC 4517,4518 and 3454. |
| | | */ |
| | | public final class StringPrepProfileTestCase |
| | | extends SchemaTestCase |
| | | @SuppressWarnings("javadoc") |
| | | public final class StringPrepProfileTestCase extends SchemaTestCase |
| | | { |
| | | /** |
| | | * Ensures that the Directory Server is running before executing the |
| | |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass() |
| | | public void startServer() |
| | | throws Exception |
| | | @BeforeClass |
| | | public void startServer() throws Exception |
| | | { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | |
| | | //Adds an entry for test. |
| | | /** Adds an entry for test. */ |
| | | private void addEntry() throws Exception |
| | | { |
| | | TestCaseUtils.clearJEBackend(true, "userRoot", "dc=example,dc=com"); |
| | |
| | | * DN and searching for it using the filter containing a combining sequence |
| | | * and acute accent. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testUnicodeSearch() throws Exception |
| | | { |
| | | try |
| | | { |
| | | addEntry(); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | SearchRequest request = |
| | | newSearchRequest("dc= example,dc=com", SearchScope.WHOLE_SUBTREE, "&(cn=Jos\u0065\u0301)(sn=This is a test)"); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc= example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | //The filter uses a combining sequence e and acute accent. |
| | | LDAPFilter.decode("&(cn=Jos\u0065\u0301)(sn=This is a test)"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | //No results expected for jdk 5. |
| | |
| | | } |
| | | |
| | | |
| | | //Generates data for case exact matching rules. |
| | | /** Generates data for case exact matching rules. */ |
| | | @DataProvider(name="exactRuleData") |
| | | private Object[][] createExactRuleData() |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | //Generates data for case ignore matching rules. |
| | | /** Generates data for case ignore matching rules. */ |
| | | @DataProvider(name="caseFoldRuleData") |
| | | private Object[][] createIgnoreRuleData() |
| | | { |
| | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.MatchingRule; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPFilter; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.TimeThread; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.internal.InternalClientConnection.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.schema.GeneralizedTimeSyntax.*; |
| | | import static org.opends.server.schema.SchemaConstants.*; |
| | | import static org.testng.Assert.*; |
| | |
| | | try |
| | | { |
| | | populateEntries(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_LT_OID+":=-60m"), // |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_LT_OID + ":=-60m"; |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | assertTrue(dnFoundInEntryList(entries,user1,user2)); |
| | |
| | | try |
| | | { |
| | | populateEntries(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_LT_OID+":=1d"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_LT_OID + ":=1d"; |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | assertTrue(entries.size() == 4 && dnFoundInEntryList(entries,user1,user2,user3,user5)); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | /** |
| | | * Test to search using the greater-than relative time matching rule for expired events. |
| | | */ |
| | | @Test() |
| | |
| | | try |
| | | { |
| | | populateEntries(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_GT_OID+":=-1h"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_GT_OID + ":=-1h"; |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | Assertions.assertThat(entries).hasSize(3); |
| | |
| | | try |
| | | { |
| | | populateEntries(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_GT_OID+":=0s"), |
| | | null, null); |
| | | |
| | | searchOperation.run(); |
| | | String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_GT_OID + ":=0s"; |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | assertTrue(entries.size()==2 && dnFoundInEntryList(entries,user3,user4)); |
| | |
| | | try |
| | | { |
| | | populateEntries(); |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | String assertion = "01D11M"; |
| | | InternalSearchOperation searchOperation = |
| | | new InternalSearchOperation( |
| | | conn, |
| | | InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | null, |
| | | ByteString.valueOf("dc=example,dc=com"), |
| | | SearchScope.WHOLE_SUBTREE, |
| | | DereferenceAliasesPolicy.NEVER, |
| | | Integer.MAX_VALUE, |
| | | Integer.MAX_VALUE, |
| | | false, |
| | | LDAPFilter.decode(DATE_ATTR+":"+EXT_PARTIAL_DATE_TIME_OID+":="+assertion), |
| | | null,null); |
| | | |
| | | searchOperation.run(); |
| | | String assertion = "01D11M"; |
| | | String filter = DATE_ATTR + ":" + EXT_PARTIAL_DATE_TIME_OID + ":=" + assertion; |
| | | SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter); |
| | | InternalSearchOperation searchOperation = getRootConnection().processSearch(request); |
| | | assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS); |
| | | List<SearchResultEntry> entries = searchOperation.getSearchEntries(); |
| | | assertTrue(entries.size()==1 && dnFoundInEntryList(entries,user6)); |