Tests cleanup
CryptoManagerTestCase.java:
Replaced use of reflection with use of direct method call.
Removed useless parentheses.
ExtensionTestUtils.java: ADDED
Factorizes common code among Extensions tests cases.
EntryDNVirtualAttributeProviderTestCase.java, EntryUUIDVirtualAttributeProviderTestCase.java, GoverningStructureRuleVirtualAttributeProviderTestCase.java, HasSubordinatesVirtualAttributeProviderTestCase.java, NumSubordinatesVirtualAttributeProviderTestCase.java, StructuralObjectClassVirtualAttributeProviderTestCase.java, SubschemaSubentryVirtualAttributeProviderTestCase.java:
Moved common code from 6 tests methods to ExtensionTestUtils + made tests delegate to the ExtensionTestUtils static methods.
1 files added
8 files modified
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.crypto; |
| | | |
| | | import static org.testng.Assert.assertEquals; |
| | | import static org.testng.Assert.assertNotNull; |
| | | import static org.testng.Assert.assertTrue; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.messages.Message; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.List; |
| | | import java.util.LinkedList; |
| | | import java.security.MessageDigest; |
| | | import java.util.Arrays; |
| | | import java.util.LinkedHashSet; |
| | | import java.lang.reflect.Method; |
| | | import java.security.MessageDigest; |
| | | |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | import org.testng.annotations.DataProvider; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | |
| | | import javax.crypto.Mac; |
| | | import javax.naming.directory.*; |
| | | import javax.naming.ldap.LdapName; |
| | | import javax.naming.directory.SearchControls; |
| | | import javax.naming.directory.SearchResult; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.naming.ldap.LdapName; |
| | | |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.messages.Message; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.config.ConfigConstants; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.opends.server.util.TimeThread; |
| | | import org.testng.annotations.AfterClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | This class tests the CryptoManager. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class CryptoManagerTestCase extends CryptoTestCase { |
| | | /** |
| | | Setup.. |
| | | @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | |
| | | @BeforeClass() |
| | | public void setUp() |
| | | throws Exception { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | | |
| | | /** |
| | | Cleanup. |
| | | @throws Exception If an exceptional condition arises. |
| | | */ |
| | | @AfterClass() |
| | | public void CleanUp() throws Exception { |
| | | // Removes at least secret keys added in this test case. |
| | |
| | | assertTrue(StaticUtils.bytesToHexNoSpace( |
| | | md.digest(ldapCert)).equals(cm.getInstanceKeyID())); |
| | | |
| | | // Call twice to ensure idempotent. |
| | | // Call twice to ensure idempotent. |
| | | CryptoManagerImpl.publishInstanceKeyEntryInADS(); |
| | | CryptoManagerImpl.publishInstanceKeyEntryInADS(); |
| | | } |
| | |
| | | ? cm.encrypt(secretMessage.getBytes()) // default |
| | | : cm.encrypt(cp.getTransformation(), cp.getKeyLength(), |
| | | secretMessage.getBytes()); |
| | | assertEquals(-1, (new String(cipherText)).indexOf(secretMessage)); |
| | | assertEquals(-1, new String(cipherText).indexOf(secretMessage)); |
| | | |
| | | final byte[] plainText = cm.decrypt(cipherText); |
| | | assertEquals((new String(plainText)), secretMessage); |
| | | assertEquals(new String(plainText), secretMessage); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | // test cycle |
| | | final byte[] plainText = cm.decrypt(cipherText2); |
| | | assertEquals((new String(plainText)), secretMessage); |
| | | assertEquals(new String(plainText), secretMessage); |
| | | |
| | | // test for identical keys |
| | | try { |
| | | Method m = Arrays.class.getMethod("copyOfRange", (new byte[16]).getClass(), |
| | | Integer.TYPE, Integer.TYPE); |
| | | final byte[] keyID = (byte[])m.invoke(null, cipherText, 1, 16); |
| | | final byte[] keyID2 = (byte[])m.invoke(null, cipherText2, 1, 16); |
| | | assertEquals(keyID, keyID2); |
| | | } |
| | | catch (NoSuchMethodException ex) { |
| | | // skip this test - requires at least Java 6 |
| | | } |
| | | final byte[] keyID = Arrays.copyOfRange(cipherText, 1, 16); |
| | | final byte[] keyID2 = Arrays.copyOfRange(cipherText2, 1, 16); |
| | | assertTrue(Arrays.equals(keyID, keyID2)); |
| | | |
| | | // test for distinct ciphertext |
| | | assertTrue(! Arrays.equals(cipherText, cipherText2)); |
| | |
| | | DirectoryServer.getEnvironmentConfig()); |
| | | |
| | | byte[] plainText = cm.decrypt(cipherText); |
| | | assertEquals((new String(plainText)), secretMessage); |
| | | assertEquals(new String(plainText), secretMessage); |
| | | plainText = cm.decrypt(cipherText2); |
| | | assertEquals((new String(plainText)), secretMessage); |
| | | assertEquals(new String(plainText), secretMessage); |
| | | } |
| | | |
| | | |
| | |
| | | //Wait so the above asynchronous modification can be applied. The crypto |
| | | //manager's cipherKeyEntryCache needs to be updated before the encrypt() |
| | | //method is called below. |
| | | Thread.sleep(1000); |
| | | Thread.sleep(1000); |
| | | // Use the transformation and key length again. A new cipher key |
| | | // should be produced. |
| | | final byte[] cipherText2 = cm.encrypt(cipherTransformationName, |
| | |
| | | // 2. Confirm ciphertext produced using the compromised key can still be |
| | | // decrypted. |
| | | final byte[] plainText = cm.decrypt(cipherText); |
| | | assertEquals((new String(plainText)), secretMessage); |
| | | assertEquals(new String(plainText), secretMessage); |
| | | |
| | | // 3. Delete the compromised entry(ies) and ensure ciphertext produced |
| | | // using a compromised key can no longer be decrypted. |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.workflowelement.localbackend.LocalBackendSearchOperation; |
| | | |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchEntryDNAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entrydn"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "entrydn", entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludeEntryDNAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryDNType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, entryDNType); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | |
| | | import static org.testng.Assert.*; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, entryUUIDType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, entryUUIDType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, entryUUIDType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, entryUUIDType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchEntryUUIDAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("entryuuid"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "entryuuid", entryUUIDType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludeEntryUUIDAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(entryUUIDType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, entryUUIDType); |
| | | } |
| | | |
| | | |
| New file |
| | |
| | | /* |
| | | * CDDL HEADER START |
| | | * |
| | | * The contents of this file are subject to the terms of the |
| | | * Common Development and Distribution License, Version 1.0 only |
| | | * (the "License"). You may not use this file except in compliance |
| | | * with the License. |
| | | * |
| | | * You can obtain a copy of the license at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE |
| | | * or https://OpenDS.dev.java.net/OpenDS.LICENSE. |
| | | * See the License for the specific language governing permissions |
| | | * and limitations under the License. |
| | | * |
| | | * When distributing Covered Code, include this CDDL HEADER in each |
| | | * file and include the License file at |
| | | * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, |
| | | * add the following below this CDDL HEADER, with the fields enclosed |
| | | * by brackets "[]" replaced with your own identifying information: |
| | | * Portions Copyright [yyyy] [name of copyright owner] |
| | | * |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DereferencePolicy; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchScope; |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | | /** |
| | | * Utility class providing common code for extensions tests. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | class ExtensionTestUtils |
| | | { |
| | | |
| | | public static void testSearchEmptyAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | public static void testSearchNoAttrs(DN entryDN, AttributeType attributeType) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, filter, |
| | | attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | public static void testSearchAllUserAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, filter, |
| | | attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | public static void testSearchAllOperationalAttrs(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, filter, |
| | | attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | public static void testSearchAttr(DN entryDN, String attrName, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(attrName); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, filter, |
| | | attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | public static void testSearchExcludeAttr(DN entryDN, |
| | | AttributeType attributeType) throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, filter, |
| | | attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(attributeType)); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchGoverningStructureRulesAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("governingStructureRule"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "governingStructureRule", governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludeGovStructRuleAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(governingStructureRuleType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, governingStructureRuleType); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchhasSubordinatesAttr(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("hasSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "hasSubordinates", hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludehasSubordinatesAttr(DN entryDN, boolean hasSubs) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(hasSubordinatesType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, hasSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchnumSubordinatesAttr(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("numSubordinates"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "numSubordinates", numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludenumSubordinatesAttr(DN entryDN, int count) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(numSubordinatesType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, numSubordinatesType); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchStructuralOCAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("structuralobjectclass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "structuralobjectclass", structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludeStructuralOCAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(structuralObjectClassType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, structuralObjectClassType); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeValue; |
| | |
| | | public void testSearchEmptyAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, filter); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchEmptyAttrs(entryDN, subschemaSubentryType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchNoAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add(SchemaConstants.NO_ATTRIBUTES); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchNoAttrs(entryDN, subschemaSubentryType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllUserAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("*"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchAllUserAttrs(entryDN, subschemaSubentryType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchAllOperationalAttrs(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("+"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchAllOperationalAttrs(entryDN, subschemaSubentryType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchSubschemaSubentryAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("subschemasubentry"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertTrue(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchAttr(entryDN, "subschemasubentry", subschemaSubentryType); |
| | | } |
| | | |
| | | |
| | |
| | | public void testSearchExcludeSubschemaSubentryAttr(DN entryDN) |
| | | throws Exception |
| | | { |
| | | SearchFilter filter = |
| | | SearchFilter.createFilterFromString("(objectClass=*)"); |
| | | LinkedHashSet<String> attrList = new LinkedHashSet<String>(1); |
| | | attrList.add("objectClass"); |
| | | |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | InternalSearchOperation searchOperation = |
| | | conn.processSearch(entryDN, SearchScope.BASE_OBJECT, |
| | | DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, |
| | | filter, attrList); |
| | | assertEquals(searchOperation.getSearchEntries().size(), 1); |
| | | |
| | | Entry e = searchOperation.getSearchEntries().get(0); |
| | | assertNotNull(e); |
| | | assertFalse(e.hasAttribute(subschemaSubentryType)); |
| | | ExtensionTestUtils.testSearchExcludeAttr(entryDN, subschemaSubentryType); |
| | | } |
| | | |
| | | |