directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1770069 - /directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
Date Wed, 16 Nov 2016 23:03:27 GMT
Author: seelmann
Date: Wed Nov 16 23:03:27 2016
New Revision: 1770069

URL: http://svn.apache.org/viewvc?rev=1770069&view=rev
Log:
Skip GSSAPI test if no default realm is defined (improvement)

Modified:
    directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java

Modified: 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=1770069&r1=1770068&r2=1770069&view=diff
==============================================================================
--- directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
(original)
+++ directory/studio/trunk/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/GssApiTest.java
Wed Nov 16 23:03:27 2016
@@ -30,6 +30,8 @@ import java.io.InputStream;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 
+import javax.security.auth.kerberos.KerberosPrincipal;
+
 import org.apache.directory.api.util.FileUtils;
 import org.apache.directory.api.util.IOUtils;
 import org.apache.directory.studio.test.integration.ui.bots.ApacheDSConfigurationEditorBot;
@@ -52,8 +54,6 @@ import org.junit.Test;
 import org.junit.rules.TestName;
 import org.junit.runner.RunWith;
 
-import sun.security.krb5.Config;
-
 
 /**
  * Tests secure connection handling.
@@ -96,6 +96,25 @@ public class GssApiTest
     }
 
 
+    @BeforeClass
+    public static void skipGssApiTestIfNoDefaultRealmIsConfigured()
+    {
+        try
+        {
+            /*
+             * When creating a KerberosPrincipial without realm the default realm is looked
up.
+             * If no default realm is defined (e.g. as not /etc/krb5.conf exists) an exception
is throws.
+             * The test is skipped in that case as it won't succeed anyway. 
+             */
+            new KerberosPrincipal( "hnelson" );
+        }
+        catch ( IllegalArgumentException e )
+        {
+            Assume.assumeNoException( "Sipping tests as not default realm (/etc/krb5.conf)
is configured", e );
+        }
+    }
+
+
     @After
     public void tearDown() throws Exception
     {
@@ -104,6 +123,10 @@ public class GssApiTest
         // stop ApacheDS
         serversViewBot.stopServer( serverName );
         serversViewBot.waitForServerStop( serverName );
+
+        // delete ApacheDS
+        DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
+        deleteDialogBot.clickOkButton();
     }
 
 
@@ -119,15 +142,6 @@ public class GssApiTest
         // create the server
         createServer( serverName );
 
-        try
-        {
-            Config.getInstance().getDefaultRealm();
-        }
-        catch ( Exception e )
-        {
-            Assume.assumeNoException( "Skipping tests as not default realm (/etc/krb5.conf)
is configured", e );
-        }
-
         // configure ApacheDS and KDC server
         configureApacheDS( serverName );
 
@@ -165,8 +179,6 @@ public class GssApiTest
         assertNull( "Expected OK", result );
 
         wizardBot.clickCancelButton();
-
-        deleteServer( serverName );
     }
 
 
@@ -227,16 +239,4 @@ public class GssApiTest
         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();
-    }
-
 }



Mime
View raw message