Allow HTTP {listen,canonicalWeb}Url in tests

Enable the ability to test the Gerrit HTTP behaviour with
different listenUrl and canonicalWebUrl configurations.

E.g. Using canonicalWebUrl <> httpd.listenUrl for reverse-proxy
     scenarios.

Change-Id: Ie0bc508dbe1d979f1235143134fbe6526c7f4848
This commit is contained in:
Luca Milanesio
2020-04-08 12:36:49 +01:00
parent 91890d430c
commit 4799b667c8
2 changed files with 9 additions and 2 deletions

View File

@@ -406,6 +406,9 @@ public abstract class AbstractDaemonTest {
baseConfig.setString("sshd", null, "listenAddress", "off");
}
baseConfig.unset("gerrit", null, "canonicalWebUrl");
baseConfig.unset("httpd", null, "listenUrl");
baseConfig.setInt("index", null, "batchThreads", -1);
baseConfig.setInt("receive", null, "changeUpdateThreads", 4);

View File

@@ -463,9 +463,13 @@ public class GerritServer implements AutoCloseable {
private static void mergeTestConfig(Config cfg) {
String forceEphemeralPort = String.format("%s:0", getLocalHost().getHostName());
String url = "http://" + forceEphemeralPort + "/";
cfg.setString("gerrit", null, "canonicalWebUrl", url);
cfg.setString("httpd", null, "listenUrl", url);
if (cfg.getString("gerrit", null, "canonicalWebUrl") == null) {
cfg.setString("gerrit", null, "canonicalWebUrl", url);
}
if (cfg.getString("httpd", null, "listenUrl") == null) {
cfg.setString("httpd", null, "listenUrl", url);
}
if (cfg.getString("sshd", null, "listenAddress") == null) {
cfg.setString("sshd", null, "listenAddress", forceEphemeralPort);
}