diff options
author | Stefan Seelmann <mail@stefan-seelmann.de> | 2021-04-18 18:06:43 +0300 |
---|---|---|
committer | Stefan Seelmann <mail@stefan-seelmann.de> | 2021-04-18 18:07:14 +0300 |
commit | 025e179dd0a8ab27529ac9b8638699730eef3771 (patch) | |
tree | 6fe8607205b79d3d535682e5ff42c6c32338a3d1 | |
parent | a2ca7a0f13d169754acf86c341d03f24ed63f1cc (diff) |
Migrate apacheds and browser tests
15 files changed, 585 insertions, 487 deletions
diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ComputeDiffTest.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ComputeDiffTest.java index 755a73091..99f032d44 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ComputeDiffTest.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/ComputeDiffTest.java @@ -291,7 +291,6 @@ public class ComputeDiffTest private void assertChangeModify( LdifFile diff, String... lines ) { - // System.out.println( diff.toRawString() ); assertThat( diff.isChangeType(), equalTo( true ) ); assertThat( diff.getContainers(), hasSize( 1 ) ); assertThat( diff.getLastContainer(), instanceOf( LdifChangeModifyRecord.class ) ); diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java index 2b1042fe3..44c86620e 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/core/DirectoryApiConnectionWrapperTest.java @@ -22,6 +22,7 @@ package org.apache.directory.studio.test.integration.core; import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_1_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_2_DN; @@ -403,7 +404,7 @@ public class DirectoryApiConnectionWrapperTest { StudioProgressMonitor monitor = getProgressMonitor(); SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE ); + searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE ); StudioSearchResultEnumeration result = getConnectionWrapper( monitor, ldapServer ).search( REFERRAL_TO_REFERRALS_DN.getName(), "(objectClass=*)", searchControls, AliasDereferencingMethod.NEVER, ReferralHandlingMethod.FOLLOW, null, monitor, null ); @@ -416,8 +417,8 @@ public class DirectoryApiConnectionWrapperTest if ( ldapServer.getType() != LdapServerType.Fedora389ds ) { // TODO: check why 389ds returns nothing - assertEquals( 11, dns.size() ); - assertThat( dns, hasItems( REFERRALS_DN, USERS_DN, USER1_DN, USER8_DN ) ); + assertEquals( 5, dns.size() ); + assertThat( dns, hasItems( REFERRALS_DN, USERS_DN, USER1_DN, MISC_DN ) ); } } @@ -460,9 +461,9 @@ public class DirectoryApiConnectionWrapperTest assertNotNull( result ); List<Dn> dns = consume( result, sr -> sr.getDn() ); - assertEquals( 7, dns.size() ); + assertEquals( 8, dns.size() ); assertThat( dns, hasItems( REFERRALS_DN, USER1_DN, USERS_DN, REFERRAL_TO_USERS_DN, REFERRAL_LOOP_1_DN, - REFERRAL_LOOP_2_DN ) ); + REFERRAL_LOOP_2_DN, MISC_DN ) ); } @@ -493,7 +494,7 @@ public class DirectoryApiConnectionWrapperTest { StudioProgressMonitor monitor = getProgressMonitor(); SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE ); + searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE ); StudioSearchResultEnumeration result = getConnectionWrapper( monitor, ldapServer ).search( REFERRALS_DN.getName(), "(objectClass=*)", searchControls, AliasDereferencingMethod.NEVER, ReferralHandlingMethod.FOLLOW, null, monitor, null ); @@ -503,12 +504,8 @@ public class DirectoryApiConnectionWrapperTest assertNotNull( result ); List<Dn> dns = consume( result, sr -> sr.getDn() ); - if ( ldapServer.getType() != LdapServerType.Fedora389ds ) - { - // TODO: check why 389ds missed uid=user.1 - assertEquals( 12, dns.size() ); - assertThat( dns, hasItems( REFERRALS_DN, REFERRALS_DN, USERS_DN, USER1_DN, USER8_DN ) ); - } + assertEquals( 5, dns.size() ); + assertThat( dns, hasItems( REFERRALS_DN, USERS_DN, USER1_DN, MISC_DN ) ); } diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java index 7873caf23..065ff6148 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/ApacheDirectoryServer.java @@ -69,6 +69,7 @@ public class ApacheDirectoryServer extends TestLdapServer new File( service.getInstanceLayout().getPartitionsDirectory(), "example.org" ) ); partition.initialize(); service.addPartition( partition ); + service.getSchemaManager().enable( "nis", "krb5kdc" ); server = new LdapServer(); server.setDirectoryService( service ); diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/LdapServersArgumentsProvider.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/LdapServersArgumentsProvider.java index b5ff2dd40..1cda1759b 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/LdapServersArgumentsProvider.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/LdapServersArgumentsProvider.java @@ -46,11 +46,18 @@ public class LdapServersArgumentsProvider implements ArgumentsProvider { if ( types.contains( type ) ) { - if ( type.getLdapServer().isAvailable() ) + try { - type.getLdapServer().prepare(); + if ( type.getLdapServer().isAvailable() ) + { + type.getLdapServer().prepare(); + } + arguments.add( Arguments.of( type.getLdapServer() ) ); + } + catch ( Exception e ) + { + throw new RuntimeException( "Prepare failed for LDAP server type " + type, e ); } - arguments.add( Arguments.of( type.getLdapServer() ) ); } } diff --git a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java index 617871306..da801f195 100644 --- a/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java +++ b/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestFixture.java @@ -34,6 +34,7 @@ import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueEx import org.apache.directory.api.ldap.model.exception.LdapInvalidDnException; import org.apache.directory.api.ldap.model.ldif.LdifEntry; import org.apache.directory.api.ldap.model.ldif.LdifReader; +import org.apache.directory.api.ldap.model.message.AliasDerefMode; import org.apache.directory.api.ldap.model.message.Control; import org.apache.directory.api.ldap.model.message.DeleteRequest; import org.apache.directory.api.ldap.model.message.DeleteRequestImpl; @@ -102,22 +103,21 @@ public class TestFixture public static final Dn MISC1_DN = dn( "ou=misc.1", MISC_DN ); public static final Dn MISC11_DN = dn( "ou=misc.1.1", MISC1_DN ); public static final Dn MISC111_DN = dn( "ou=misc.1.1.1", MISC11_DN ); - public static final Dn MISC2_DN = dn( "ou=misc.2", MISC_DN ); - public static final Dn MISC21_DN = dn( "ou=misc.2.1", MISC2_DN ); - public static final Dn MISC211_DN = dn( "ou=misc.2.1.1", MISC21_DN ); - public static final Dn MISC212_DN = dn( "ou=misc.2.1.2", MISC21_DN ); - public static final Dn MISC22_DN = dn( "ou=misc.2.2", MISC2_DN ); - public static final Dn MISC221_DN = dn( "ou=misc.2.2.1", MISC22_DN ); - public static final Dn MISC222_DN = dn( "ou=misc.2.2.2", MISC22_DN ); public static final Dn MULTI_VALUED_RDN_DN = dn( "cn=Barbara Jensen+uid=bjensen", MISC_DN ); - public static final Dn LEADING_SHARP_DN_BACKSLASH_PREFIXED = dn( "cn=\\#123456", MISC_DN ); - public static final Dn LEADING_SHARP_DN_HEX_ESCAPED = dn( "cn=\\23123456", MISC_DN ); - public static final Dn RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED = dn( "cn=\\#\\\\\\+\\, \\\"öé\\\"", + public static final Dn DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED = dn( "cn=\\#123456", MISC_DN ); + public static final Dn DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED = dn( "cn=\\23123456", MISC_DN ); + public static final Dn DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED = dn( "cn=\\\"\\+\\,\\;\\<\\>\\\\", MISC_DN ); + public static final Dn DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED = dn( "cn=\\22\\2B\\2C\\3B\\3C\\3E\\5C", MISC_DN ); - public static final Dn RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED = dn( "cn=\\23\\5C\\2B\\2C \\22öé\\22", MISC_DN ); + public static final Dn DN_WITH_TRAILING_EQUALS_CHARACTER = dn( "cn=trailing=", MISC_DN ); + public static final Dn DN_WITH_TRAILING_EQUALS_CHARACTER_HEX_PAIR_ESCAPED = dn( "cn=trailing\\3D", MISC_DN ); + public static final Dn DN_WITH_IP_HOST_NUMBER = dn( "cn=loopback+ipHostNumber=127.0.0.1", MISC_DN ); + public static final Dn ALIAS_DN = dn( "cn=alias", MISC_DN ); public static final Dn USERS_DN = dn( "ou=users", CONTEXT_DN ); public static final Dn USER1_DN = dn( "uid=user.1", USERS_DN ); + public static final Dn USER2_DN = dn( "uid=user.2", USERS_DN ); + public static final Dn USER3_DN = dn( "uid=user.3", USERS_DN ); public static final Dn USER8_DN = dn( "uid=user.8", USERS_DN ); public static final Dn REFERRALS_DN = dn( "ou=referrals", CONTEXT_DN ); @@ -127,6 +127,7 @@ public class TestFixture public static final Dn REFERRAL_TO_REFERRALS_DN = dn( "cn=referral-to-referrals", REFERRALS_DN ); public static final Dn REFERRAL_LOOP_1_DN = dn( "cn=referral-loop-1", REFERRALS_DN ); public static final Dn REFERRAL_LOOP_2_DN = dn( "cn=referral-loop-2", REFERRALS_DN ); + public static final Dn REFERRAL_TO_MISC_DN = dn( "cn=referral-to-misc", REFERRALS_DN ); /** * Creates the context entry "dc=example,dc=org" if it doesn't exist yet. @@ -190,9 +191,9 @@ public class TestFixture // delete ou=users deleteTree( connection, USERS_DN, Optional.empty() ); // delete ou=misc + deleteTree( connection, MISC_DN, Optional.of( Controls.SUBENTRIES_CONTROL ) ); deleteTree( connection, MISC_DN, Optional.empty() ); } ); - } @@ -203,6 +204,7 @@ public class TestFixture searchRequest.setBase( baseDn ); searchRequest.setFilter( OBJECT_CLASS_ALL_FILTER ); searchRequest.setScope( SearchScope.SUBTREE ); + searchRequest.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES ); control.ifPresent( c -> searchRequest.addControl( c ) ); try ( SearchCursor searchCursor = connection.search( searchRequest ); diff --git a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif index b0296b07f..79d3847b5 100644 --- a/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif +++ b/tests/test.integration.core/src/main/resources/org/apache/directory/studio/test/integration/junit5/TestFixture.ldif @@ -25,8 +25,9 @@ dn: ou=misc,dc=example,dc=org objectClass: top objectClass: organizationalUnit -ou: users +ou: misc +# Multi-valued RDN dn: cn=Barbara Jensen+uid=bjensen,ou=misc,dc=example,dc=org objectClass: inetOrgPerson objectClass: organizationalPerson @@ -37,16 +38,16 @@ sn: Jensen givenName: Barbara uid: bjensen -# cn=\#\\\+\, \"öé\",ou=misc,dc=example,dc=org -dn:: Y249XCNcXFwrXCwgXCLDtsOpXCIsb3U9bWlzYyxkYz1leGFtcGxlLGRjPW9yZw== +# DN with escaped characters: '"', '+', ',', ';', '<', '>', or '\' +dn: cn=\"\+\,\;\<\>\\,ou=misc,dc=example,dc=org objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person objectClass: top -cn:: I1wrLCAiw7bDqSI= -sn:: I1wrLCAiw7bDqSI= -givenName:: I1wrLCAiw7bDqSI= +cn: "+,;<>\ +sn: "+,;<>\ +# DN with leading sharp/hash/pound/number sign dn: cn=\#123456,ou=misc,dc=example,dc=org objectClass: inetOrgPerson objectClass: organizationalPerson @@ -57,55 +58,42 @@ sn: #123456 givenName: #123456 uid: #123456 -dn: ou=misc.1,ou=misc,dc=example,dc=org -objectClass: top -objectClass: organizationalUnit -ou: misc.1 - -dn: ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org -objectClass: top -objectClass: organizationalUnit -ou: misc.1.1 - -dn: ou=misc.1.1.1,ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org +# DN with trailing equals character = +dn: cn=trailing=,ou=misc,dc=example,dc=org objectClass: top -objectClass: organizationalUnit -ou: misc.1.1.1 - -dn: ou=misc.2,ou=misc,dc=example,dc=org -objectClass: top -objectClass: organizationalUnit -ou: misc.2 - -dn: ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org -objectClass: top -objectClass: organizationalUnit -ou: misc.2.1 +objectClass: person +cn: trailing= +sn: trailing= -dn: ou=misc.2.1.1,ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org +# Multi-valued RDN with IP address +dn: cn=loopback+ipHostNumber=127.0.0.1,ou=misc,dc=example,dc=org objectClass: top -objectClass: organizationalUnit -ou: misc.2.1.1 +objectClass: device +objectClass: ipHost +cn: loopback +ipHostNumber: 127.0.0.1 -dn: ou=misc.2.1.2,ou=misc.2.1,ou=misc.2,ou=misc,dc=example,dc=org +dn: ou=misc.1,ou=misc,dc=example,dc=org objectClass: top objectClass: organizationalUnit -ou: misc.2.1.2 +ou: misc.1 -dn: ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org +dn: cn=alias,ou=misc,dc=example,dc=org +objectClass: alias objectClass: top -objectClass: organizationalUnit -ou: misc.2.2 +objectClass: extensibleObject +cn: alias +aliasedObjectName: ou=misc,dc=example,dc=org -dn: ou=misc.2.2.1,ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org +dn: ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org objectClass: top objectClass: organizationalUnit -ou: misc.2.2.1 +ou: misc.1.1 -dn: ou=misc.2.2.2,ou=misc.2.2,ou=misc.2,ou=misc,dc=example,dc=org +dn: ou=misc.1.1.1,ou=misc.1.1,ou=misc.1,ou=misc,dc=example,dc=org objectClass: top objectClass: organizationalUnit -ou: misc.2.2.2 +ou: misc.1.1.1 # # ou=users @@ -369,3 +357,11 @@ objectClass: referral objectClass: extensibleObject cn: referral-loop-2 ref: ldap://replace-with-host-port/cn=referral-loop-1,ou=referrals,dc=example,dc=org + +dn: cn=referral-to-misc,ou=referrals,dc=example,dc=org +objectClass: top +objectClass: referral +objectClass: extensibleObject +cn: referral-to-misc +ref: ldap://replace-with-host-port/ou=misc,dc=example,dc=org + diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java index fd3000b53..5efdf1f47 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/AbstractTestBase.java @@ -13,8 +13,11 @@ import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.name.Rdn; import org.apache.directory.studio.test.integration.junit5.SkipTestIfLdapServerIsNotAvailableInterceptor; import org.apache.directory.studio.test.integration.junit5.TestLdapServer; +import org.apache.directory.studio.test.integration.ui.bots.ApacheDSServersViewBot; import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot; import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot; +import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot; +import org.apache.directory.studio.test.integration.ui.bots.SearchLogsViewBot; import org.apache.directory.studio.test.integration.ui.bots.StudioBot; import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions; import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; @@ -33,22 +36,29 @@ public class AbstractTestBase protected StudioBot studioBot; protected ConnectionsViewBot connectionsViewBot; protected BrowserViewBot browserViewBot; + protected SearchLogsViewBot searchLogsViewBot; + protected ModificationLogsViewBot modificationLogsViewBot; + protected ApacheDSServersViewBot serversViewBot; @BeforeEach - void setUp() throws Exception + final void setUpBase() throws Exception { bot = new SWTWorkbenchBot(); studioBot = new StudioBot(); studioBot.resetLdapPerspective(); connectionsViewBot = studioBot.getConnectionView(); browserViewBot = studioBot.getBrowserView(); + searchLogsViewBot = studioBot.getSearchLogsViewBot(); + modificationLogsViewBot = studioBot.getModificationLogsViewBot(); + serversViewBot = studioBot.getApacheDSServersViewBot(); } @AfterEach - void tearDown() throws Exception + final void tearDownBase() throws Exception { connectionsViewBot.deleteTestConnections(); + serversViewBot.deleteTestServers(); Assertions.genericTearDownAssertions(); } @@ -56,12 +66,18 @@ public class AbstractTestBase { "DIT", "Root DSE" }; public static final String[] CONTEXT_PATH = path( ROOT_DSE_PATH, CONTEXT_DN.getName() ); - private static String[] path( String[] parents, String leaf ) + public static String[] path( String[] parents, String leaf ) { return ArrayUtils.addAll( parents, leaf ); } + public static String[] path( Dn dn, String leaf ) + { + return ArrayUtils.addAll( path( dn ), leaf ); + } + + /** * Gets the path to the DN in the LDAP browser tree. * The path starts with "DIT", "Root DSE", and the context entry. diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java index 019199ebf..362ecc33f 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java @@ -34,22 +34,15 @@ import org.apache.directory.studio.connection.core.ConnectionFolderManager; import org.apache.directory.studio.connection.core.ConnectionManager; import org.apache.directory.studio.ldapservers.LdapServersManager; import org.apache.directory.studio.test.integration.ui.bots.ApacheDSConfigurationEditorBot; -import org.apache.directory.studio.test.integration.ui.bots.ApacheDSServersViewBot; import org.apache.directory.studio.test.integration.ui.bots.BotUtils; import org.apache.directory.studio.test.integration.ui.bots.ConnectionFromServerDialogBot; -import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot; import org.apache.directory.studio.test.integration.ui.bots.ConsoleViewBot; import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot; import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot; import org.apache.directory.studio.test.integration.ui.bots.NewApacheDSServerWizardBot; -import org.apache.directory.studio.test.integration.ui.bots.StudioBot; -import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions; -import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** @@ -58,35 +51,17 @@ import org.junit.runner.RunWith; * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> * @version $Rev$, $Date$ */ -@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class) -public class ApacheDSPluginTest +public class ApacheDSPluginTest extends AbstractTestBase { - private StudioBot studioBot; - private ApacheDSServersViewBot serversViewBot; - private ConnectionsViewBot connectionsViewBot; - private ConsoleViewBot consoleViewBot; + protected ConsoleViewBot consoleViewBot; - - @Before - public void setUp() throws Exception + @BeforeEach + void setUp() throws Exception { - studioBot = new StudioBot(); - studioBot.resetLdapPerspective(); - serversViewBot = studioBot.getApacheDSServersViewBot(); - connectionsViewBot = studioBot.getConnectionView(); consoleViewBot = studioBot.getConsoleView(); } - @After - public void tearDown() throws Exception - { - connectionsViewBot.deleteTestConnections(); - serversViewBot.deleteTestServers(); - Assertions.genericTearDownAssertions(); - } - - /** * Run the following tests: * <ul> @@ -417,7 +392,7 @@ public class ApacheDSPluginTest // Repair the server serversViewBot.repairServer( serverName ); - consoleViewBot.waitForConsoleText("Database repaired"); + consoleViewBot.waitForConsoleText( "Database repaired" ); serversViewBot.waitForServerStop( serverName ); // Wait a bit more after repair, another weird race condition... diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java index 3a6c9adb6..0543649ce 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java @@ -21,8 +21,23 @@ package org.apache.directory.studio.test.integration.ui; -import static org.apache.directory.studio.test.integration.ui.Constants.LOCALHOST; -import static org.apache.directory.studio.test.integration.ui.Constants.LOCALHOST_ADDRESS; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.ALIAS_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_IP_HOST_NUMBER; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_TRAILING_EQUALS_CHARACTER; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_TRAILING_EQUALS_CHARACTER_HEX_PAIR_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.MULTI_VALUED_RDN_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USERS_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER2_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER3_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.USERS_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.dn; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -32,12 +47,11 @@ import java.util.concurrent.atomic.AtomicInteger; import org.apache.commons.lang3.StringUtils; import org.apache.directory.api.ldap.model.entry.DefaultEntry; +import org.apache.directory.api.ldap.model.entry.DefaultModification; import org.apache.directory.api.ldap.model.entry.Entry; +import org.apache.directory.api.ldap.model.entry.Modification; +import org.apache.directory.api.ldap.model.entry.ModificationOperation; import org.apache.directory.api.ldap.model.name.Dn; -import org.apache.directory.server.annotations.CreateLdapServer; -import org.apache.directory.server.annotations.CreateTransport; -import org.apache.directory.server.core.annotations.ApplyLdifFiles; -import org.apache.directory.server.core.integ.AbstractLdapTestUnit; import org.apache.directory.studio.connection.core.Connection; import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod; import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod; @@ -49,16 +63,12 @@ import org.apache.directory.studio.ldapbrowser.core.model.impl.Bookmark; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIConstants; import org.apache.directory.studio.ldapbrowser.ui.BrowserUIPlugin; import org.apache.directory.studio.ldapbrowser.ui.editors.entry.EntryEditor; -import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot; -import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot; +import org.apache.directory.studio.test.integration.junit5.LdapServerType; +import org.apache.directory.studio.test.integration.junit5.LdapServersSource; +import org.apache.directory.studio.test.integration.junit5.TestLdapServer; import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot; import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot; -import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot; import org.apache.directory.studio.test.integration.ui.bots.ReferralDialogBot; -import org.apache.directory.studio.test.integration.ui.bots.SearchLogsViewBot; -import org.apache.directory.studio.test.integration.ui.bots.StudioBot; -import org.apache.directory.studio.test.integration.ui.bots.utils.Assertions; -import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener; import org.apache.directory.studio.test.integration.ui.bots.utils.JobWatcher; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable; @@ -66,10 +76,7 @@ import org.eclipse.swtbot.swt.finder.results.VoidResult; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPropertyListener; import org.eclipse.ui.PlatformUI; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.params.ParameterizedTest; /** @@ -78,62 +85,29 @@ import org.junit.runner.RunWith; * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> * @version $Rev$, $Date$ */ -@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class) -@CreateLdapServer(transports = - { @CreateTransport(protocol = "LDAP") }) -@ApplyLdifFiles(clazz = BrowserTest.class, value = "org/apache/directory/studio/test/integration/ui/BrowserTest.ldif") -public class BrowserTest extends AbstractLdapTestUnit +public class BrowserTest extends AbstractTestBase { - private StudioBot studioBot; - private ConnectionsViewBot connectionsViewBot; - private BrowserViewBot browserViewBot; - private SearchLogsViewBot searchLogsViewBot; - private ModificationLogsViewBot modificationLogsViewBot; - - private Connection connection; - - - @Before - public void setUp() throws Exception - { - studioBot = new StudioBot(); - studioBot.resetLdapPerspective(); - connectionsViewBot = studioBot.getConnectionView(); - connection = connectionsViewBot.createTestConnection( "BrowserTest", ldapServer.getPort() ); - browserViewBot = studioBot.getBrowserView(); - searchLogsViewBot = studioBot.getSearchLogsViewBot(); - modificationLogsViewBot = studioBot.getModificationLogsViewBot(); - } - - - @After - public void tearDown() throws Exception - { - connectionsViewBot.deleteTestConnections(); - Assertions.genericTearDownAssertions(); - } - /** * Test for DIRSTUDIO-463. * * When expanding an entry in the browser only one search request * should be send to the server - * - * @throws Exception */ - @Test - public void testOnlyOneSearchRequestWhenExpandingEntry() throws Exception + @ParameterizedTest + @LdapServersSource + public void testOnlyOneSearchRequestWhenExpandingEntry( TestLdapServer server ) throws Exception { - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" ); + connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( CONTEXT_DN ) ); // get number of search requests before expanding the entry String text = searchLogsViewBot.getSearchLogsText(); int countMatchesBefore = StringUtils.countMatches( text, "#!SEARCH REQUEST" ); // expand - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system" ); - browserViewBot.waitForEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.expandEntry( path( CONTEXT_DN ) ); + browserViewBot.waitForEntry( path( USERS_DN ) ); // get number of search requests after expanding the entry text = searchLogsViewBot.getSearchLogsText(); @@ -149,14 +123,14 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-512. * * Verify minimum UI updates when deleting multiple entries. - * - * @throws Exception */ - @Test - public void testDeleteDontUpdateUI() throws Exception + @ParameterizedTest + @LdapServersSource + public void testDeleteDoesNotUpdateUI( TestLdapServer server ) throws Exception { - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( USERS_DN ) ); + browserViewBot.expandEntry( path( USERS_DN ) ); long fireCount0 = EventRegistry.getFireCount(); @@ -171,10 +145,10 @@ public class BrowserTest extends AbstractLdapTestUnit "uid=user.6", "uid=user.7", "uid=user.8" }; - browserViewBot.selectChildrenOfEntry( children, "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectChildrenOfEntry( children, path( USERS_DN ) ); DeleteDialogBot deleteDialog = browserViewBot.openDeleteDialog(); deleteDialog.clickOkButton(); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( USERS_DN ) ); long fireCount1 = EventRegistry.getFireCount(); @@ -189,25 +163,25 @@ public class BrowserTest extends AbstractLdapTestUnit * * When opening a bookmark the entry editor should be opened and the * bookmark entry's attributes should be displayed. - * - * @throws Exception */ - @Test - public void testBookmark() throws Exception + @ParameterizedTest + @LdapServersSource + public void testBookmark( TestLdapServer server ) throws Exception { // create a bookmark + Connection connection = connectionsViewBot.createTestConnection( server ); IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); browserConnection.getBookmarkManager().addBookmark( - new Bookmark( browserConnection, new Dn( "uid=user.1,ou=users,ou=system" ), "Existing Bookmark" ) ); + new Bookmark( browserConnection, USER1_DN, "Existing Bookmark" ) ); // select the bookmark browserViewBot.selectEntry( "Bookmarks", "Existing Bookmark" ); // check that entry editor was opened and attributes are visible - EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" ); + EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() ); String dn = entryEditorBot.getDnText(); - assertEquals( "DN: uid=user.1,ou=users,ou=system", dn ); + assertEquals( "DN: " + USER1_DN.getName(), dn ); List<String> attributeValues = entryEditorBot.getAttributeValues(); assertEquals( 23, attributeValues.size() ); assertTrue( attributeValues.contains( "uid: user.1" ) ); @@ -220,49 +194,54 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-481. * * Check proper operation of refresh action. - * - * @throws Exception */ - @Test - public void testRefreshParent() throws Exception + @ParameterizedTest + @LdapServersSource + public void testRefreshParent( TestLdapServer server ) throws Exception { // check the entry doesn't exist yet - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + connectionsViewBot.createTestConnection( server ); + browserViewBot.expandEntry( path( MISC_DN ) ); + Dn refreshDn = dn( "cn=refresh", MISC_DN ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // add the entry directly in the server - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "cn=refresh,ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "person" ); - entry.add( "cn", "refresh" ); - entry.add( "sn", "refresh" ); - ldapServer.getDirectoryService().getAdminSession().add( entry ); + server.withAdminConnection( conn -> { + Entry entry = new DefaultEntry( conn.getSchemaManager() ); + entry.setDn( refreshDn ); + entry.add( "objectClass", "top", "person" ); + entry.add( "cn", "refresh" ); + entry.add( "sn", "refresh" ); + conn.add( entry ); + } ); // check the entry still isn't visible in the tree - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh parent - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( MISC_DN ) ); browserViewBot.refresh(); // check the entry exists now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); + browserViewBot.selectEntry( path( refreshDn ) ); // delete the entry directly in the server - ldapServer.getDirectoryService().getAdminSession().delete( new Dn( "cn=refresh,ou=users,ou=system" ) ); + server.withAdminConnection( conn -> { + conn.delete( refreshDn ); + } ); - // check the entry still is now visible in the tree - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + // check the entry still is visible in the tree + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh parent - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( MISC_DN ) ); browserViewBot.refresh(); // check the entry doesn't exist now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); } @@ -273,46 +252,53 @@ public class BrowserTest extends AbstractLdapTestUnit * * @throws Exception */ - @Test - public void testRefreshContextEntry() throws Exception + @ParameterizedTest + @LdapServersSource + public void testRefreshContextEntry( TestLdapServer server ) throws Exception { // check the entry doesn't exist yet - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + connectionsViewBot.createTestConnection( server ); + browserViewBot.expandEntry( path( MISC_DN ) ); + Dn refreshDn = dn( "cn=refresh", MISC_DN ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // add the entry directly in the server - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "cn=refresh,ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "person" ); - entry.add( "cn", "refresh" ); - entry.add( "sn", "refresh" ); - ldapServer.getDirectoryService().getAdminSession().add( entry ); + server.withAdminConnection( conn -> { + Entry entry = new DefaultEntry( conn.getSchemaManager() ); + entry.setDn( refreshDn ); + entry.add( "objectClass", "top", "person" ); + entry.add( "cn", "refresh" ); + entry.add( "sn", "refresh" ); + conn.add( entry ); + } ); // check the entry still isn't visible in the tree - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh context entry - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" ); + browserViewBot.selectEntry( path( CONTEXT_DN ) ); browserViewBot.refresh(); // check the entry exists now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); + browserViewBot.selectEntry( path( refreshDn ) ); // delete the entry directly in the server - ldapServer.getDirectoryService().getAdminSession().delete( new Dn( "cn=refresh,ou=users,ou=system" ) ); + server.withAdminConnection( connection -> { + connection.delete( refreshDn ); + } ); - // check the entry still is now visible in the tree - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + // check the entry still is visible in the tree + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh context entry - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" ); + browserViewBot.selectEntry( path( CONTEXT_DN ) ); browserViewBot.refresh(); // check the entry doesn't exist now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); } @@ -320,49 +306,54 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-481. * * Check proper operation of refresh action. - * - * @throws Exception */ - @Test - public void testRefreshRootDSE() throws Exception + @ParameterizedTest + @LdapServersSource + public void testRefreshRootDSE( TestLdapServer server ) throws Exception { // check the entry doesn't exist yet - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + connectionsViewBot.createTestConnection( server ); + browserViewBot.expandEntry( path( MISC_DN ) ); + Dn refreshDn = dn( "cn=refresh", MISC_DN ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // add the entry directly in the server - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "cn=refresh,ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "person" ); - entry.add( "cn", "refresh" ); - entry.add( "sn", "refresh" ); - ldapServer.getDirectoryService().getAdminSession().add( entry ); + server.withAdminConnection( connection -> { + Entry entry = new DefaultEntry( connection.getSchemaManager() ); + entry.setDn( refreshDn ); + entry.add( "objectClass", "top", "person" ); + entry.add( "cn", "refresh" ); + entry.add( "sn", "refresh" ); + connection.add( entry ); + } ); // check the entry still isn't visible in the tree - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh Root DSE - browserViewBot.selectEntry( "DIT", "Root DSE" ); + browserViewBot.selectEntry( ROOT_DSE_PATH ); browserViewBot.refresh(); // check the entry exists now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); + browserViewBot.selectEntry( path( refreshDn ) ); // delete the entry directly in the server - ldapServer.getDirectoryService().getAdminSession().delete( new Dn( "cn=refresh,ou=users,ou=system" ) ); + server.withAdminConnection( connection -> { + connection.delete( refreshDn ); + } ); // check the entry still is now visible in the tree - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + assertTrue( browserViewBot.existsEntry( path( refreshDn ) ) ); // refresh Root DSE - browserViewBot.selectEntry( "DIT", "Root DSE" ); + browserViewBot.selectEntry( ROOT_DSE_PATH ); browserViewBot.refresh(); // check the entry doesn't exist now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=refresh" ) ); + browserViewBot.expandEntry( path( MISC_DN ) ); + assertFalse( browserViewBot.existsEntry( path( refreshDn ) ) ); } @@ -370,80 +361,83 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-481. * * Check proper operation of refresh action. - * - * @throws Exception */ - @Test - public void testRefreshSearchContinuation() throws Exception + @ParameterizedTest + @LdapServersSource + public void testRefreshSearchContinuation( TestLdapServer server ) throws Exception { - // preparation: add referral entry and set referral handling - String url = "ldap://" + LOCALHOST + ":" + ldapServer.getPort() + "/ou=users,ou=system"; - Entry refEntry = new DefaultEntry( service.getSchemaManager() ); - refEntry.setDn( new Dn( "cn=referral,ou=system" ) ); - refEntry.add( "objectClass", "top", "referral", "extensibleObject" ); - refEntry.add( "cn", "referral" ); - refEntry.add( "ref", url ); - ldapServer.getDirectoryService().getAdminSession().add( refEntry ); + Connection connection = connectionsViewBot.createTestConnection( server ); + Dn refreshDn = dn( "cn=refresh", MISC_DN ); + String[] pathToReferral = pathWithRefLdapUrl( server, MISC_DN ); + String[] pathToRefreshViaReferral = path( pathToReferral, "cn=refresh" ); connection.getConnectionParameter().setExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD, ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal() ); - browserViewBot.selectEntry( "DIT", "Root DSE" ); + browserViewBot.selectEntry( ROOT_DSE_PATH ); browserViewBot.refresh(); // check the entry doesn't exist yet - ReferralDialogBot refDialog = browserViewBot.expandEntryExpectingReferralDialog( "DIT", "Root DSE", - "ou=system", url ); + ReferralDialogBot refDialog = browserViewBot.expandEntryExpectingReferralDialog( pathToReferral ); refDialog.clickOkButton(); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) ); + assertFalse( browserViewBot.existsEntry( pathToRefreshViaReferral ) ); // add the entry directly in the server - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "cn=refresh,ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "person" ); - entry.add( "cn", "refresh" ); - entry.add( "sn", "refresh" ); - ldapServer.getDirectoryService().getAdminSession().add( entry ); + server.withAdminConnection( conn -> { + Entry entry = new DefaultEntry( conn.getSchemaManager() ); + entry.setDn( refreshDn ); + entry.add( "objectClass", "top", "person" ); + entry.add( "cn", "refresh" ); + entry.add( "sn", "refresh" ); + conn.add( entry ); + } ); // check the entry still isn't visible in the tree - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) ); + assertFalse( browserViewBot.existsEntry( pathToRefreshViaReferral ) ); // refresh search continuation - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", url ); + browserViewBot.selectEntry( pathToReferral ); browserViewBot.refresh(); // check the entry exists now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", url ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ); + browserViewBot.expandEntry( pathToReferral ); + assertTrue( browserViewBot.existsEntry( pathToRefreshViaReferral ) ); + browserViewBot.selectEntry( pathToRefreshViaReferral ); // delete the entry directly in the server - ldapServer.getDirectoryService().getAdminSession().delete( new Dn( "cn=refresh,ou=users,ou=system" ) ); + server.withAdminConnection( conn -> { + conn.delete( refreshDn ); + } ); - // check the entry still is now visible in the tree - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) ); + // check the entry still is visible in the tree + assertTrue( browserViewBot.existsEntry( pathToRefreshViaReferral ) ); // refresh search continuation - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", url ); + browserViewBot.selectEntry( pathToReferral ); browserViewBot.refresh(); // check the entry doesn't exist now - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", url ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", url, "cn=refresh" ) ); + browserViewBot.expandEntry( pathToReferral ); + assertFalse( browserViewBot.existsEntry( pathToRefreshViaReferral ) ); } /** * Test for DIRSTUDIO-591. * (Error reading objects with # in DN) - * - * @throws Exception */ - @Test - public void testBrowseDnWithSharpAndHexSequence() throws Exception + @ParameterizedTest + @LdapServersSource + public void testBrowseDnWithSharpAndHexSequence( TestLdapServer server ) throws Exception { - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=\\#ACL_AD-Projects_Author" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=\\#ACL_AD-Projects_Author" ); + Dn dn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; + if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds ) + { + dn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; + } + + connectionsViewBot.createTestConnection( server ); + assertTrue( browserViewBot.existsEntry( path( dn ) ) ); + browserViewBot.selectEntry( path( dn ) ); assertEquals( "No modification expected", "", modificationLogsViewBot.getModificationLogsText() ); } @@ -452,34 +446,75 @@ public class BrowserTest extends AbstractLdapTestUnit /** * Test for DIRSTUDIO-1172: Studio doesn't display entries with trailing =. */ - @Test - public void testBrowseDnWithTrailingEqualsCharacter() throws Exception + @ParameterizedTest + @LdapServersSource + public void testBrowseDnWithTrailingEqualsCharacter( TestLdapServer server ) throws Exception { - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=nghZwwtHgxgyvVbTQCYyeY\\+O4cc=" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=nghZwwtHgxgyvVbTQCYyeY\\+O4cc=" ); + Dn dn = DN_WITH_TRAILING_EQUALS_CHARACTER; + if ( server.getType() == LdapServerType.OpenLdap ) + { + dn = DN_WITH_TRAILING_EQUALS_CHARACTER_HEX_PAIR_ESCAPED; + } + + connectionsViewBot.createTestConnection( server ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=nghZwwtHgxgyvVbTQCYyeY+email=" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=nghZwwtHgxgyvVbTQCYyeY+email=" ); + assertTrue( browserViewBot.existsEntry( path( dn ) ) ); + browserViewBot.selectEntry( path( dn ) ); + } + + + /** + * Test for DIRSTUDIO-1172: Studio doesn't display entries with trailing =. + */ + @ParameterizedTest + @LdapServersSource(types = LdapServerType.ApacheDS) + // Empty RDN value is not supported by OpenLDAP and 389ds + public void testBrowseDnWithEmptyRdnValue( TestLdapServer server ) throws Exception + { + + Dn dn = dn( "cn=nghZwwtHgxgyvVbTQCYyeY+email=", MISC_DN ); + + server.withAdminConnection( connection -> { + Entry entry = new DefaultEntry( connection.getSchemaManager() ); + entry.setDn( dn ); + entry.add( "objectClass", "top", "person", "extensibleObject" ); + entry.add( "cn", "nghZwwtHgxgyvVbTQCYyeY" ); + entry.add( "sn", "nghZwwtHgxgyvVbTQCYyeY" ); + entry.add( "email", "" ); + connection.add( entry ); + } ); + + connectionsViewBot.createTestConnection( server ); + + assertTrue( browserViewBot.existsEntry( path( dn ) ) ); + browserViewBot.selectEntry( path( dn ) ); } /** * Test for DIRSTUDIO-1151: DN with backslash not displayed */ - @Test - public void testBrowseDnWithBackslash() throws Exception + @ParameterizedTest + @LdapServersSource + public void testBrowseDnWithBackslash( TestLdapServer server ) throws Exception { + Dn dn = DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; + if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds ) + { + dn = DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; + } + + connectionsViewBot.createTestConnection( server ); + // expand parent and verify entry is visible - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.0\\,foo" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.0\\,foo" ); + browserViewBot.expandEntry( path( dn.getParent() ) ); + assertTrue( browserViewBot.existsEntry( path( dn ) ) ); + browserViewBot.selectEntry( path( dn ) ); // refresh entry and verify child is still visible - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( dn.getParent() ) ); browserViewBot.refresh(); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.0\\,foo" ) ); + assertTrue( browserViewBot.existsEntry( path( dn ) ) ); } @@ -489,9 +524,12 @@ public class BrowserTest extends AbstractLdapTestUnit * * @throws Exception */ - @Test - public void testNoModificationWhileBrowsingAndRefreshing() throws Exception + @ParameterizedTest + @LdapServersSource + public void testNoModificationWhileBrowsingAndRefreshing( TestLdapServer server ) throws Exception { + connectionsViewBot.createTestConnection( server ); + boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE; ErrorDialog.AUTOMATED_MODE = false; @@ -500,18 +538,16 @@ public class BrowserTest extends AbstractLdapTestUnit try { - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=\\#ACL_AD-Projects_Author" ) ); + assertTrue( browserViewBot.existsEntry( path( MULTI_VALUED_RDN_DN ) ) ); for ( int i = 0; i < 5; i++ ) { // select entry and refresh - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=\\#ACL_AD-Projects_Author" ); + browserViewBot.selectEntry( path( MULTI_VALUED_RDN_DN ) ); browserViewBot.refresh(); // select parent and refresh - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( MULTI_VALUED_RDN_DN.getParent() ) ); browserViewBot.refresh(); } } @@ -531,53 +567,43 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-603, DIRSHARED-41. * (Error browsing/entering rfc2307 compliant host entry.) */ - @Test - public void testBrowseDnWithIpHostNumber() throws Exception + @ParameterizedTest + @LdapServersSource + public void testBrowseDnWithIpHostNumber( TestLdapServer server ) throws Exception { - ApacheDsUtils.enableSchema( ldapServer, "nis" ); - - // create entry with multi-valued RDN containing an IP address value - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "cn=loopback+ipHostNumber=" + LOCALHOST_ADDRESS + ",ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "device", "ipHost" ); - entry.add( "cn", "loopback" ); - entry.add( "ipHostNumber", LOCALHOST_ADDRESS ); - ldapServer.getDirectoryService().getAdminSession().add( entry ); - - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=loopback+ipHostNumber=" + LOCALHOST_ADDRESS ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "cn=loopback+ipHostNumber=" + LOCALHOST_ADDRESS ); + connectionsViewBot.createTestConnection( server ); + + assertTrue( browserViewBot.existsEntry( path( DN_WITH_IP_HOST_NUMBER ) ) ); + browserViewBot.selectEntry( path( DN_WITH_IP_HOST_NUMBER ) ); } /** * DIRSTUDIO-637: copy/paste of attributes no longer works. * Test copy/paste of a value to a bookmark. - * - * @throws Exception - * the exception */ - @Test - public void testCopyPasteValueToBookmark() throws Exception + @ParameterizedTest + @LdapServersSource + public void testCopyPasteValueToBookmark( TestLdapServer server ) throws Exception { // create a bookmark + Connection connection = connectionsViewBot.createTestConnection( server ); IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager() .getBrowserConnection( connection ); browserConnection.getBookmarkManager().addBookmark( - new Bookmark( browserConnection, new Dn( "uid=user.2,ou=users,ou=system" ), "My Bookmark" ) ); + new Bookmark( browserConnection, MULTI_VALUED_RDN_DN, "My Bookmark" ) ); // copy a value - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ); - EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" ); + browserViewBot.selectEntry( path( USER1_DN ) ); + EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() ); entryEditorBot.activate(); entryEditorBot.copyValue( "uid", "user.1" ); // select the bookmark browserViewBot.selectEntry( "Bookmarks", "My Bookmark" ); - entryEditorBot = studioBot.getEntryEditorBot( "uid=user.2,ou=users,ou=system" ); + entryEditorBot = studioBot.getEntryEditorBot( MULTI_VALUED_RDN_DN.getName() ); entryEditorBot.activate(); - assertEquals( 23, entryEditorBot.getAttributeValues().size() ); + assertEquals( 8, entryEditorBot.getAttributeValues().size() ); // paste the value JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__execute_ldif_name ); @@ -585,13 +611,14 @@ public class BrowserTest extends AbstractLdapTestUnit watcher.waitUntilDone(); // assert pasted value visible in editor - assertEquals( 24, entryEditorBot.getAttributeValues().size() ); + assertEquals( 9, entryEditorBot.getAttributeValues().size() ); entryEditorBot.getAttributeValues().contains( "uid: user.1" ); // assert pasted value was written to directory - Entry entry = ldapServer.getDirectoryService().getAdminSession().lookup( - new Dn( "uid=user.2,ou=users,ou=system" ) ); - assertTrue( entry.contains( "uid", "user.1" ) ); + server.withAdminConnection( conn -> { + Entry entry = conn.lookup( MULTI_VALUED_RDN_DN ); + assertTrue( entry.contains( "uid", "user.1" ) ); + } ); } @@ -600,16 +627,18 @@ public class BrowserTest extends AbstractLdapTestUnit * * Verify input is set only once when entry is selected. */ - @Test - public void testSetInputOnlyOnce() throws Exception + @ParameterizedTest + @LdapServersSource + public void testSetInputOnlyOnce( TestLdapServer server ) throws Exception { /* * This test fails on Jenkins Windows Server, to be investigated... */ // Assume.assumeFalse( StudioSystemUtils.IS_OS_WINDOWS_SERVER ); + connectionsViewBot.createTestConnection( server ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( path( USERS_DN ) ); + browserViewBot.expandEntry( path( USERS_DN ) ); // verify link-with-editor is enabled assertTrue( BrowserUIPlugin.getDefault().getPreferenceStore() @@ -645,12 +674,12 @@ public class BrowserTest extends AbstractLdapTestUnit } ); // select 3 different entries, select one twice should not set the input again - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.2" ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.2" ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.3" ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.3" ); + browserViewBot.selectEntry( path( USER1_DN ) ); + browserViewBot.selectEntry( path( USER1_DN ) ); + browserViewBot.selectEntry( path( USER2_DN ) ); + browserViewBot.selectEntry( path( USER2_DN ) ); + browserViewBot.selectEntry( path( USER3_DN ) ); + browserViewBot.selectEntry( path( USER3_DN ) ); // verify that input was only set 3 times. assertEquals( "Only 3 input changes expected.", 3, counter.get() ); @@ -660,13 +689,13 @@ public class BrowserTest extends AbstractLdapTestUnit // use navigation history to go back and forth, each step should set input only once studioBot.navigationHistoryBack(); - browserViewBot.waitUntilEntryIsSelected( "uid=user.2" ); + browserViewBot.waitUntilEntryIsSelected( USER2_DN.getRdn().getName() ); studioBot.navigationHistoryBack(); - browserViewBot.waitUntilEntryIsSelected( "uid=user.1" ); + browserViewBot.waitUntilEntryIsSelected( USER1_DN.getRdn().getName() ); studioBot.navigationHistoryForward(); - browserViewBot.waitUntilEntryIsSelected( "uid=user.2" ); + browserViewBot.waitUntilEntryIsSelected( USER2_DN.getRdn().getName() ); studioBot.navigationHistoryForward(); - browserViewBot.waitUntilEntryIsSelected( "uid=user.3" ); + browserViewBot.waitUntilEntryIsSelected( USER3_DN.getRdn().getName() ); // verify that input was only set 4 times. assertEquals( "Only 4 input changes expected.", 4, counter.get() ); @@ -677,149 +706,197 @@ public class BrowserTest extends AbstractLdapTestUnit * Test for DIRSTUDIO-987, DIRSTUDIO-271. * * Browse and refresh entry with multi-valued RDN with same attribute type. - * - * @throws Exception */ - @Test - public void testBrowseAndRefreshEntryWithMvRdn() throws Exception + @ParameterizedTest + @LdapServersSource(types = + { LdapServerType.ApacheDS, LdapServerType.Fedora389ds }) + // Multi-valued RDN with same attribute is not suupported by OpenLDAP + public void testBrowseAndRefreshEntryWithMvRdn( TestLdapServer server ) throws Exception { + Dn entryDn = dn( "l=Berlin+l=Brandenburger Tor+l=de+l=eu", MISC_DN ); + Dn childDn = dn( "cn=A", entryDn ); + + server.withAdminConnection( connection -> { + Entry entry1 = new DefaultEntry( connection.getSchemaManager() ); + entry1.setDn( entryDn ); + entry1.add( "objectClass", "top", "locality" ); + entry1.add( "l", "eu", "de", "Berlin", "Brandenburger Tor" ); + connection.add( entry1 ); + + Entry entry2 = new DefaultEntry( connection.getSchemaManager() ); + entry2.setDn( childDn ); + entry2.add( "objectClass", "top", "person" ); + entry2.add( "cn", "A" ); + entry2.add( "sn", "A" ); + connection.add( entry2 ); + } ); + + String[] pathToParent = path( entryDn.getParent() ); + String[] pathToEntry = path( entryDn ); + String[] pathToChild = path( childDn ); + + connectionsViewBot.createTestConnection( server ); + // expand parent and verify entry is visible - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ); + browserViewBot.expandEntry( pathToParent ); + assertTrue( browserViewBot.existsEntry( pathToEntry ) ); + browserViewBot.selectEntry( pathToEntry ); // expand entry and verify child is visible - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor", "cn=A" ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor", "cn=A" ); + browserViewBot.expandEntry( pathToEntry ); + assertTrue( browserViewBot.existsEntry( pathToChild ) ); + browserViewBot.selectEntry( pathToChild ); // refresh entry and verify child is still visible - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ); + browserViewBot.selectEntry( pathToEntry ); browserViewBot.refresh(); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor", "cn=A" ) ); + assertTrue( browserViewBot.existsEntry( pathToChild ) ); // refresh parent and verify entry is still visible - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + browserViewBot.selectEntry( pathToParent ); browserViewBot.refresh(); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ) ); + assertTrue( browserViewBot.existsEntry( pathToEntry ) ); // expand entry and verify child is visible - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", - "l=eu + l=de + l=Berlin + l=Brandenburger Tor", "cn=A" ) ); + browserViewBot.expandEntry( pathToEntry ); + assertTrue( browserViewBot.existsEntry( pathToChild ) ); } - @Test - public void testBrowseAliasEntry() + @ParameterizedTest + @LdapServersSource + public void testBrowseAliasEntry( TestLdapServer server ) throws Exception { // disable alias dereferencing + Connection connection = connectionsViewBot.createTestConnection( server ); connection.getConnectionParameter().setExtendedIntProperty( IBrowserConnection.CONNECTION_PARAMETER_ALIASES_DEREFERENCING_METHOD, AliasDereferencingMethod.NEVER.ordinal() ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=alias" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=alias" ) ); + browserViewBot.expandEntry( path( ALIAS_DN.getParent() ) ); + assertTrue( browserViewBot.existsEntry( path( ALIAS_DN ) ) ); + browserViewBot.selectEntry( path( ALIAS_DN ) ); } - @Test - public void testBrowseReferralEntry() + @ParameterizedTest + @LdapServersSource + public void testBrowseReferralEntry( TestLdapServer server ) throws Exception { // enable ManageDsaIT control + Connection connection = connectionsViewBot.createTestConnection( server ); connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_MANAGE_DSA_IT, true ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=referral" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=referral" ) ); + browserViewBot.expandEntry( path( REFERRAL_TO_USERS_DN.getParent() ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_USERS_DN ) ) ); + browserViewBot.selectEntry( path( REFERRAL_TO_USERS_DN ) ); } - @Test - public void testBrowseSubEntry() + @ParameterizedTest + @LdapServersSource(types = LdapServerType.ApacheDS) + public void testBrowseSubEntry( TestLdapServer server ) throws Exception { + Dn subentryDn = dn( "cn=subentry", MISC_DN ); + + server.withAdminConnection( connection -> { + + Modification mod = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, + "administrativeRole", "accessControlSpecificArea" ); + connection.modify( subentryDn.getParent(), mod ); + + Entry subentry = new DefaultEntry( connection.getSchemaManager() ); + subentry.setDn( subentryDn ); + subentry.add( "objectClass", "top", "subentry" ); + subentry.add( "cn", "subentry" ); + subentry.add( "subtreeSpecification", "{}" ); + connection.add( subentry ); + } ); + // enable Subentries control + Connection connection = connectionsViewBot.createTestConnection( server ); connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_FETCH_SUBENTRIES, true ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=subentry" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=special", "cn=subentry" ) ); + browserViewBot.expandEntry( path( subentryDn.getParent() ) ); + assertTrue( browserViewBot.existsEntry( path( subentryDn ) ) ); + browserViewBot.selectEntry( path( subentryDn ) ); } - @Test - public void testBrowseWithPagingWithScrollMode() + @ParameterizedTest + @LdapServersSource + public void testBrowseWithPagingWithScrollMode( TestLdapServer server ) throws Exception { - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + Connection connection = connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( USERS_DN ) ); // enable Simple Paged Results control connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH, true ); connection.getConnectionParameter().setExtendedIntProperty( - IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE, 5 ); + IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE, 3 ); connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE, true ); // 1st page - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ) ); + browserViewBot.expandEntry( path( USERS_DN ) ); + assertFalse( browserViewBot.existsEntry( path( USERS_DN, "--- Top Page ---" ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "--- Next Page ---" ) ) ); // next page - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ) ); + browserViewBot.selectEntry( path( USERS_DN, "--- Next Page ---" ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "--- Top Page ---" ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "--- Next Page ---" ) ) ); // last page - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ) ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ) ); + browserViewBot.selectEntry( path( USERS_DN, "--- Next Page ---" ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "--- Top Page ---" ) ) ); + assertFalse( browserViewBot.existsEntry( path( USERS_DN, "--- Next Page ---" ) ) ); // back to top - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ) ); + browserViewBot.selectEntry( path( USERS_DN, "--- Top Page ---" ) ); + assertFalse( browserViewBot.existsEntry( path( USERS_DN, "--- Top Page ---" ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "--- Next Page ---" ) ) ); } - @Test - public void testBrowseWithPagingWithoutScrollMode() + @ParameterizedTest + @LdapServersSource + public void testBrowseWithPagingWithoutScrollMode( TestLdapServer server ) throws Exception { - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + Connection connection = connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( USERS_DN ) ); // enable Simple Paged Results control connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH, true ); connection.getConnectionParameter().setExtendedIntProperty( - IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE, 5 ); + IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SIZE, 3 ); connection.getConnectionParameter().setExtendedBoolProperty( IBrowserConnection.CONNECTION_PARAMETER_PAGED_SEARCH_SCROLL_MODE, false ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Top Page ---" ) ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "--- Next Page ---" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users (13)" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) ); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.8" ) ); + browserViewBot.expandEntry( path( USERS_DN ) ); + assertFalse( browserViewBot.existsEntry( path( USERS_DN, "--- Top Page ---" ) ) ); + assertFalse( browserViewBot.existsEntry( path( USERS_DN, "--- Next Page ---" ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "uid=user.1" ) ) ); + assertTrue( browserViewBot.existsEntry( path( USERS_DN, "uid=user.8" ) ) ); } - @Test - public void testDeleteClearsEntryCache() throws Exception + + @ParameterizedTest + @LdapServersSource + public void x( TestLdapServer server ) throws Exception { - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); + connectionsViewBot.createTestConnection( server ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ); - EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" ); + browserViewBot.selectEntry( path( USERS_DN ) ); + browserViewBot.expandEntry( path( USERS_DN ) ); + + browserViewBot.selectEntry( path( USER1_DN ) ); + EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() ); List<String> attributeValues = entryEditorBot.getAttributeValues(); assertEquals( 23, attributeValues.size() ); assertTrue( attributeValues.contains( "uid: user.1" ) ); @@ -827,24 +904,26 @@ public class BrowserTest extends AbstractLdapTestUnit DeleteDialogBot deleteDialog = browserViewBot.openDeleteDialog(); deleteDialog.clickOkButton(); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" ); - assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) ); - - Entry entry = new DefaultEntry( service.getSchemaManager() ); - entry.setDn( new Dn( "uid=user.1,ou=users,ou=system" ) ); - entry.add( "objectClass", "top", "person", "organizationalPerson", "inetOrgPerson" ); - entry.add( "uid", "user.1" ); - entry.add( "givenName", "Foo" ); - entry.add( "sn", "Bar" ); - entry.add( "cn", "Foo Bar" ); - entry.add( "initials", "FB" ); - service.getAdminSession().add( entry ); + browserViewBot.selectEntry( path( USERS_DN ) ); + assertFalse( browserViewBot.existsEntry( path( USER1_DN ) ) ); + + server.withAdminConnection( conn -> { + Entry entry = new DefaultEntry( conn.getSchemaManager() ); + entry.setDn( USER1_DN ); + entry.add( "objectClass", "top", "person", "organizationalPerson", "inetOrgPerson" ); + entry.add( "uid", "user.1" ); + entry.add( "givenName", "Foo" ); + entry.add( "sn", "Bar" ); + entry.add( "cn", "Foo Bar" ); + entry.add( "initials", "FB" ); + conn.add( entry ); + } ); browserViewBot.refresh(); - assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) ); + assertTrue( browserViewBot.existsEntry( path( USER1_DN ) ) ); - browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ); - entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" ); + browserViewBot.selectEntry( path( USER1_DN ) ); + entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() ); attributeValues = entryEditorBot.getAttributeValues(); assertEquals( 9, attributeValues.size() ); assertTrue( attributeValues.contains( "uid: user.1" ) ); diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java index 67eeac102..e0b907da9 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java @@ -21,12 +21,12 @@ package org.apache.directory.studio.test.integration.ui; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_BACKSLASH_PREFIXED; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_HEX_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC111_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -75,13 +75,13 @@ public class MoveEntryTest extends AbstractTestBase @LdapServersSource public void testMoveDown( TestLdapServer server ) throws Exception { - Dn dnToMove = RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED; - Dn newParentDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED; + Dn dnToMove = DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; + Dn newParentDn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds ) { // OpenLDAP and 389ds escape all characters with hex digits - dnToMove = RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED; - newParentDn = LEADING_SHARP_DN_HEX_ESCAPED; + dnToMove = DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; + newParentDn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; } connectionsViewBot.createTestConnection( server ); diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java index d0e3a63b2..436e8f0d7 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java @@ -21,9 +21,11 @@ package org.apache.directory.studio.test.integration.ui; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_1_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_2_DN; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_MISC_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_REFERRALS_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_REFERRAL_TO_USERS_DN; import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USER1_DN; @@ -83,7 +85,8 @@ public class ReferralDialogTest extends AbstractTestBase browserViewBot.expandEntry( pathWithRefLdapUrl( server, USERS_DN ) ); assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) ); browserViewBot.expandEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ); - + assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) ); + browserViewBot.expandEntry( pathWithRefLdapUrl( server, MISC_DN ) ); } @@ -169,12 +172,13 @@ public class ReferralDialogTest extends AbstractTestBase // ensure that the referral entries are visible, but not the continuation URLs assertRefLdapUrlsAreNotVisible( server ); - browserViewBot.selectEntry( path( REFERRAL_TO_USER1_DN ) ); - browserViewBot.selectEntry( path( REFERRAL_TO_USERS_DN ) ); - browserViewBot.selectEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) ); - browserViewBot.selectEntry( path( REFERRAL_TO_REFERRALS_DN ) ); - browserViewBot.selectEntry( path( REFERRAL_LOOP_1_DN ) ); - browserViewBot.selectEntry( path( REFERRAL_LOOP_2_DN ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_USER1_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_USERS_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRALS_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_LOOP_1_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_LOOP_2_DN ) ) ); + assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_MISC_DN ) ) ); } @@ -205,6 +209,7 @@ public class ReferralDialogTest extends AbstractTestBase assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) ); assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) ) ); assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) ) ); + assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) ); // select one target, that should popup the referral dialog ReferralDialogBot referralDialogBot = browserViewBot @@ -220,6 +225,7 @@ public class ReferralDialogTest extends AbstractTestBase browserViewBot.expandEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ); browserViewBot.expandEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) ); browserViewBot.expandEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) ); + browserViewBot.expandEntry( pathWithRefLdapUrl( server, MISC_DN ) ); } @@ -231,6 +237,7 @@ public class ReferralDialogTest extends AbstractTestBase assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) ); assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) ) ); assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) ) ); + assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) ); } @@ -242,6 +249,7 @@ public class ReferralDialogTest extends AbstractTestBase assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRALS_DN ) ) ); assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_1_DN ) ) ); assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_2_DN ) ) ); + assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_MISC_DN ) ) ); } }
\ No newline at end of file diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java index 2f1204984..9b2a77900 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/RenameEntryTest.java @@ -21,11 +21,11 @@ package org.apache.directory.studio.test.integration.ui; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_BACKSLASH_PREFIXED; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.LEADING_SHARP_DN_HEX_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; import static org.apache.directory.studio.test.integration.junit5.TestFixture.MULTI_VALUED_RDN_DN; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED; -import static org.apache.directory.studio.test.integration.junit5.TestFixture.RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; +import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; import static org.apache.directory.studio.test.integration.junit5.TestFixture.dn; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -89,21 +89,19 @@ public class RenameEntryTest extends AbstractTestBase @LdapServersSource public void testRenameRdnWithEscapedCharacters( TestLdapServer server ) throws Exception { - Dn oldDn = RDN_WITH_ESCAPED_CHARACTERS_DN_BACKSLASH_PREFIXED; - Dn newDn = dn( "cn=\\#\\\\\\+\\, \\\"öé\\\" 2", oldDn.getParent() ); + Dn oldDn = DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED; if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds ) { - // OpenLDAP and 389ds escape all characters with hex digits - oldDn = RDN_WITH_ESCAPED_CHARACTERS_DN_HEX_ESCAPED; - newDn = dn( "cn=\\23\\5C\\2B\\2C \\22öé\\22 2", oldDn.getParent() ); + oldDn = DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED; } + Dn newDn = dn( oldDn.getRdn().getName() + " renamed", oldDn.getParent() ); connectionsViewBot.createTestConnection( server ); browserViewBot.selectEntry( path( oldDn ) ); RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog(); assertTrue( renameDialogBot.isVisible() ); - renameDialogBot.setRdnValue( 1, "#\\+, \"öé\" 2" ); + renameDialogBot.setRdnValue( 1, newDn.getRdn().getValue() ); renameDialogBot.clickOkButton(); assertTrue( browserViewBot.existsEntry( path( newDn ) ) ); @@ -119,14 +117,13 @@ public class RenameEntryTest extends AbstractTestBase */ @ParameterizedTest @LdapServersSource - public void testRenameRdnWithSharp( TestLdapServer server ) throws Exception + public void testRenameRdnWithLeadingSharp( TestLdapServer server ) throws Exception { - Dn oldDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED; + Dn oldDn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; Dn newDn = dn( "cn=\\#ABCDEF", oldDn.getParent() ); if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds ) { - // OpenLDAP and 389ds escape all characters with hex digits - oldDn = LEADING_SHARP_DN_HEX_ESCAPED; + oldDn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; newDn = dn( "cn=\\23ABCDEF", oldDn.getParent() ); } @@ -147,22 +144,19 @@ public class RenameEntryTest extends AbstractTestBase /** * Test for DIRSHARED-39. * - * Rename an entry with trailing space in RDN. + * Rename an entry with leading and trailing space in RDN. */ @ParameterizedTest @LdapServersSource(types = { LdapServerType.ApacheDS, LdapServerType.OpenLdap }) public void testRenameRdnWithTrailingSpace( TestLdapServer server ) throws Exception { - Dn oldDn = LEADING_SHARP_DN_BACKSLASH_PREFIXED; - Dn newDn1 = dn( "cn=\\#ABCDEF\\ ", oldDn.getParent() ); - Dn newDn2 = dn( "cn=A\\ ", oldDn.getParent() ); + Dn oldDn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; + Dn newDn = dn( "cn=\\#ABCDEF\\ ", oldDn.getParent() ); if ( server.getType() == LdapServerType.OpenLdap ) { - // OpenLDAP and 389ds escape all characters with hex digits - oldDn = LEADING_SHARP_DN_HEX_ESCAPED; - newDn1 = dn( "cn=\\23ABCDEF\\20", oldDn.getParent() ); - newDn2 = dn( "cn=A\\20", oldDn.getParent() ); + oldDn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; + newDn = dn( "cn=\\23ABCDEF\\20", oldDn.getParent() ); } connectionsViewBot.createTestConnection( server ); @@ -173,18 +167,41 @@ public class RenameEntryTest extends AbstractTestBase renameDialogBot.setRdnValue( 1, "#ABCDEF " ); renameDialogBot.clickOkButton(); - assertTrue( browserViewBot.existsEntry( path( newDn1 ) ) ); - browserViewBot.selectEntry( path( newDn1 ) ); + assertTrue( browserViewBot.existsEntry( path( newDn ) ) ); + browserViewBot.selectEntry( path( newDn ) ); assertFalse( browserViewBot.existsEntry( path( oldDn ) ) ); - renameDialogBot = browserViewBot.openRenameDialog(); + } + + + /** + * Test for DIRSHARED-39. + * + * Rename an entry with leading and trailing space in RDN. + */ + @ParameterizedTest + @LdapServersSource(types = + { LdapServerType.ApacheDS, LdapServerType.OpenLdap }) + public void testRenameRdnWithLeadingAndTrailingSpace( TestLdapServer server ) throws Exception + { + Dn oldDn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED; + Dn newDn = dn( "cn=\\ #ABCDEF \\ ", oldDn.getParent() ); + if ( server.getType() == LdapServerType.OpenLdap ) + { + oldDn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED; + newDn = dn( "cn=\\20 #ABCDEF \\20", oldDn.getParent() ); + } + + connectionsViewBot.createTestConnection( server ); + browserViewBot.selectEntry( path( oldDn ) ); + + RenameEntryDialogBot renameDialogBot = browserViewBot.openRenameDialog(); assertTrue( renameDialogBot.isVisible() ); - renameDialogBot.setRdnValue( 1, "A " ); + renameDialogBot.setRdnValue( 1, " #ABCDEF " ); renameDialogBot.clickOkButton(); - assertTrue( browserViewBot.existsEntry( path( newDn2 ) ) ); - browserViewBot.selectEntry( path( newDn2 ) ); - assertFalse( browserViewBot.existsEntry( path( newDn1 ) ) ); + assertTrue( browserViewBot.existsEntry( path( newDn ) ) ); + browserViewBot.selectEntry( path( newDn ) ); assertFalse( browserViewBot.existsEntry( path( oldDn ) ) ); } diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java index 09923f193..084c44b7f 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java @@ -398,8 +398,8 @@ public class SearchTest extends AbstractLdapTestUnit assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) ); assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) ); assertTrue( browserViewBot.existsEntry( "Searches", searchName + " (15+)" ) ); - assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.1" ) ); - assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.8" ) ); + assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.1,ou=users,ou=system" ) ); + assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.8,ou=users,ou=system" ) ); } @@ -424,7 +424,7 @@ public class SearchTest extends AbstractLdapTestUnit dialogBot.clickSearchButton(); browserViewBot.expandEntry( "Searches", searchName ); - assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.1" ) ); + assertTrue( browserViewBot.existsEntry( "Searches", searchName, "uid=user.1,ou=users,ou=system" ) ); assertEquals( "(&(objectClass=*)(uid=user.1))", filter ); assertEquals( "(&\n (objectClass=*)\n (uid=user.1)\n)", formattetFilter ); } diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java index c0bc316a9..13e09fe25 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java @@ -268,15 +268,16 @@ class BrowserWidgetBot } - private boolean matches( String node, String nodeName ) + private boolean matches( String candidate, String needle ) { Pattern pattern = Pattern.compile( "(.*) \\(\\d+\\+?\\)" ); - Matcher matcher = pattern.matcher( node ); - if ( matcher.matches() ) + Matcher candidateMatcher = pattern.matcher( candidate ); + Matcher needleMatcher = pattern.matcher( needle ); + if ( candidateMatcher.matches() && !needleMatcher.matches() ) { - node = matcher.group( 1 ); + candidate = candidateMatcher.group( 1 ); } - return node.toUpperCase().equals( nodeName.toUpperCase() ); + return candidate.toUpperCase().equals( needle.toUpperCase() ); } diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/utils/JobWatcher.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/utils/JobWatcher.java index 41fd0daa4..003c0ed48 100644 --- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/utils/JobWatcher.java +++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/utils/JobWatcher.java @@ -142,6 +142,6 @@ public class JobWatcher }, SWTBotPreferences.TIMEOUT * 4 ); // Wait a bit longer after job is done to allow UI update - BotUtils.sleep( 1000L ); + BotUtils.sleep( 100L ); } } |