directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1769434 - in /directory/studio/trunk/tests/test.integration.ui/src/main: java/org/apache/directory/studio/test/integration/ui/ java/org/apache/directory/studio/test/integration/ui/bots/ resources/org/apache/directory/studio/test/integratio...
Date Sat, 12 Nov 2016 22:57:47 GMT
Author: seelmann
Date: Sat Nov 12 22:57:47 2016
New Revision: 1769434

URL: http://svn.apache.org/viewvc?rev=1769434&view=rev
Log:
Add first Kerberos/GSSAPI authentication test

Added:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
  (with props)
    directory/studio/trunk/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/GssApiTest.ldif
Modified:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.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/ApacheDSPluginTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java?rev=1769434&r1=1769433&r2=1769434&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java
Sat Nov 12 22:57:47 2016
@@ -246,7 +246,7 @@ public class ApacheDSPluginTest
     {
         ApacheDSConfigurationEditorBot editorBot = serversViewBot.openConfigurationEditor(
serverName );
 
-        editorBot.setAvailableLdapAndLdapsPort();
+        editorBot.setAvailablePorts();
 
         editorBot.save();
         editorBot.close();
@@ -348,7 +348,7 @@ public class ApacheDSPluginTest
         int oldLdapsPort = remoteEditorBot.getLdapsPort();
 
         // Set new ports
-        remoteEditorBot.setAvailableLdapAndLdapsPort();
+        remoteEditorBot.setAvailablePorts();
         int newLdapPort = remoteEditorBot.getLdapPort();
         int newLdapsPort = remoteEditorBot.getLdapsPort();
 

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java?rev=1769434&r1=1769433&r2=1769434&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java
Sat Nov 12 22:57:47 2016
@@ -776,7 +776,7 @@ public class CertificateValidationTest
     {
         ApacheDSConfigurationEditorBot editorBot = serversViewBot.openConfigurationEditor(
serverName );
 
-        editorBot.setAvailableLdapAndLdapsPort();
+        editorBot.setAvailablePorts();
         ldapPort = editorBot.getLdapPort();
         ldapsPort = editorBot.getLdapsPort();
 

Added: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java?rev=1769434&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
(added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
Sat Nov 12 22:57:47 2016
@@ -0,0 +1,236 @@
+/*
+ *  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;
+
+
+import static org.apache.directory.studio.test.integration.ui.Constants.LOCALHOST;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+
+import org.apache.directory.api.util.FileUtils;
+import org.apache.directory.api.util.IOUtils;
+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.BrowserViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.ConnectionsViewBot;
+import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.ImportWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewApacheDSServerWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
+import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.apache.directory.studio.test.integration.ui.bots.utils.FrameworkRunnerWithScreenshotCaptureListener;
+import org.eclipse.core.runtime.Platform;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Tests secure connection handling.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(FrameworkRunnerWithScreenshotCaptureListener.class)
+public class GssApiTest
+{
+    private static final String serverName = "GssApiTest";
+
+    @Rule
+    public TestName name = new TestName();
+
+    private static int ldapPort;
+    private static int kdcPort;
+
+    private static StudioBot studioBot;
+    private static ApacheDSServersViewBot serversViewBot;
+    private static ConnectionsViewBot connectionsViewBot;
+
+
+    @BeforeClass
+    public static void setUpClass() throws Exception
+    {
+        studioBot = new StudioBot();
+        studioBot.resetLdapPerspective();
+        serversViewBot = studioBot.getApacheDSServersViewBot();
+        connectionsViewBot = studioBot.getConnectionView();
+
+        // ErrorDialog.AUTOMATED_MODE = false;
+    }
+
+
+    @AfterClass
+    public static void tearDownClass() throws Exception
+    {
+        deleteServer( serverName );
+    }
+
+
+    @Before
+    public void setUp() throws Exception
+    {
+        studioBot.resetLdapPerspective();
+    }
+
+
+    @After
+    public void tearDown() throws Exception
+    {
+        connectionsViewBot.deleteTestConnections();
+
+        // stop ApacheDS
+        serversViewBot.stopServer( serverName );
+        serversViewBot.waitForServerStop( serverName );
+    }
+
+
+    private String getConnectionName()
+    {
+        return "GssApiTest." + name.getMethodName();
+    }
+
+
+    @Test
+    public void testGssApiObtainTgtAndObtainServiceTicket() throws Exception
+    {
+        // create the server
+        createServer( serverName );
+
+        // configure ApacheDS and KDC server
+        configureApacheDS( serverName );
+
+        // start ApacheDS
+        serversViewBot.runServer( serverName );
+        serversViewBot.waitForServerStart( serverName );
+
+        // import KDC data
+        connectionsViewBot.createTestConnection( "GssApiTest", ldapPort );
+        importData();
+
+        // restart ApacheDS
+        // serversViewBot.stopServer( serverName );
+        // serversViewBot.waitForServerStop( serverName );
+        // serversViewBot.runServer( serverName );
+        // serversViewBot.waitForServerStart( serverName );
+
+        // connect with GSSAPI authentication
+        NewConnectionWizardBot wizardBot = connectionsViewBot.openNewConnectionWizard();
+        wizardBot.typeConnectionName( getConnectionName() );
+        wizardBot.typeHost( LOCALHOST );
+        wizardBot.typePort( ldapPort );
+        wizardBot.clickNextButton();
+        wizardBot.selectGssApiAuthentication();
+        wizardBot.selectObtainTgtFromKdc();
+        wizardBot.typeUser( "hnelson" );
+        wizardBot.typePassword( "secret" );
+        wizardBot.selectUseManualConfiguration();
+        wizardBot.typeKerberosRealm( "EXAMPLE.COM" );
+        wizardBot.typeKdcHost( LOCALHOST );
+        wizardBot.typeKdcPort( kdcPort );
+
+        // check the connection
+        String result = wizardBot.clickCheckAuthenticationButton();
+        assertNull( "Expected OK", result );
+
+        wizardBot.clickCancelButton();
+    }
+
+
+    private static void createServer( String serverName )
+    {
+        // Showing view
+        serversViewBot.show();
+
+        // Opening wizard
+        NewApacheDSServerWizardBot wizardBot = serversViewBot.openNewServerWizard();
+
+        // Filling fields of the wizard
+        wizardBot.selectApacheDS200();
+        wizardBot.typeServerName( serverName );
+
+        // Closing wizard
+        wizardBot.clickFinishButton();
+        serversViewBot.waitForServer( serverName );
+    }
+
+
+    private static void configureApacheDS( String serverName ) throws Exception
+    {
+        ApacheDSConfigurationEditorBot editorBot = serversViewBot.openConfigurationEditor(
serverName );
+
+        editorBot.enableKerberosServer();
+
+        editorBot.setAvailablePorts();
+        ldapPort = editorBot.getLdapPort();
+        kdcPort = editorBot.getKerberosPort();
+
+        editorBot.setKdcRealm( "EXAMPLE.COM" );
+        editorBot.setKdcSearchBase( "dc=security,dc=example,dc=com" );
+
+        editorBot.setSaslHost( Constants.LOCALHOST );
+        editorBot.setSaslPrincipal( "ldap/" + Constants.LOCALHOST + "@EXAMPLE.COM" );
+        editorBot.setSaslSearchBase( "dc=security,dc=example,dc=com" );
+
+        editorBot.save();
+        editorBot.close();
+    }
+
+
+    private void importData() throws IOException
+    {
+        URL url = Platform.getInstanceLocation().getURL();
+        String destFile = url.getFile() + "GssApiTest.ldif";
+        InputStream is = getClass().getResourceAsStream( "GssApiTest.ldif" );
+        String ldifContent = IOUtils.toString( is, StandardCharsets.UTF_8 );
+        ldifContent = ldifContent.replace( "HOSTNAME", Constants.LOCALHOST );
+        FileUtils.writeStringToFile( new File( destFile ), ldifContent, StandardCharsets.UTF_8,
false );
+
+        BrowserViewBot browserViewBot = studioBot.getBrowserView();
+        browserViewBot.selectEntry( "DIT", "Root DSE", "dc=example,dc=com" );
+        ImportWizardBot importWizardBot = browserViewBot.openImportLdifWizard();
+        importWizardBot.typeFile( destFile );
+        importWizardBot.clickFinishButton();
+        browserViewBot.waitForEntry( "DIT", "Root DSE", "dc=example,dc=com", "dc=security"
);
+    }
+
+
+    private static void deleteServer( String serverName )
+    {
+        // Stopping the server
+        serversViewBot.stopServer( serverName );
+        serversViewBot.waitForServerStop( serverName );
+
+        // Deleting the server
+        DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
+        deleteDialogBot.clickOkButton();
+    }
+
+}

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

Modified: directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.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/ApacheDSConfigurationEditorBot.java?rev=1769434&r1=1769433&r2=1769434&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.java
Sat Nov 12 22:57:47 2016
@@ -55,51 +55,142 @@ public class ApacheDSConfigurationEditor
     }
 
 
-    public void setAvailableLdapAndLdapsPort()
+    public void setAvailablePorts()
     {
-        int ldapPort = AvailablePortFinder.getNextAvailable( 1024 );
-        setLdapPort( ldapPort );
-        int ldapsPort = AvailablePortFinder.getNextAvailable( getLdapPort() + 1 );
-        setLdapsPort( ldapsPort );
+        int port = 1023;
+
+        if ( isLdapServerEnabled() )
+        {
+            port = AvailablePortFinder.getNextAvailable( port + 1 );
+            setLdapPort( port );
+        }
+        if ( isLdapsServerEnabled() )
+        {
+            port = AvailablePortFinder.getNextAvailable( port + 1 );
+            setLdapsPort( port );
+        }
+        if ( isKerberosServerEnabled() )
+        {
+            port = AvailablePortFinder.getNextAvailable( port + 1 );
+            setKerberosPort( port );
+        }
+
+    }
+
+
+    public boolean isLdapServerEnabled()
+    {
+        activateLdapLdapsServersPage();
+        return editor.bot().checkBox( 0 ).isChecked();
     }
 
 
     public void setLdapPort( int port )
     {
-        editor.activatePage( "LDAP/LDAPS Servers" );
+        activateLdapLdapsServersPage();
         editor.bot().text( 0 ).setText( "" + port );
     }
 
 
     public int getLdapPort()
     {
-        editor.activatePage( "LDAP/LDAPS Servers" );
+        activateLdapLdapsServersPage();
         return Integer.parseInt( editor.bot().text( 0 ).getText() );
     }
 
 
+    public boolean isLdapsServerEnabled()
+    {
+        activateLdapLdapsServersPage();
+        return editor.bot().checkBox( 1 ).isChecked();
+    }
+
+
     public void setLdapsPort( int port )
     {
-        editor.activatePage( "LDAP/LDAPS Servers" );
+        activateLdapLdapsServersPage();
         editor.bot().text( 4 ).setText( "" + port );
     }
 
 
     public int getLdapsPort()
     {
-        editor.activatePage( "LDAP/LDAPS Servers" );
+        activateLdapLdapsServersPage();
         return Integer.parseInt( editor.bot().text( 4 ).getText() );
     }
 
 
     public void setKeystore( String keyStoreFilePath, String keyStorePassword )
     {
-        editor.activatePage( "LDAP/LDAPS Servers" );
+        activateLdapLdapsServersPage();
         editor.bot().text( 11 ).setText( keyStoreFilePath );
         editor.bot().text( 12 ).setText( keyStorePassword );
     }
 
 
+    public void setSaslHost( String saslHost )
+    {
+        activateLdapLdapsServersPage();
+        editor.bot().text( 17 ).setText( saslHost );
+    }
+
+
+    public void setSaslPrincipal( String saslPrincipal )
+    {
+        activateLdapLdapsServersPage();
+        editor.bot().text( 18 ).setText( saslPrincipal );
+    }
+
+
+    public void setSaslSearchBase( String saslSearchBase )
+    {
+        activateLdapLdapsServersPage();
+        editor.bot().text( 19 ).setText( saslSearchBase );
+    }
+
+
+    public void enableKerberosServer()
+    {
+        activateKerberosServerPage();
+        editor.bot().checkBox( 0 ).select();
+    }
+
+
+    public boolean isKerberosServerEnabled()
+    {
+        activateKerberosServerPage();
+        return editor.bot().checkBox( 0 ).isChecked();
+    }
+
+
+    public void setKerberosPort( int port )
+    {
+        activateKerberosServerPage();
+        editor.bot().text( 0 ).setText( "" + port );
+    }
+
+
+    public int getKerberosPort()
+    {
+        activateKerberosServerPage();
+        return Integer.parseInt( editor.bot().text( 0 ).getText() );
+    }
+
+
+    public void setKdcRealm( String kdcRealm )
+    {
+        activateKerberosServerPage();
+        editor.bot().text( 4 ).setText( kdcRealm );
+    }
+
+
+    public void setKdcSearchBase( String kdcSearchBase )
+    {
+        activateKerberosServerPage();
+        editor.bot().text( 5 ).setText( kdcSearchBase );
+    }
+
+
     public void save()
     {
         editor.save();
@@ -112,4 +203,15 @@ public class ApacheDSConfigurationEditor
     }
 
 
+    private void activateLdapLdapsServersPage()
+    {
+        editor.activatePage( "LDAP/LDAPS Servers" );
+    }
+
+
+    private void activateKerberosServerPage()
+    {
+        editor.activatePage( "Kerberos Server" );
+    }
+
 }

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=1769434&r1=1769433&r2=1769434&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
Sat Nov 12 22:57:47 2016
@@ -303,18 +303,36 @@ public class NewConnectionWizardBot exte
     }
 
 
+    public void typeKerberosRealm( String realm )
+    {
+        bot.textWithLabel( KERBEROS_REALM ).setText( realm );
+    }
+
+
     public boolean isKdcHostEnabled()
     {
         return bot.textWithLabel( KDC_HOST ).isEnabled();
     }
 
 
+    public void typeKdcHost( String host )
+    {
+        bot.textWithLabel( KDC_HOST ).setText( host );
+    }
+
+
     public boolean isKdcPortEnabled()
     {
         return bot.textWithLabel( KDC_PORT ).isEnabled();
     }
 
 
+    public void typeKdcPort( int port )
+    {
+        bot.textWithLabel( KDC_PORT ).setText( Integer.toString( port ) );
+    }
+
+
     public boolean isGetBaseDnsFromRootDseEnabled()
     {
         return bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).isEnabled();

Added: directory/studio/trunk/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/GssApiTest.ldif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/GssApiTest.ldif?rev=1769434&view=auto
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/GssApiTest.ldif
(added)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/resources/org/apache/directory/studio/test/integration/ui/GssApiTest.ldif
Sat Nov 12 22:57:47 2016
@@ -0,0 +1,52 @@
+dn: dc=security,dc=example,dc=com
+objectClass: top
+objectClass: domain
+dc: security
+
+dn: ou=services,dc=security,dc=example,dc=com
+objectClass: top
+objectClass: organizationalUnit
+ou: services
+
+dn: ou=users,dc=security,dc=example,dc=com
+objectClass: top
+objectClass: organizationalUnit
+ou: users
+
+dn: uid=hnelson,ou=users,dc=security,dc=example,dc=com
+objectClass: top
+objectClass: krb5KDCEntry
+objectClass: inetOrgPerson
+objectClass: krb5Principal
+objectClass: person
+objectClass: organizationalPerson
+cn: Horatio Nelson
+krb5KeyVersionNumber: 1
+krb5PrincipalName: hnelson@EXAMPLE.COM
+sn: Nelson
+uid: hnelson
+userPassword: secret
+
+dn: uid=ldap,ou=services,dc=security,dc=example,dc=com
+objectClass: top
+objectClass: organizationalUnit
+objectClass: krb5KDCEntry
+objectClass: uidObject
+objectClass: krb5Principal
+krb5KeyVersionNumber: 0
+krb5PrincipalName: ldap/HOSTNAME@EXAMPLE.COM
+uid: ldap
+userPassword: randomKey
+ou: ldap
+
+dn: uid=krbtgt,ou=services,dc=security,dc=example,dc=com
+objectClass: top
+objectClass: organizationalUnit
+objectClass: krb5KDCEntry
+objectClass: uidObject
+objectClass: krb5Principal
+krb5KeyVersionNumber: 0
+krb5PrincipalName: krbtgt/EXAMPLE.COM@EXAMPLE.COM
+uid: krbtgt
+userPassword:: randomkey
+ou: krbtgt



Mime
View raw message