[Jboss-cvs] JBossAS SVN: r55386 - trunk/testsuite/src/main/org/jboss/test/web/test/ssl

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 7 17:30:18 EDT 2006


Author: anil.saldhana at jboss.com
Date: 2006-08-07 17:30:18 -0400 (Mon, 07 Aug 2006)
New Revision: 55386

Modified:
   trunk/testsuite/src/main/org/jboss/test/web/test/ssl/SSLUnitTestCase.java
Log:
JBAS-3369:encrypt keystore pass and sync with Branch_4_0

Modified: trunk/testsuite/src/main/org/jboss/test/web/test/ssl/SSLUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/web/test/ssl/SSLUnitTestCase.java	2006-08-07 21:25:41 UTC (rev 55385)
+++ trunk/testsuite/src/main/org/jboss/test/web/test/ssl/SSLUnitTestCase.java	2006-08-07 21:30:18 UTC (rev 55386)
@@ -1,64 +1,112 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
 package org.jboss.test.web.test.ssl;
 
 import java.net.HttpURLConnection;
 
-import org.apache.commons.httpclient.Cookie;
+import junit.framework.Test;
 import org.apache.commons.httpclient.Header;
 import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.jboss.test.JBossTestCase;
-import org.jboss.test.JBossTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
 
 /** Tests of ssl and CLIENT-CERT auth
  * 
  * @author Scott.Stark at jboss.org
+ * @author Anil.Saldhana at jboss.org
  * @version $Revision$
  */
 public class SSLUnitTestCase extends JBossTestCase
 {
-   private String baseHttpNoAuth = "http://localhost:" + Integer.getInteger("web.port", 8080) + "/"; 
-   private String baseHttpsNoAuth = "https://localhost:" + Integer.getInteger("web.port", 8443) + "/"; 
+   private String baseHttpNoAuth = "http://" + getServerHost() + ":" + Integer.getInteger("web.port", 8080) + "/"; 
+   private String baseHttpsNoAuth = "https://" + getServerHost() + ":" + Integer.getInteger("secureweb.port", 8443) + "/"; 
 
    public SSLUnitTestCase(String name)
    {
       super(name);
    }
 
-   /** Test that access of the transport constrained 
+   /** Test that access of the transport constrained redirects to the ssl connector
     * 
     * @throws Exception
     */ 
    public void testHttpRedirect() throws Exception
    {
       log.info("+++ testHttpRedirect");
+      doHttpRedirect(baseHttpNoAuth);
+   }
+   /** Test that access of the transport constrained redirects to the ssl connector
+    * when using the SecurityDomain based connector config.
+    * 
+    * @throws Exception
+    */ 
+   public void testHttpRedirectSecurityDomain() throws Exception
+   {
+      log.info("+++ testHttpRedirectSecurityDomain");
+      int port = Integer.getInteger("web.port", 8080).intValue();
+      port += 1000;
+      String httpNoAuth = "http://" + getServerHost() + ":" + port + "/";
+      doHttpRedirect(httpNoAuth);
+   }
+
+   /** Test that access of the transport constrained 
+    * 
+    * @throws Exception
+    */ 
+   public void testHttps() throws Exception
+   {
+      log.info("+++ testHttps");
+      doHttps(baseHttpsNoAuth);
+   }
+   
+   public void testHttpsSecurityDomain() throws Exception
+   {
+      log.info("+++ testHttps");
+      int port = Integer.getInteger("secureweb.port", 8443).intValue();
+      port += 1000;
+      String httpsNoAuth = "https://" + getServerHost() + ":" + port + "/";
+      doHttps(httpsNoAuth);
+   }
+   
+   /**
+    * Test masking of Keystore password via encryption
+    * @throws Exception
+    */
+   public void testEncryptPassword() throws Exception
+   {
+      log.info("+++ testHttps");
+      int port = Integer.getInteger("secureweb.port", 8443).intValue();
+      port += 1500;
+      String httpsNoAuth = "https://" + getServerHost() + ":" + port + "/";
+      doHttps(httpsNoAuth);
+   }
+   
+
+   private void doHttpRedirect(String httpNoAuth) throws Exception
+   {
+      log.info("+++ testHttpRedirect, httpNoAuth="+httpNoAuth);
       // Start by accessing the secured index.html of war1
       HttpClient httpConn = new HttpClient();
-      String url = baseHttpNoAuth+"clientcert-auth/unrestricted/SecureServlet";
+      String url = httpNoAuth+"clientcert-auth/unrestricted/SecureServlet";
       log.info("Accessing: "+url);
       GetMethod get = new GetMethod(url);
       int responseCode = httpConn.executeMethod(get);
@@ -74,25 +122,20 @@
       log.debug(status);
       assertTrue("Get OK("+responseCode+")", responseCode == HttpURLConnection.HTTP_OK);
    }
-
-   /** Test that access of the transport constrained 
-    * 
-    * @throws Exception
-    */ 
-   public void testHttps() throws Exception
+   public void doHttps(String httpsNoAuth) throws Exception
    {
-      log.info("+++ testHttps");
+      log.info("+++ doHttps, httpsNoAuth="+httpsNoAuth);
       // Start by accessing the secured index.html of war1
       HttpClient httpConn = new HttpClient();
-      String url = baseHttpsNoAuth+"clientcert-auth/unrestricted/SecureServlet";
+      String url = httpsNoAuth+"clientcert-auth/unrestricted/SecureServlet";
       log.info("Accessing: "+url);
       GetMethod get = new GetMethod(url);
       int responseCode = httpConn.executeMethod(get);
       String status = get.getStatusText();
       log.debug(status);
       assertTrue("Get OK("+responseCode+")", responseCode == HttpURLConnection.HTTP_OK);
-   }
-
+   } 
+   
    /** One time setup for all SingleSignOnUnitTestCase unit tests
     */
    public static Test suite() throws Exception




More information about the jboss-cvs-commits mailing list