Package org.littleshoot.proxy

Examples of org.littleshoot.proxy.HttpProxyServer


        }
    }

    @Test
    public void testService1_httpProxy_directProxy() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("https://" + endpointUrl)
                            .endpointSecurity(securityContext)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here


        }
    }

    @Test
    public void testService1_httpProxy_noAuthentication() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("https://" + endpointUrl)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .endpointSecurity(securityContext)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testService1_httpProxy_basicAuthentication_success() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });
        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            final Security security = Security.builder()
                    .authBasic("tom", "007")
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder()
                            .endpointUri("https://" + endpointUrl)
                            .endpointSecurity(securityContext)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .proxySecurity(security)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

    @Test
    public void testService1_httpProxy_basicAuthentication_wrongKeystore_failure() throws Exception {
        exception.expect(SoapClientException.class);
        exception.expectMessage("peer not authenticated");

        HttpProxyServer proxyServer = initProxy();
        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });
        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlTwo())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            final Security security = Security.builder()
                    .authBasic("tom", "007")
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder()
                            .endpointUri("https://" + endpointUrl)
                            .endpointSecurity(securityContext)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .proxySecurity(security)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

    public void testService1_httpProxy_basicAuthentication_failure() throws Exception {

        exception.expect(TransmissionException.class);
        exception.expectMessage("[407]");

        HttpProxyServer proxyServer = initProxy();

        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });

        final Security props = Security.builder()
                .authBasic("james", "003")
                .build();

        try {
            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("https://" + endpointUrl)
                            .proxyUri("http://127.0.0.1:" + PROXY_PORT)
                            .proxySecurity(props)
                            .endpointSecurity(securityContext)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

    public void destroyServer() {
        server.stop();
    }

    public HttpProxyServer initProxy() {
        HttpProxyServer proxyServer = new DefaultHttpProxyServer(PROXY_PORT);
        proxyServer.start(true, true);
        return proxyServer;
    }
View Full Code Here

        return proxyServer;
    }

    @Test
    public void testService1_httpsProxy_defaultProxySetting() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testService1_httpsProxy_directProxy() throws Exception {
        HttpProxyServer proxyServer = initProxy();
        try {
            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .build();
                }
            });
        } finally {
            proxyServer.stop();
        }
    }
View Full Code Here

        KeyStore ks = readKeyStore(getKeyStoreUrlOne(), getKeyStorePassword(), "JKS");
        SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797);
        tunnel.start();

        HttpProxyServer proxyServer = initProxy();
        try {

            final Security securityContext = Security.builder()
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder().endpointUri("http://" + endpointUrl)
                            .proxyUri("https://127.0.0.1:" + 9898)
                            .proxySecurity(securityContext)
                            .build();
                }
            });
        } finally {
            tunnel.stop();
            proxyServer.stop();
        }
    }
View Full Code Here

        KeyStore ks = readKeyStore(getKeyStoreUrlOne(), getKeyStorePassword(), "JKS");
        SslTunnel tunnel = new SslTunnel(ks, getKeyStorePassword(), 9898, "localhost", 9797);
        tunnel.start();

        HttpProxyServer proxyServer = initProxy();
        proxyServer.addProxyAuthenticationHandler(new ProxyAuthorizationHandler() {
            @Override
            public boolean authenticate(String user, String pass) {
                return user.equals("tom") && pass.equals("007");
            }
        });
        try {

            final Security security = Security.builder()
                    .authBasic("tom", "007")
                    .trustStoreUrl(getKeyStoreUrlOne())
                    .trustStorePassword(getKeyStorePassword())
                    .build();

            verifyServiceBehavior(1, new ClientBuilder() {
                @Override
                public SoapClient buildClient(String endpointUrl) {
                    return SoapClient.builder()
                            .endpointUri("http://" + endpointUrl)
                            .proxyUri("https://127.0.0.1:" + 9898)
                            .proxySecurity(security)
                            .build();
                }
            });
        } finally {
            tunnel.stop();
            proxyServer.stop();
        }
    }
View Full Code Here

TOP

Related Classes of org.littleshoot.proxy.HttpProxyServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.