Add support for SearchScope.SUBORDINATES to MemoryBackend
| | |
| | | sendEntry(attributeFilter, resultHandler, baseEntry); |
| | | } |
| | | resultHandler.handleResult(newResult(ResultCode.SUCCESS)); |
| | | } else if (scope.equals(SearchScope.SINGLE_LEVEL) || scope.equals(SearchScope.WHOLE_SUBTREE)) { |
| | | } else if (scope.equals(SearchScope.SINGLE_LEVEL) || scope.equals(SearchScope.SUBORDINATES) |
| | | || scope.equals(SearchScope.WHOLE_SUBTREE)) { |
| | | searchWithSubordinates(requestContext, resultHandler, dn, matcher, attributeFilter, |
| | | request.getSizeLimit(), scope, request.getControl( |
| | | SimplePagedResultsControl.DECODER, new DecodeOptions())); |
| | |
| | | int position = 0; |
| | | for (final Entry entry : subtree.values()) { |
| | | requestContext.checkIfCancelled(false); |
| | | if (scope.equals(SearchScope.WHOLE_SUBTREE) || entry.getName().isChildOf(dn)) { |
| | | if (scope.equals(SearchScope.WHOLE_SUBTREE) || entry.getName().isChildOf(dn) |
| | | || (scope.equals(SearchScope.SUBORDINATES) && !entry.getName().equals(dn))) { |
| | | if (matcher.matches(entry).toBoolean()) { |
| | | /* |
| | | * This entry is going to be returned to the client so it |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchSubordinatesReturnsAllEntries() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | connection.search(Requests.newSearchRequest("dc=com", SearchScope.SUBORDINATES, "(objectclass=*)"), entries); |
| | | assertThat(entries).hasSize(numberOfEntriesInBackend - 1); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchSubordinatesEntries() throws Exception { |
| | | int numberOfUsers = 5; |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |
| | | connection.search(Requests.newSearchRequest("ou=People,dc=example,dc=com", SearchScope.SUBORDINATES, |
| | | "(objectclass=*)"), entries); |
| | | assertThat(entries).hasSize(numberOfUsers); |
| | | } |
| | | |
| | | @Test |
| | | public void testSearchSubtreeWithSizeLimit() throws Exception { |
| | | final Connection connection = getConnection(); |
| | | Collection<SearchResultEntry> entries = new ArrayList<SearchResultEntry>(); |