[1/3] cxf git commit: Adding Jetty programmatic tests
Repository: cxf Updated Branches: refs/heads/3.1.x-fixes e24153bd6 -> 398a4988b Adding Jetty programmatic tests # Conflicts: # systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/2f219d0c Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/2f219d0c Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/2f219d0c Branch: refs/heads/3.1.x-fixes Commit: 2f219d0c7258b33cb72d49d19bfd991a2ef3264a Parents: e24153b Author: Colm O hEigeartaigh Authored: Thu Mar 30 10:03:17 2017 +0100 Committer: Colm O hEigeartaigh Committed: Thu Mar 30 10:04:41 2017 +0100 -- .../systest/https/trust/TrustManagerTest.java | 116 +++ .../https/trust/TrustServerNoSpring.java| 84 ++ 2 files changed, 200 insertions(+) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/2f219d0c/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java -- diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java index 6264f44..89e6b89 100644 --- a/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java +++ b/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java @@ -43,7 +43,13 @@ import org.junit.BeforeClass; */ public class TrustManagerTest extends AbstractBusClientServerTestBase { static final String PORT = allocatePort(TrustServer.class); +<<< HEAD +=== +static final String PORT2 = allocatePort(TrustServer.class, 2); +static final String PORT3 = allocatePort(TrustServer.class, 3); + +>>> 16163d8... Adding Jetty programmatic tests @BeforeClass public static void startServers() throws Exception { assertTrue( @@ -52,6 +58,12 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { // set this to false to fork launchServer(TrustServer.class, true) ); +assertTrue( + "Server failed to launch", + // run the server in the same process + // set this to false to fork + launchServer(TrustServerNoSpring.class, true) +); } @AfterClass @@ -131,7 +143,50 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { ((java.io.Closeable)port).close(); bus.shutdown(true); } +<<< HEAD +=== + +// Here the Trust Manager checks the server cert. this time we are invoking on the +// service that is configured in code (not by spring) +@org.junit.Test +public void testValidServerCertX509TrustManager2() throws Exception { +SpringBusFactory bf = new SpringBusFactory(); +URL busFile = TrustManagerTest.class.getResource("client-trust.xml"); + +Bus bus = bf.createBus(busFile.toString()); +SpringBusFactory.setDefaultBus(bus); +SpringBusFactory.setThreadDefaultBus(bus); + +URL url = SOAPService.WSDL_LOCATION; +SOAPService service = new SOAPService(url, SOAPService.SERVICE); +assertNotNull("Service is null", service); +final Greeter port = service.getHttpsPort(); +assertNotNull("Port is null", port); + +updateAddressPort(port, PORT3); + +String validPrincipalName = "CN=Bethal,OU=Bethal,O=ApacheTest,L=Syracuse,C=US"; + +TLSClientParameters tlsParams = new TLSClientParameters(); +X509TrustManager trustManager = +new ServerCertX509TrustManager(validPrincipalName); +TrustManager[] trustManagers = new TrustManager[1]; +trustManagers[0] = trustManager; +tlsParams.setTrustManagers(trustManagers); +tlsParams.setDisableCNCheck(true); + +Client client = ClientProxy.getClient(port); +HTTPConduit http = (HTTPConduit) client.getConduit(); +http.setTlsClientParameters(tlsParams); + +assertEquals(port.greetMe("Kitty"), "Hello Kitty"); + +((java.io.Closeable)port).close(); +bus.shutdown(true); +} + +>>> 16163d8... Adding Jetty programmatic tests @org.junit.Test public void testInvalidServerCertX509TrustManager() throws Exception { SpringBusFactory bf = new SpringBusFactory(); @@ -169,7 +224,68 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { } catch (Exception ex) { // expected } +<<< HEAD +=== + +((java.io.Closeable)port).close(); +bus.shutdown(true); +} + +@org.junit.Te
cxf git commit: Adding Jetty programmatic tests
Repository: cxf Updated Branches: refs/heads/master 1d1b318e5 -> 16163d804 Adding Jetty programmatic tests Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/16163d80 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/16163d80 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/16163d80 Branch: refs/heads/master Commit: 16163d8044be801683d1fb2d2d44507f43be2d6a Parents: 1d1b318 Author: Colm O hEigeartaigh Authored: Thu Mar 30 10:03:17 2017 +0100 Committer: Colm O hEigeartaigh Committed: Thu Mar 30 10:03:17 2017 +0100 -- .../systest/https/trust/TrustManagerTest.java | 64 --- .../https/trust/TrustServerNoSpring.java| 84 2 files changed, 139 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/cxf/blob/16163d80/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java -- diff --git a/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java b/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java index a2b9fa6..cc5ba7d 100644 --- a/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java +++ b/systests/transports/src/test/java/org/apache/cxf/systest/https/trust/TrustManagerTest.java @@ -52,6 +52,7 @@ import org.junit.BeforeClass; public class TrustManagerTest extends AbstractBusClientServerTestBase { static final String PORT = allocatePort(TrustServer.class); static final String PORT2 = allocatePort(TrustServer.class, 2); +static final String PORT3 = allocatePort(TrustServer.class, 3); @BeforeClass public static void startServers() throws Exception { @@ -61,6 +62,12 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { // set this to false to fork launchServer(TrustServer.class, true) ); +assertTrue( + "Server failed to launch", + // run the server in the same process + // set this to false to fork + launchServer(TrustServerNoSpring.class, true) +); } @AfterClass @@ -141,6 +148,45 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { bus.shutdown(true); } +// Here the Trust Manager checks the server cert. this time we are invoking on the +// service that is configured in code (not by spring) +@org.junit.Test +public void testValidServerCertX509TrustManager2() throws Exception { +SpringBusFactory bf = new SpringBusFactory(); +URL busFile = TrustManagerTest.class.getResource("client-trust.xml"); + +Bus bus = bf.createBus(busFile.toString()); +SpringBusFactory.setDefaultBus(bus); +SpringBusFactory.setThreadDefaultBus(bus); + +URL url = SOAPService.WSDL_LOCATION; +SOAPService service = new SOAPService(url, SOAPService.SERVICE); +assertNotNull("Service is null", service); +final Greeter port = service.getHttpsPort(); +assertNotNull("Port is null", port); + +updateAddressPort(port, PORT3); + +String validPrincipalName = "CN=Bethal,OU=Bethal,O=ApacheTest,L=Syracuse,C=US"; + +TLSClientParameters tlsParams = new TLSClientParameters(); +X509TrustManager trustManager = +new ServerCertX509TrustManager(validPrincipalName); +TrustManager[] trustManagers = new TrustManager[1]; +trustManagers[0] = trustManager; +tlsParams.setTrustManagers(trustManagers); +tlsParams.setDisableCNCheck(true); + +Client client = ClientProxy.getClient(port); +HTTPConduit http = (HTTPConduit) client.getConduit(); +http.setTlsClientParameters(tlsParams); + +assertEquals(port.greetMe("Kitty"), "Hello Kitty"); + +((java.io.Closeable)port).close(); +bus.shutdown(true); +} + @org.junit.Test public void testInvalidServerCertX509TrustManager() throws Exception { SpringBusFactory bf = new SpringBusFactory(); @@ -182,7 +228,7 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { ((java.io.Closeable)port).close(); bus.shutdown(true); } - + @org.junit.Test public void testOSCPOverride() throws Exception { SpringBusFactory bf = new SpringBusFactory(); @@ -206,36 +252,36 @@ public class TrustManagerTest extends AbstractBusClientServerTestBase { ClassLoaderUtils.getResourceAsStream("keys/cxfca.jks", TrustManagerTest.class)) { ts.load(trustStore, "password".toCharArray()); } - + try { Security.setProperty("ocsp.ena