-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25044 from OndroMih/ondromih-gh24918-proxy-scheme
Enhancement: Respect scheme from the serverName listener property in redirect URLs
- Loading branch information
Showing
20 changed files
with
318 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/ConnectionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package org.glassfish.main.admin.test; | ||
|
||
import static java.nio.charset.StandardCharsets.ISO_8859_1; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.StringWriter; | ||
import java.net.URL; | ||
import java.net.URLConnection; | ||
|
||
public class ConnectionUtils { | ||
/** | ||
* This method opens a connection to the given URL and returns the string that is returned from that URL. This is | ||
* useful for simple servlet retrieval | ||
* | ||
* @param urlstr The URL to connect to | ||
* @return The string returned from that URL, or empty string if there was a problem contacting the URL | ||
*/ | ||
public static String getURL(String urlstr) { | ||
URLConnection urlc = openConnection(urlstr); | ||
return getContent(urlc); | ||
} | ||
|
||
/** | ||
* This method retrieves the content of the connection response as plain String | ||
* | ||
* @param connection | ||
* @return The string returned from that connection, or empty string if there was a problem contacting the URL | ||
*/ | ||
public static String getContent(URLConnection connection) { | ||
try ( | ||
BufferedReader ir = new BufferedReader(new InputStreamReader(connection.getInputStream(), ISO_8859_1)); StringWriter ow = new StringWriter()) { | ||
String line; | ||
while ((line = ir.readLine()) != null) { | ||
ow.write(line); | ||
ow.write("\n"); | ||
} | ||
return ow.getBuffer().toString(); | ||
} catch (IOException ex) { | ||
return fail(ex); | ||
} | ||
} | ||
|
||
public static URLConnection openConnection(String url) { | ||
try { | ||
return new URL(url).openConnection(); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException(e); | ||
} | ||
} | ||
|
||
|
||
} |
52 changes: 52 additions & 0 deletions
52
appserver/tests/admin/tests/src/test/java/org/glassfish/main/admin/test/TestResources.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0, which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception, which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
*/ | ||
package org.glassfish.main.admin.test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.exporter.ZipExporter; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
|
||
public class TestResources { | ||
|
||
public static final String SIMPLE_HTML_PAGE | ||
= "<html>\n" | ||
+ " <head>\n" | ||
+ " <title>Simple test app</title>\n" | ||
+ " <meta charset=\"UTF-8\">\n" | ||
+ " </head>\n" | ||
+ " <body>\n" | ||
+ " <div>Simple test app</div>\n" | ||
+ " </body>\n" | ||
+ "</html>"; | ||
|
||
public static File createSimpleWarDeployment(String appName) { | ||
final WebArchive war = ShrinkWrap.create(WebArchive.class) | ||
.addAsWebResource( | ||
new StringAsset(SIMPLE_HTML_PAGE), | ||
"index.html"); | ||
try { | ||
File tempFile = File.createTempFile(appName, ".war"); | ||
war.as(ZipExporter.class).exportTo(tempFile, true); | ||
return tempFile; | ||
} catch (IOException e) { | ||
throw new IllegalStateException("WAR file creation failed for app " + appName, e); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.