Skip to content

Commit

Permalink
Issue #5357 - Fixing demo /proxy/ url to use https://eclipse.org... p…
Browse files Browse the repository at this point in the history
…roperly

Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Sep 28, 2020
1 parent 5221a26 commit 0016b86
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 149 deletions.
17 changes: 5 additions & 12 deletions tests/test-webapps/test-proxy-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<!--
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
Expand All @@ -61,13 +53,14 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<artifactId>jetty-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//

package org.eclipse.jetty.demos;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.proxy.ProxyServlet;
import org.eclipse.jetty.util.ssl.SslContextFactory;

/**
* Transparent Proxy to Eclipse hosted Javadoc
*/
public class EclipseJavadocProxyServlet extends ProxyServlet.Transparent
{
@Override
protected HttpClient newHttpClient()
{
int selectorCount = 1;
HttpClientTransportOverHTTP transport = new HttpClientTransportOverHTTP(selectorCount);
SslContextFactory.Client clientSsl = new SslContextFactory.Client();
return new HttpClient(transport, clientSsl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@

<servlet>
<servlet-name>JavadocTransparentProxy</servlet-name>
<servlet-class>org.eclipse.jetty.proxy.ProxyServlet$Transparent</servlet-class>
<servlet-class>org.eclipse.jetty.demos.EclipseJavadocProxyServlet</servlet-class>
<init-param>
<param-name>proxyTo</param-name>
<param-value>https://www.eclipse.org/jetty/javadoc/</param-value>
</init-param>
<init-param>
<param-name>hostHeader</param-name><param-value>eclipse.org</param-value>
<param-name>hostHeader</param-name>
<param-value>www.eclipse.org</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//

package org.eclipse.jetty;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.webapp.WebAppContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class EclipseJavadocProxyServletTest
{
private Server server;
private HttpClient client;

@BeforeEach
public void setup() throws Exception
{
server = new Server();

ServerConnector connector = new ServerConnector(server);
connector.setPort(0);
server.addConnector(connector);

WebAppContext webapp = new WebAppContext();
// This is a pieced together WebApp.
// We don't have a valid WEB-INF/lib to rely on at this point.
// So, open up server classes here, for purposes of this testcase.
webapp.getServerClasspathPattern().add(
"-org.eclipse.jetty.proxy.",
"-org.eclipse.jetty.client.",
"-org.eclipse.jetty.util.ssl.");
webapp.getSystemClasspathPattern().add(
"org.eclipse.jetty.proxy.",
"org.eclipse.jetty.client.",
"org.eclipse.jetty.util.ss.");
webapp.setBaseResource(new PathResource(MavenTestingUtils.getProjectDirPath("src/main/webapp")));
webapp.setExtraClasspath(MavenTestingUtils.getTargetPath().resolve("classes").toString());
server.setHandler(webapp);

server.start();

client = new HttpClient();
client.start();
}

@AfterEach
public void teardown()
{
LifeCycle.stop(client);
LifeCycle.stop(server);
}

@Test
@Tag("external")
public void testProxyRequest() throws InterruptedException, ExecutionException, TimeoutException
{
ContentResponse response = client.newRequest(server.getURI().resolve("/proxy/current/"))
.followRedirects(false)
.send();

assertThat("response status", response.getStatus(), is(HttpStatus.OK_200));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
#org.eclipse.jetty.LEVEL=WARN
#org.eclipse.jetty.client.LEVEL=DEBUG
#org.eclipse.jetty.http.LEVEL=DEBUG
#org.eclipse.jetty.proxy.LEVEL=DEBUG

0 comments on commit 0016b86

Please sign in to comment.