directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1731682 - in /directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui: ./ bots/
Date Mon, 22 Feb 2016 16:26:53 GMT
Author: seelmann
Date: Mon Feb 22 16:26:52 2016
New Revision: 1731682

URL: http://svn.apache.org/viewvc?rev=1731682&view=rev
Log:
DIRSTUDIO-738: Add support for modular crypt format password
* Add UI tests

Added:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
  (with props)
Modified:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java
Mon Feb 22 16:26:52 2016
@@ -21,8 +21,11 @@
 package org.apache.directory.studio.test.integration.ui;
 
 
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.lang.StringUtils;
@@ -30,8 +33,11 @@ import org.apache.directory.server.annot
 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.api.ldap.model.constants.LdapSecurityConstants;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.password.PasswordUtil;
+import org.apache.directory.api.util.Strings;
 import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
 import org.apache.directory.studio.test.integration.ui.bots.BrowserViewBot;
 import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
@@ -39,6 +45,7 @@ import org.apache.directory.studio.test.
 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.NewAttributeWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.PasswordEditorDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
 import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
 import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
@@ -217,7 +224,7 @@ public class EntryEditorTest extends Abs
      *             the exception
      */
     @Test
-    public void testCopyPasteIn() throws Exception
+    public void testCopyPaste() throws Exception
     {
         browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara
Jensen" );
 
@@ -248,4 +255,99 @@ public class EntryEditorTest extends Abs
         assertTrue( entry.contains( "uid", "bjensen" ) );
     }
 
+
+    /**
+     * DIRSTUDIO-738: Add support for modular crypt format password
+     */
+    @Test
+    public void testPasswordValueEditor() throws Exception
+    {
+        browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "cn=Barbara
Jensen" );
+
+        EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "cn=Barbara Jensen,ou=users,ou=system"
);
+        entryEditorBot.activate();
+        String dn = entryEditorBot.getDnText();
+        assertEquals( "DN: cn=Barbara Jensen,ou=users,ou=system", dn );
+        assertEquals( 8, entryEditorBot.getAttributeValues().size() );
+        assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
+
+        // add userPassword attribute
+        entryEditorBot.activate();
+        NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
+        assertTrue( wizardBot.isVisible() );
+        wizardBot.typeAttributeType( "userPassword" );
+        PasswordEditorDialogBot pwdEditorBot = wizardBot.clickFinishButtonExpectingPasswordEditor();
+        assertTrue( pwdEditorBot.isVisible() );
+
+        pwdEditorBot.setNewPassword1( "secret" );
+        pwdEditorBot.setNewPassword2( "secret" );
+        pwdEditorBot.setShowNewPasswordDetails( true );
+
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_MD5, PasswordUtil.MD5_LENGTH,
0 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SMD5, PasswordUtil.MD5_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA, PasswordUtil.SHA1_LENGTH,
0 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA, PasswordUtil.SHA1_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA256, PasswordUtil.SHA256_LENGTH,
0 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA256, PasswordUtil.SHA256_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA384, PasswordUtil.SHA384_LENGTH,
0 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA384, PasswordUtil.SHA384_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA512, PasswordUtil.SHA512_LENGTH,
0 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA512, PasswordUtil.SHA512_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_PKCS5S2, PasswordUtil.PKCS5S2_LENGTH,
16 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT, PasswordUtil.CRYPT_LENGTH,
2 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_MD5, PasswordUtil.CRYPT_MD5_LENGTH,
8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_SHA256,
+            PasswordUtil.CRYPT_SHA256_LENGTH, 8 );
+        assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_SHA512,
+            PasswordUtil.CRYPT_SHA512_LENGTH, 8 );
+
+        pwdEditorBot.clickOkButton();
+
+        // assert value after saved and reloaded from server
+        SWTUtils.sleep( 1000 );
+        System.out.println( entryEditorBot.getAttributeValues() );
+        assertTrue( entryEditorBot.getAttributeValues().contains( "userPassword: CRYPT-SHA-512
hashed password" ) );
+
+        // verify and bind with the correct password
+        pwdEditorBot = entryEditorBot.editValueExpectingPasswordEditor( "userPassword",
+            "CRYPT-SHA-512 hashed password" );
+        pwdEditorBot.activateCurrentPasswordTab();
+        pwdEditorBot.setVerifyPassword( "secret" );
+        assertNull( pwdEditorBot.clickVerifyButton() );
+        assertNull( pwdEditorBot.clickBindButton() );
+
+        // verify and bind with the wrong password
+        pwdEditorBot = entryEditorBot.editValueExpectingPasswordEditor( "userPassword",
+            "CRYPT-SHA-512 hashed password" );
+        pwdEditorBot.activateCurrentPasswordTab();
+        pwdEditorBot.setVerifyPassword( "Wrong Password" );
+        assertEquals( "Password verification failed", pwdEditorBot.clickVerifyButton() );
+        assertThat( pwdEditorBot.clickBindButton(), startsWith( "The authentication failed"
) );
+    }
+
+
+    private void assertHashMethod( PasswordEditorDialogBot passwordEditorBot, LdapSecurityConstants
hashMethod,
+        int passwordLength, int saltLength ) throws Exception
+    {
+        passwordEditorBot.selectHashMethod( hashMethod );
+
+        String preview = passwordEditorBot.getPasswordPreview();
+        assertThat( preview, startsWith( "{" + Strings.upperCase( hashMethod.getPrefix()
) + "}" ) );
+
+        String passwordHex = passwordEditorBot.getPasswordHex();
+        assertEquals( passwordLength * 2, passwordHex.length() );
+        assertTrue( passwordHex.matches( "[0-9a-f]{" + ( passwordLength * 2 ) + "}" ) );
+
+        String saltHex = passwordEditorBot.getSaltHex();
+        if ( saltLength > 0 )
+        {
+            assertEquals( saltLength * 2, saltHex.length() );
+            assertTrue( saltHex.matches( "[0-9a-f]{" + ( saltLength * 2 ) + "}" ) );
+        }
+        else
+        {
+            assertEquals( "-", saltHex );
+        }
+    }
+
 }

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java
Mon Feb 22 16:26:52 2016
@@ -22,6 +22,7 @@ package org.apache.directory.studio.test
 
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
 
 
 public abstract class DialogBot
@@ -42,4 +43,27 @@ public abstract class DialogBot
         button.click();
     }
 
+    protected String clickCheckButton( final String label, final String title )
+    {
+        SWTBotShell shell = BotUtils.shell( new Runnable()
+        {
+            public void run()
+            {
+                bot.button( label ).click();
+            }
+        }, "Error", title );
+
+        String shellText = shell.getText();
+        String labelText = bot.label( 1 ).getText(); // label(0) is the image
+        bot.button( "OK" ).click();
+
+        if ( shellText.equals( title ) )
+        {
+            return null;
+        }
+        else
+        {
+            return labelText;
+        }
+    }
 }

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java
Mon Feb 22 16:26:52 2016
@@ -101,6 +101,12 @@ public class EntryEditorBot
     }
 
 
+    public PasswordEditorDialogBot editValueExpectingPasswordEditor( String attributeType,
String value )
+    {
+        return editorBot.editValueExpectingPasswordEditor( attributeType, value );
+    }
+
+
     public void deleteValue( String attributeType, String value )
     {
         editorBot.deleteValue( attributeType, value );

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java
Mon Feb 22 16:26:52 2016
@@ -129,6 +129,13 @@ class EntryEditorWidgetBot
     }
 
 
+    PasswordEditorDialogBot editValueExpectingPasswordEditor( String attributeType, String
value )
+    {
+        editValue( attributeType, value );
+        return new PasswordEditorDialogBot();
+    }
+
+
     private SWTBotTreeItem getTreeItem( String attributeType, String value )
     {
         SWTBotTree tree = bot.tree();

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java
Mon Feb 22 16:26:52 2016
@@ -41,4 +41,11 @@ public class NewAttributeWizardBot exten
         return new DnEditorDialogBot();
     }
 
+
+    public PasswordEditorDialogBot clickFinishButtonExpectingPasswordEditor()
+    {
+        clickFinishButton();
+        return new PasswordEditorDialogBot();
+    }
+
 }

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java?rev=1731682&r1=1731681&r2=1731682&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java
Mon Feb 22 16:26:52 2016
@@ -257,7 +257,7 @@ public class NewConnectionWizardBot exte
      */
     public String clickCheckNetworkParameterButton()
     {
-        return clickCheckButton( CHECK_NETWORK_PARAMETER );
+        return clickCheckButton( CHECK_NETWORK_PARAMETER, CHECK_NETWORK_PARAMETER );
     }
 
 
@@ -279,7 +279,7 @@ public class NewConnectionWizardBot exte
      */
     public String clickCheckAuthenticationButton()
     {
-        return clickCheckButton( CHECK_AUTHENTICATION );
+        return clickCheckButton( CHECK_AUTHENTICATION, CHECK_AUTHENTICATION );
     }
 
 
@@ -294,31 +294,6 @@ public class NewConnectionWizardBot exte
     }
 
 
-    private String clickCheckButton( final String label )
-    {
-        SWTBotShell shell = BotUtils.shell( new Runnable()
-        {
-            public void run()
-            {
-                bot.button( label ).click();
-            }
-        }, "Error", label );
-
-        String shellText = shell.getText();
-        String labelText = bot.label( 1 ).getText(); // label(0) is the image
-        bot.button( "OK" ).click();
-
-        if ( shellText.equals( label ) )
-        {
-            return null;
-        }
-        else
-        {
-            return labelText;
-        }
-    }
-
-
     public boolean isNoEncryptionSelected()
     {
         SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );

Added: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java?rev=1731682&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
(added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
Mon Feb 22 16:26:52 2016
@@ -0,0 +1,119 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
+
+
+public class PasswordEditorDialogBot extends DialogBot
+{
+
+    public boolean isVisible()
+    {
+        return super.isVisible( "Password Editor" );
+    }
+
+
+    public void clickOkButton()
+    {
+        super.clickButton( "OK" );
+    }
+
+
+    public void clickCancelButton()
+    {
+        super.clickButton( "Cancel" );
+    }
+
+
+    public void setNewPassword1( String password )
+    {
+        bot.text( 0 ).setText( password );
+    }
+
+
+    public void setNewPassword2( String password )
+    {
+        bot.text( 1 ).setText( password );
+    }
+
+
+    public String getPasswordPreview()
+    {
+        return bot.text( 2 ).getText();
+    }
+
+
+    public void selectHashMethod( LdapSecurityConstants hashMethod )
+    {
+        bot.comboBox().setSelection( hashMethod.getName() );
+    }
+
+
+    public String getPasswordHex()
+    {
+        return bot.text( 3 ).getText();
+    }
+
+
+    public String getSaltHex()
+    {
+        return bot.text( 4 ).getText();
+    }
+
+
+    public void setShowNewPasswordDetails( boolean selected )
+    {
+        if ( selected )
+        {
+            bot.checkBox().select();
+        }
+        else
+        {
+            bot.checkBox().deselect();
+        }
+    }
+
+
+    public void activateCurrentPasswordTab()
+    {
+        bot.tabItem( "Current Password" ).activate();
+    }
+
+
+    public void setVerifyPassword( String password )
+    {
+        bot.text( 4 ).setText( password );
+    }
+
+
+    public String clickVerifyButton()
+    {
+        return clickCheckButton( "Verify", "Password Verification" );
+    }
+
+
+    public String clickBindButton()
+    {
+        return clickCheckButton( "Bind", "Check Authentication" );
+    }
+
+}

Propchange: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message