You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2020/03/20 04:17:10 UTC
[directory-server] branch master updated: Fix for DIRSERVER-2302,
added a test for it
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new b8a5559 Fix for DIRSERVER-2302, added a test for it
b8a5559 is described below
commit b8a5559dd7930e65a6e05484553b00a432a3d930
Author: emmanuel lecharny <em...@busit.com>
AuthorDate: Fri Mar 20 05:17:06 2020 +0100
Fix for DIRSERVER-2302, added a test for it
---
.../normalization/NormalizationInterceptor.java | 15 +-
.../client/api/operations/lookup/LookupTest.java | 184 +++++++++++++++++++++
2 files changed, 196 insertions(+), 3 deletions(-)
diff --git a/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java b/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
index d9fe43c..c276157 100644
--- a/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
+++ b/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
@@ -461,6 +461,8 @@ public class NormalizationInterceptor extends BaseInterceptor
*/
private ExprNode handleNotNode( ExprNode node )
{
+ NotNode newNotNode = new NotNode();
+
for ( ExprNode child : ( ( BranchNode ) node ).getChildren() )
{
ExprNode modifiedNode = removeObjectClass( child );
@@ -476,9 +478,12 @@ public class NormalizationInterceptor extends BaseInterceptor
// Here, we will select everything
return ObjectClassNode.OBJECT_CLASS_NODE;
}
+
+ newNotNode.addNode( modifiedNode );
+
}
- return node;
+ return newNotNode;
}
@@ -487,6 +492,8 @@ public class NormalizationInterceptor extends BaseInterceptor
*/
private ExprNode handleOrNode( ExprNode node )
{
+ OrNode newOrNode = new OrNode();
+
for ( ExprNode child : ( ( BranchNode ) node ).getChildren() )
{
ExprNode modifiedNode = removeObjectClass( child );
@@ -496,14 +503,16 @@ public class NormalizationInterceptor extends BaseInterceptor
// We can return immediately with an ObjectClass node
return ObjectClassNode.OBJECT_CLASS_NODE;
}
+
+ newOrNode.addNode( modifiedNode );
}
- return node;
+ return newOrNode;
}
/**
- * Remove the (ObjectClass=*) node from the filter, if we have one.
+ * Remove the (ObjectClass=*) and ( ObjectClass=top) nodes from the filter, if we have one.
*/
private ExprNode removeObjectClass( ExprNode node )
{
diff --git a/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java
new file mode 100644
index 0000000..bd7c98d
--- /dev/null
+++ b/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/lookup/LookupTest.java
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.shared.client.api.operations.lookup;
+
+
+import static org.junit.Assert.assertTrue;
+
+import org.apache.directory.api.ldap.model.cursor.EntryCursor;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.server.annotations.CreateLdapServer;
+import org.apache.directory.server.annotations.CreateTransport;
+import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.annotations.ContextEntry;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.client.api.LdapApiIntegrationUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+@RunWith(FrameworkRunner.class)
+@CreateDS(
+ name = "AddPerfDS",
+ partitions =
+ {
+ @CreatePartition(
+ name = "isp",
+ suffix = "o=isp",
+ contextEntry = @ContextEntry(
+ entryLdif =
+ "dn: o=isp\n" +
+ "o: isp\n" +
+ "objectClass: top\n" +
+ "objectClass: organization\n\n"),
+ indexes =
+ {
+ @CreateIndex(attribute = "objectClass"),
+ @CreateIndex(attribute = "sn"),
+ @CreateIndex(attribute = "cn"),
+ @CreateIndex(attribute = "displayName")
+ }),
+ @CreatePartition(
+ name = "test",
+ suffix = "dc=test,dc=com",
+ contextEntry = @ContextEntry(
+ entryLdif =
+ "dn: dc=test,dc=com\n" +
+ "dc: test\n" +
+ "objectClass: top\n" +
+ "objectClass: domain\n\n"),
+ indexes =
+ {
+ @CreateIndex(attribute = "objectClass"),
+ @CreateIndex(attribute = "sn"),
+ @CreateIndex(attribute = "cn"),
+ @CreateIndex(attribute = "uniqueMember"),
+ @CreateIndex(attribute = "displayName")
+ })
+
+ },
+ enableChangeLog = true)
+@CreateLdapServer(transports =
+ {
+ @CreateTransport(protocol = "LDAP"),
+ @CreateTransport(protocol = "LDAPS")
+})
+@ApplyLdifs(
+ {
+ // Entry # 1
+ "dn: ou=People,o=isp",
+ "objectClass: organizationalUnit",
+ "objectClass: top",
+ "ou: People",
+
+ "DN: ou=Groups,o=isp",
+ "objectClass: organizationalUnit",
+ "objectClass: top",
+ "ou: Groups",
+
+ "DN: cn=testLDAPGroup,ou=Groups,o=isp",
+ "objectClass: groupOfUniqueNames",
+ "objectClass: top",
+ "cn: testLDAPGroup",
+ "uniqueMember: uid=admin,ou=system",
+ "uniqueMember: uid=pullFromLDAP,ou=People,o=isp",
+ "owner: uid=pullFromLDAP,ou=People,o=isp",
+
+ "dn: uid=pullFromLDAP,ou=People,o=isp",
+ "objectClass: organizationalPerson",
+ "objectClass: person",
+ "objectClass: inetOrgPerson",
+ "objectClass: top",
+ "cn: pullFromLDAP",
+ "description: Active",
+ "mail: pullFromLDAP@syncope.apache.org",
+ "sn: Surname",
+ "uid: pullFromLDAP",
+ "userpassword:: cGFzc3dvcmQxMjM=",
+ "givenname: pullFromLDAP",
+ "title: odd",
+ "registeredAddress: 5BAA61E4C9B93F3F0682250B6CF8331B7EE68FD8",
+ "jpegPhoto:: /9j/4AAQSkZJRgABAQEBKwErAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoH",
+ " BwYIDAoMDAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFBQk",
+ " UDQsNFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBT/wg",
+ " ARCAAEAAQDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAACP/EABQBAQAAAAAAAAAAAAAAA",
+ " AAAAAD/2gAMAwEAAhADEAAAAUuf/8QAFhABAQEAAAAAAAAAAAAAAAAAAwAS/9oACAEBAAEFAiLV",
+ " /8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPwF//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/",
+ " aAAgBAgEBPwF//8QAGhAAAQUBAAAAAAAAAAAAAAAAAgABESEiQf/aAAgBAQAGPwI9k2orq//EAB",
+ " kQAAMAAwAAAAAAAAAAAAAAAAERIQBBYf/aAAgBAQABPyF20CYlpT3P/9oADAMBAAIAAwAAABCf/",
+ " 8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAgBAwEBPxB//8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/a",
+ " AAgBAgEBPxB//8QAGhABAAIDAQAAAAAAAAAAAAAAAREhAEFRYf/aAAgBAQABPxCUKGDcAUFrvhoz/9k="
+ }
+ )
+/**
+ * Test some Add operations using an index
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LookupTest extends AbstractLdapTestUnit
+{
+ private LdapNetworkConnection connection;
+
+
+ @Before
+ public void setup() throws Exception
+ {
+ connection = ( LdapNetworkConnection ) LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );
+
+ // Restart the service so that the index is created
+ getService().shutdown();
+ getService().startup();
+ }
+
+
+ @After
+ public void shutdown() throws Exception
+ {
+ LdapApiIntegrationUtils.releasePooledAdminConnection( connection, getLdapServer() );
+ }
+
+
+ @Test
+ public void testLookup() throws Exception
+ {
+ try ( EntryCursor cursor = connection.search(
+ "ou=groups,o=isp",
+ "(&(objectClass=top)(cn=testLDAPGroup))", SearchScope.ONELEVEL, "*" ) )
+ {
+ assertTrue( cursor.next() );
+
+ Entry result = cursor.get();
+
+ assertTrue( result.contains( "cn", "testLDAPGroup" ) );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+}