You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/08/02 19:33:54 UTC
svn commit: r682022 - in /directory/studio/trunk:
connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/
test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/
Author: seelmann
Date: Sat Aug 2 10:33:54 2008
New Revision: 682022
URL: http://svn.apache.org/viewvc?rev=682022&view=rev
Log:
Fix for DIRSTUDIO-360 (problem with slash '/' in DN)
Modified:
directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java?rev=682022&r1=682021&r2=682022&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/io/jndi/JNDIConnectionWrapper.java Sat Aug 2 10:33:54 2008
@@ -39,6 +39,7 @@
import javax.naming.ldap.Control;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
+import javax.naming.ldap.LdapName;
import javax.naming.ldap.ManageReferralControl;
import javax.naming.ldap.StartTlsRequest;
import javax.naming.ldap.StartTlsResponse;
@@ -301,7 +302,12 @@
searchCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
// perform the search
- NamingEnumeration<SearchResult> ne = searchCtx.search( searchBase, filter,
+ // we use LdapName here for the following reason:
+ // - when passing dn as String, JNDI doesn't handle slashes '/' correctly
+ // - when using LdapDN from shared-ldap, JNDI uses the toString() method
+ // and LdapDN.toString() returns the normalized ATAV, but we need the
+ // user provided ATAV.
+ NamingEnumeration<SearchResult> ne = searchCtx.search( new LdapName( searchBase ), filter,
searchControls );
namingEnumeration = new StudioNamingEnumeration( connection, ne, searchBase, filter,
searchControls, aliasesDereferencingMethod, referralsHandlingMethod, controls, requestNum,
@@ -453,7 +459,12 @@
modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
// perform modification
- modCtx.modifyAttributes( dn, modificationItems );
+ // we use LdapName here for the following reason:
+ // - when passing dn as String, JNDI doesn't handle slashes '/' correctly
+ // - when using LdapDN from shared-ldap, JNDI uses the toString() method
+ // and LdapDN.toString() returns the normalized ATAV, but we need the
+ // user provided ATAV.
+ modCtx.modifyAttributes( new LdapName( dn ), modificationItems );
}
catch ( ReferralException re )
{
@@ -554,7 +565,12 @@
}
// rename entry
- modCtx.rename( oldDn, newDn );
+ // we use LdapName here for the following reason:
+ // - when passing dn as String, JNDI doesn't handle slashes '/' correctly
+ // - when using LdapDN from shared-ldap, JNDI uses the toString() method
+ // and LdapDN.toString() returns the normalized ATAV, but we need the
+ // user provided ATAV.
+ modCtx.rename( new LdapName( oldDn ), new LdapName( newDn ) );
}
catch ( ReferralException re )
{
@@ -644,7 +660,12 @@
modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
// create entry
- modCtx.createSubcontext( dn, attributes );
+ // we use LdapName here for the following reason:
+ // - when passing dn as String, JNDI doesn't handle slashes '/' correctly
+ // - when using LdapDN from shared-ldap, JNDI uses the toString() method
+ // and LdapDN.toString() returns the normalized ATAV, but we need the
+ // user provided ATAV.
+ modCtx.createSubcontext( new LdapName( dn ), attributes );
}
catch ( ReferralException re )
{
@@ -732,7 +753,12 @@
modCtx.addToEnvironment( Context.REFERRAL, REFERRAL_THROW );
// delete entry
- modCtx.destroySubcontext( dn );
+ // we use LdapName here for the following reason:
+ // - when passing dn as String, JNDI doesn't handle slashes '/' correctly
+ // - when using LdapDN from shared-ldap, JNDI uses the toString() method
+ // and LdapDN.toString() returns the normalized ATAV, but we need the
+ // user provided ATAV.
+ modCtx.destroySubcontext( new LdapName( dn ) );
}
catch ( ReferralException re )
{
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java?rev=682022&r1=682021&r2=682022&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/NewEntryWizardTest.java Sat Aug 2 10:33:54 2008
@@ -21,6 +21,10 @@
package org.apache.directory.studio.test.integration.ui;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+
import net.sf.swtbot.eclipse.finder.SWTEclipseBot;
import net.sf.swtbot.wait.DefaultCondition;
import net.sf.swtbot.widgets.SWTBotCombo;
@@ -30,6 +34,8 @@
import net.sf.swtbot.widgets.SWTBotTreeItem;
import org.apache.directory.server.unit.AbstractServerTest;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
/**
@@ -46,6 +52,23 @@
protected void setUp() throws Exception
{
super.setUp();
+
+ // check if krb5kdc is disabled
+ Attributes krb5kdcAttrs = schemaRoot.getAttributes( "cn=Krb5kdc" );
+ boolean isKrb5KdcDisabled = false;
+ if ( krb5kdcAttrs.get( "m-disabled" ) != null )
+ {
+ isKrb5KdcDisabled = ( ( String ) krb5kdcAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
+ }
+ // if krb5kdc is disabled then enable it
+ if ( isKrb5KdcDisabled )
+ {
+ Attribute disabled = new AttributeImpl( "m-disabled" );
+ ModificationItemImpl[] mods = new ModificationItemImpl[]
+ { new ModificationItemImpl( DirContext.REMOVE_ATTRIBUTE, disabled ) };
+ schemaRoot.modifyAttributes( "cn=Krb5kdc", mods );
+ }
+
bot = new SWTEclipseBot();
SWTBotUtils.openLdapPerspective( bot );
SWTBotUtils.createTestConnection( bot, "NewEntryWizardTest", ldapServer.getIpPort() );
@@ -201,7 +224,7 @@
} );
}
-
+
/**
* Test for DIRSTUDIO-350.
*
@@ -269,10 +292,10 @@
return "Could not find widget";
}
} );
-
+
// Now create a second entry under the previously created entry
// to ensure that the selected parent is also upper case.
-
+
// open "New Entry" wizard
contextMenu = browserTree.contextMenu( "New Entry..." );
contextMenu.click();
@@ -285,17 +308,17 @@
bot.table( 0 ).select( "organization" );
bot.button( "Add" ).click();
bot.button( "Next >" ).click();
-
+
// specify DN
typeCombo = bot.comboBoxWithLabel( "RDN:" );
typeCombo.setText( "O" );
valueText = bot.text( "" );
valueText.setText( "testCreateOrganizationEntry2" );
-
+
// check preview text
SWTBotText previewText = bot.text( "O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system" );
assertEquals( "O=testCreateOrganizationEntry2,O=testCreateOrganizationEntry,ou=system", previewText.getText() );
-
+
bot.button( "Next >" ).click();
// wait for check that entry doesn't exist yet
@@ -332,4 +355,93 @@
} );
}
+
+ /**
+ * Test for DIRSTUDIO-360.
+ *
+ * Create entries with a slash '/' in the RDN value.
+ *
+ * @throws Exception the exception
+ */
+ public void testCreateEntryWithSlash() throws Exception
+ {
+ final SWTBotTree browserTree = SWTBotUtils.getLdapBrowserTree( bot );
+ SWTBotTreeItem systemNode = SWTBotUtils.selectNode( bot, browserTree, "DIT", "Root DSE", "ou=system" );
+ systemNode.expand();
+ systemNode.expand();
+
+ // open "New Entry" wizard
+ SWTBotMenu contextMenu = browserTree.contextMenu( "New Entry..." );
+ contextMenu.click();
+
+ // select entry creation method
+ bot.radio( "Create entry from scratch" ).click();
+ bot.button( "Next >" ).click();
+
+ // select object classes
+ bot.table( 0 ).select( "krb5Principal" );
+ bot.button( "Add" ).click();
+ bot.table( 0 ).select( "person" );
+ bot.button( "Add" ).click();
+ bot.button( "Next >" ).click();
+
+ // specify DN
+ SWTBotCombo typeCombo = bot.comboBoxWithLabel( "RDN:" );
+ typeCombo.setText( "krb5PrincipalName" );
+ SWTBotText valueText = bot.text( "" );
+ valueText.setText( "kadmin/changepw@DOMAIN" );
+ bot.button( "Next >" ).click();
+
+ // wait for check that entry doesn't exist yet
+ bot.waitUntil( new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return bot.tree( 0 ) != null;
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find entry editor";
+ }
+ } );
+
+ // click to finish editing of sn
+ SWTBotTree tree = bot.tree( 0 );
+ SWTBotTreeItem krbNode = SWTBotUtils.selectNode( bot, tree, "krb5PrincipalName" );
+ krbNode.click();
+
+ // enter sn value
+ tree.select( "sn" );
+ bot.text( "" ).setText( "test" );
+ // click to finish editing of sn
+ krbNode.click();
+
+ // enter cn value
+ tree.select( "cn" );
+ bot.text( "" ).setText( "test" );
+ // click to finish editing of cn
+ krbNode.click();
+
+ // click finish to create the entry
+ bot.button( "Finish" ).click();
+
+ // wait till entry is created and selected in the tree
+ bot.waitUntil( new DefaultCondition()
+ {
+ public boolean test() throws Exception
+ {
+ return browserTree.selection().get( 0 ).get( 0 )
+ .startsWith( "krb5PrincipalName=kadmin/changepw@DOMAIN" );
+ }
+
+
+ public String getFailureMessage()
+ {
+ return "Could not find entry 'krb5Principal=kadmin/changepw@DOMAIN'";
+ }
+ } );
+ }
+
}