[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/transport/http/ssl/config ...

Ron Sigal ron_sigal at yahoo.com
Mon Nov 13 13:10:16 EST 2006


  User: rsigal  
  Date: 06/11/13 13:10:16

  Modified:    src/tests/org/jboss/test/remoting/transport/http/ssl/config 
                        HostnameVerifierTestCase.java
  Log:
  JBREM-525:  Added two unit tests for using AnyHostVerifier if authentication is turned off on client side.
  
  Revision  Changes    Path
  1.5       +120 -19   JBossRemoting/src/tests/org/jboss/test/remoting/transport/http/ssl/config/HostnameVerifierTestCase.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HostnameVerifierTestCase.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/transport/http/ssl/config/HostnameVerifierTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -b -r1.4 -r1.5
  --- HostnameVerifierTestCase.java	12 Jul 2006 04:49:52 -0000	1.4
  +++ HostnameVerifierTestCase.java	13 Nov 2006 18:10:16 -0000	1.5
  @@ -60,8 +60,6 @@
      {
         try
         {
  -         if (connector == null)
  -         {
               // Register subclassed transport for test.
               InvokerRegistry.registerInvokerFactories(getTransport(),
                                               TestClientInvokerFactory.class,
  @@ -69,11 +67,26 @@
               
               HashMap config = new HashMap();
               
  +         if ("testServerModeAuthenticationOff".equals(getName()))
  +         {
  +            // Put ServerSocket in client mode with authorization turned on.
  +            config.put(SSLSocketBuilder.REMOTING_SERVER_SOCKET_USE_CLIENT_MODE, "true");
  +            config.put(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_NEED);
  +            
  +            // Put SSL truststore parameters in config map.
  +            config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
  +            String trustStoreFilePath = getClass().getResource("../.truststore").getFile();
  +            config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
  +            config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
  +         }
  +         else
  +         {
               // Put SSL keystore parameters in config map.
               config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS");
               String keyStoreFilePath = getClass().getResource("../.keystore").getFile();
               config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
               config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
  +         }
               
               // Make callback Client use remote invoker.
               config.put(InvokerLocator.FORCE_REMOTE, "true");
  @@ -86,7 +99,6 @@
               connector.addInvocationHandler("sample", new SampleInvocationHandler());
               connector.start();
            }
  -      }
         catch (Exception e)
         {
            log.error(e);
  @@ -285,6 +297,95 @@
      }
      
      
  +   public void testClientModeAuthenticationOff()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         HashMap config = new HashMap();
  +         
  +         // Make Client use remote invoker.
  +         config.put(InvokerLocator.FORCE_REMOTE, "true");
  +         
  +         // Put SSL truststore parameters in config map.
  +         config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
  +         String trustStoreFilePath =  getClass().getResource("../.truststore").getFile();
  +         config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
  +         config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
  +         
  +         // Turn off server authentication for sockets in client mode.
  +         config.put(SSLSocketBuilder.REMOTING_SERVER_AUTH_MODE, "false");
  +         
  +         // Connect Client and make invocation.
  +         Client client = new Client(locator, config);
  +         client.connect();
  +         client.invoke("abc");
  +         
  +         // Verify AnyhostVerifier was used.
  +         ClientInvoker clientInvoker = client.getInvoker();
  +         assertTrue(clientInvoker instanceof TestClientInvoker);
  +         TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker;
  +         Class[] classes = HTTPSClientInvoker.class.getDeclaredClasses();
  +         String anyhostVerifyClassName = classes[0].getName();
  +         assertEquals(anyhostVerifyClassName, testClientInvoker.getHostnameVerifierClassName());
  +         
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable t)
  +      {
  +         log.error(t);
  +         t.printStackTrace();
  +         log.info(getName() + " FAILS");
  +         fail();
  +      }
  +   }
  +   
  +   
  +   public void testServerModeAuthenticationOff()
  +   {
  +      log.info("entering " + getName());
  +      try
  +      {
  +         HashMap config = new HashMap();
  +         
  +         // Make Client use remote invoker.
  +         config.put(InvokerLocator.FORCE_REMOTE, "true");
  +         
  +         // Put SSL keystore parameters in config map.
  +         config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS");
  +         String keyStoreFilePath =  getClass().getResource("../.keystore").getFile();
  +         config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
  +         config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
  +         
  +         // Turn off server authentication for sockets in server mode.
  +         config.put(SSLSocketBuilder.REMOTING_SOCKET_USE_CLIENT_MODE, "false");
  +         config.put(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_NONE);
  +         
  +         // Connect Client and make invocation.
  +         Client client = new Client(locator, config);
  +         client.connect();
  +         client.invoke("abc");
  +         
  +         // Verify AnyhostVerifier was used.
  +         ClientInvoker clientInvoker = client.getInvoker();
  +         assertTrue(clientInvoker instanceof TestClientInvoker);
  +         TestClientInvoker testClientInvoker = (TestClientInvoker) clientInvoker;
  +         Class[] classes = HTTPSClientInvoker.class.getDeclaredClasses();
  +         String anyhostVerifyClassName = classes[0].getName();
  +         assertEquals(anyhostVerifyClassName, testClientInvoker.getHostnameVerifierClassName());
  +         
  +         log.info(getName() + " PASSES");
  +      }
  +      catch (Throwable t)
  +      {
  +         log.error(t);
  +         t.printStackTrace();
  +         log.info(getName() + " FAILS");
  +         fail();
  +      }
  +   }
  +   
  +   
      public void testZZZ()
      {
      }
  
  
  



More information about the jboss-cvs-commits mailing list