Commit c8a1ae9e by Johannes Edmeier

Merge branch '1.4.x'

parents a99a889a 79eb9496
...@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties; import org.springframework.boot.actuate.autoconfigure.ManagementServerProperties;
import org.springframework.boot.autoconfigure.web.ServerProperties; import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.embedded.Ssl;
import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
...@@ -94,8 +95,9 @@ public class AdminClientProperties { ...@@ -94,8 +95,9 @@ public class AdminClientProperties {
"serviceUrl must be set when deployed to servlet-container"); "serviceUrl must be set when deployed to servlet-container");
} }
return UriComponentsBuilder.newInstance().scheme(getScheme()).host(getServiceHost()) return UriComponentsBuilder.newInstance().scheme(getScheme(server.getSsl()))
.port(serverPort).path(server.getContextPath()).toUriString(); .host(getServiceHost()).port(serverPort).path(server.getContextPath())
.toUriString();
} }
public String getManagementUrl() { public String getManagementUrl() {
...@@ -110,7 +112,8 @@ public class AdminClientProperties { ...@@ -110,7 +112,8 @@ public class AdminClientProperties {
.toUriString(); .toUriString();
} }
return UriComponentsBuilder.newInstance().scheme(getScheme()).host(getManagementHost()) Ssl ssl = management.getSsl() != null ? management.getSsl() : server.getSsl();
return UriComponentsBuilder.newInstance().scheme(getScheme(ssl)).host(getManagementHost())
.port(managementPort).path(management.getContextPath()).toUriString(); .port(managementPort).path(management.getContextPath()).toUriString();
} }
...@@ -151,8 +154,8 @@ public class AdminClientProperties { ...@@ -151,8 +154,8 @@ public class AdminClientProperties {
return preferIp; return preferIp;
} }
private String getScheme() { private String getScheme(Ssl ssl) {
return server.getSsl() != null && server.getSsl().isEnabled() ? "https" : "http"; return ssl != null && ssl.isEnabled() ? "https" : "http";
} }
private String getHost(InetAddress address) { private String getHost(InetAddress address) {
......
...@@ -135,6 +135,20 @@ public class AdminClientPropertiesTest { ...@@ -135,6 +135,20 @@ public class AdminClientPropertiesTest {
} }
@Test @Test
public void test_ssl_managment() {
load("management.ssl.key-store=somefile.jks", "management.ssl.key-store-password=password",
"local.server.port=8080", "local.management.port=9090");
AdminClientProperties clientProperties = context.getBean(AdminClientProperties.class);
publishApplicationReadyEvent(clientProperties);
assertThat(clientProperties.getManagementUrl(), is("https://" + getHostname() + ":9090"));
assertThat(clientProperties.getHealthUrl(),
is("https://" + getHostname() + ":9090/health"));
assertThat(clientProperties.getServiceUrl(), is("http://" + getHostname() + ":8080"));
}
@Test
public void test_preferIpAddress_serveraddress_missing() { public void test_preferIpAddress_serveraddress_missing() {
load("spring.boot.admin.client.prefer-ip=true", "local.server.port=8080"); load("spring.boot.admin.client.prefer-ip=true", "local.server.port=8080");
AdminClientProperties clientProperties = context.getBean(AdminClientProperties.class); AdminClientProperties clientProperties = context.getBean(AdminClientProperties.class);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment