commit
efe84356b7
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -27,16 +27,31 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* Configuration properties for {@link HealthEndpoint}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Leo Li
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties("management.endpoint.health")
|
||||
public class HealthEndpointProperties extends HealthProperties {
|
||||
|
||||
/**
|
||||
* When to show full health details.
|
||||
*/
|
||||
private Show showDetails = Show.NEVER;
|
||||
|
||||
/**
|
||||
* Health endpoint groups.
|
||||
*/
|
||||
private Map<String, Group> group = new LinkedHashMap<>();
|
||||
|
||||
@Override
|
||||
public Show getShowDetails() {
|
||||
return this.showDetails;
|
||||
}
|
||||
|
||||
public void setShowDetails(Show showDetails) {
|
||||
this.showDetails = showDetails;
|
||||
}
|
||||
|
||||
public Map<String, Group> getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
|
@ -56,6 +71,12 @@ public class HealthEndpointProperties extends HealthProperties {
|
|||
*/
|
||||
private Set<String> exclude;
|
||||
|
||||
/**
|
||||
* When to show full health details. Defaults to the value of
|
||||
* 'management.endpoint.health.show-details'.
|
||||
*/
|
||||
private Show showDetails;
|
||||
|
||||
public Set<String> getInclude() {
|
||||
return this.include;
|
||||
}
|
||||
|
|
@ -72,6 +93,15 @@ public class HealthEndpointProperties extends HealthProperties {
|
|||
this.exclude = exclude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Show getShowDetails() {
|
||||
return this.showDetails;
|
||||
}
|
||||
|
||||
public void setShowDetails(Show showDetails) {
|
||||
this.showDetails = showDetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -43,11 +43,6 @@ public abstract class HealthProperties {
|
|||
*/
|
||||
private Show showComponents;
|
||||
|
||||
/**
|
||||
* When to show full health details.
|
||||
*/
|
||||
private Show showDetails = Show.NEVER;
|
||||
|
||||
/**
|
||||
* Roles used to determine whether or not a user is authorized to be shown details.
|
||||
* When empty, all authenticated users are authorized.
|
||||
|
|
@ -66,13 +61,7 @@ public abstract class HealthProperties {
|
|||
this.showComponents = showComponents;
|
||||
}
|
||||
|
||||
public Show getShowDetails() {
|
||||
return this.showDetails;
|
||||
}
|
||||
|
||||
public void setShowDetails(Show showDetails) {
|
||||
this.showDetails = showDetails;
|
||||
}
|
||||
public abstract Show getShowDetails();
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return this.roles;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* Tests for {@link AutoConfiguredHealthEndpointGroups}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Leo Li
|
||||
*/
|
||||
class AutoConfiguredHealthEndpointGroupsTests {
|
||||
|
||||
|
|
@ -308,6 +309,16 @@ class AutoConfiguredHealthEndpointGroupsTests {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void createWhenGroupWithNoShowDetailsOverrideInheritsShowDetails() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.health.show-details=always",
|
||||
"management.endpoint.health.group.a.include=*").run((context) -> {
|
||||
HealthEndpointGroups groups = context.getBean(HealthEndpointGroups.class);
|
||||
HealthEndpointGroup groupA = groups.get("a");
|
||||
assertThat(groupA.showDetails(SecurityContext.NONE)).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(HealthEndpointProperties.class)
|
||||
static class AutoConfiguredHealthEndpointGroupsTestConfiguration {
|
||||
|
|
|
|||
Loading…
Reference in New Issue