Search in sources :

Example 1 with ProxyIgnore

use of io.undertow.testutils.ProxyIgnore in project undertow by undertow-io.

the class SimpleConfidentialRedirectTestCase method testRedirectWithFullURLInPath.

@ProxyIgnore
public void testRedirectWithFullURLInPath() throws IOException {
    DefaultServer.isProxy();
    //see UNDERTOW-874
    try (Socket socket = new Socket(DefaultServer.getHostAddress(), DefaultServer.getHostPort())) {
        socket.getOutputStream().write(("GET " + DefaultServer.getDefaultServerURL() + "/foo HTTP/1.0\r\n\r\n").getBytes(StandardCharsets.UTF_8));
        String result = FileUtils.readFile(socket.getInputStream());
        Assert.assertTrue(result.contains("Location: " + DefaultServer.getDefaultServerSSLAddress() + "/foo"));
    }
}
Also used : HttpString(io.undertow.util.HttpString) Socket(java.net.Socket) ProxyIgnore(io.undertow.testutils.ProxyIgnore)

Example 2 with ProxyIgnore

use of io.undertow.testutils.ProxyIgnore in project undertow by undertow-io.

the class WebSocketClient13TestCase method testMessageViaWssProxy.

@Test
@ProxyIgnore
public void testMessageViaWssProxy() throws Exception {
    final WebSocketChannel webSocketChannel = WebSocketClient.connectionBuilder(worker, DefaultServer.getBufferPool(), new URI(DefaultServer.getDefaultServerSSLAddress())).setSsl(new UndertowXnioSsl(Xnio.getInstance(), OptionMap.EMPTY, DefaultServer.getClientSSLContext())).setProxyUri(new URI("http", null, DefaultServer.getHostAddress("default"), DefaultServer.getHostPort("default") + 10, "/proxy", null, null)).connect().get();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<String> result = new AtomicReference<>();
    webSocketChannel.getReceiveSetter().set(new AbstractReceiveListener() {

        @Override
        protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) throws IOException {
            String data = message.getData();
            result.set(data);
            latch.countDown();
        }

        @Override
        protected void onError(WebSocketChannel channel, Throwable error) {
            super.onError(channel, error);
            error.printStackTrace();
            latch.countDown();
        }
    });
    webSocketChannel.resumeReceives();
    StreamSinkFrameChannel sendChannel = webSocketChannel.send(WebSocketFrameType.TEXT);
    new StringWriteChannelListener("Hello World").setup(sendChannel);
    latch.await(10, TimeUnit.SECONDS);
    Assert.assertEquals("Hello World", result.get());
    webSocketChannel.sendClose();
    Assert.assertEquals("CONNECT " + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostSSLPort("default"), connectLog.poll());
}
Also used : WebSocketChannel(io.undertow.websockets.core.WebSocketChannel) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) StreamSinkFrameChannel(io.undertow.websockets.core.StreamSinkFrameChannel) URI(java.net.URI) BufferedTextMessage(io.undertow.websockets.core.BufferedTextMessage) AbstractReceiveListener(io.undertow.websockets.core.AbstractReceiveListener) StringWriteChannelListener(io.undertow.util.StringWriteChannelListener) UndertowXnioSsl(io.undertow.protocols.ssl.UndertowXnioSsl) Test(org.junit.Test) ProxyIgnore(io.undertow.testutils.ProxyIgnore)

Example 3 with ProxyIgnore

use of io.undertow.testutils.ProxyIgnore in project undertow by undertow-io.

the class QueryParametersTestCase method testQueryParametersShiftJIS.

@Test
@ProxyIgnore
public void testQueryParametersShiftJIS() throws IOException {
    OptionMap old = DefaultServer.getUndertowOptions();
    try {
        DefaultServer.setUndertowOptions(OptionMap.create(UndertowOptions.URL_CHARSET, "Shift_JIS"));
        TestHttpClient client = new TestHttpClient();
        try {
            runTest(client, "{unicode=>ใƒ†ใ‚นใƒˆ}", "/path?unicode=%83e%83X%83g");
        } finally {
            client.getConnectionManager().shutdown();
        }
    } finally {
        DefaultServer.setUndertowOptions(old);
    }
}
Also used : OptionMap(org.xnio.OptionMap) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test) ProxyIgnore(io.undertow.testutils.ProxyIgnore)

Example 4 with ProxyIgnore

use of io.undertow.testutils.ProxyIgnore in project undertow by undertow-io.

the class WebSocketClient13TestCase method testMessageViaProxy.

@Test
@ProxyIgnore
public void testMessageViaProxy() throws Exception {
    final WebSocketChannel webSocketChannel = WebSocketClient.connectionBuilder(worker, DefaultServer.getBufferPool(), new URI(DefaultServer.getDefaultServerURL())).setProxyUri(new URI("http", null, DefaultServer.getHostAddress("default"), DefaultServer.getHostPort("default") + 10, "/proxy", null, null)).connect().get();
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<String> result = new AtomicReference<>();
    webSocketChannel.getReceiveSetter().set(new AbstractReceiveListener() {

        @Override
        protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) throws IOException {
            String data = message.getData();
            result.set(data);
            latch.countDown();
        }

        @Override
        protected void onError(WebSocketChannel channel, Throwable error) {
            super.onError(channel, error);
            error.printStackTrace();
            latch.countDown();
        }
    });
    webSocketChannel.resumeReceives();
    StreamSinkFrameChannel sendChannel = webSocketChannel.send(WebSocketFrameType.TEXT);
    new StringWriteChannelListener("Hello World").setup(sendChannel);
    latch.await(10, TimeUnit.SECONDS);
    Assert.assertEquals("Hello World", result.get());
    webSocketChannel.sendClose();
    Assert.assertEquals("CONNECT " + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default"), connectLog.poll());
}
Also used : WebSocketChannel(io.undertow.websockets.core.WebSocketChannel) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) StreamSinkFrameChannel(io.undertow.websockets.core.StreamSinkFrameChannel) URI(java.net.URI) BufferedTextMessage(io.undertow.websockets.core.BufferedTextMessage) AbstractReceiveListener(io.undertow.websockets.core.AbstractReceiveListener) StringWriteChannelListener(io.undertow.util.StringWriteChannelListener) Test(org.junit.Test) ProxyIgnore(io.undertow.testutils.ProxyIgnore)

Aggregations

ProxyIgnore (io.undertow.testutils.ProxyIgnore)4 Test (org.junit.Test)3 StringWriteChannelListener (io.undertow.util.StringWriteChannelListener)2 AbstractReceiveListener (io.undertow.websockets.core.AbstractReceiveListener)2 BufferedTextMessage (io.undertow.websockets.core.BufferedTextMessage)2 StreamSinkFrameChannel (io.undertow.websockets.core.StreamSinkFrameChannel)2 WebSocketChannel (io.undertow.websockets.core.WebSocketChannel)2 IOException (java.io.IOException)2 URI (java.net.URI)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 UndertowXnioSsl (io.undertow.protocols.ssl.UndertowXnioSsl)1 TestHttpClient (io.undertow.testutils.TestHttpClient)1 HttpString (io.undertow.util.HttpString)1 Socket (java.net.Socket)1 OptionMap (org.xnio.OptionMap)1