|
|
@ -17,6 +17,7 @@
|
|
|
|
package org.springframework.boot.actuate.autoconfigure.health;
|
|
|
|
package org.springframework.boot.actuate.autoconfigure.health;
|
|
|
|
|
|
|
|
|
|
|
|
import java.security.Principal;
|
|
|
|
import java.security.Principal;
|
|
|
|
|
|
|
|
import java.time.Duration;
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
@ -97,8 +98,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
Health extensionHealth = extension.health(securityContext).block()
|
|
|
|
Health extensionHealth = extension.health(securityContext)
|
|
|
|
.getBody();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody();
|
|
|
|
assertThat(endpointHealth.getDetails())
|
|
|
|
assertThat(endpointHealth.getDetails())
|
|
|
|
.containsOnlyKeys("application", "first", "second");
|
|
|
|
.containsOnlyKeys("application", "first", "second");
|
|
|
|
assertThat(extensionHealth.getDetails())
|
|
|
|
assertThat(extensionHealth.getDetails())
|
|
|
@ -111,8 +112,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
assertThat(extension.health(mock(SecurityContext.class)).block().getBody()
|
|
|
|
assertThat(extension.health(mock(SecurityContext.class))
|
|
|
|
.getDetails()).isEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails()).isEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -123,8 +124,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
given(securityContext.getPrincipal()).willReturn(mock(Principal.class));
|
|
|
|
given(securityContext.getPrincipal()).willReturn(mock(Principal.class));
|
|
|
|
assertThat(extension.health(securityContext).block().getBody().getDetails())
|
|
|
|
assertThat(extension.health(securityContext).block(Duration.ofSeconds(30))
|
|
|
|
.isEmpty();
|
|
|
|
.getBody().getDetails()).isEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -139,8 +140,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
assertThat(extension.health(securityContext).block().getBody()
|
|
|
|
assertThat(extension.health(securityContext)
|
|
|
|
.getDetails()).isNotEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails())
|
|
|
|
|
|
|
|
.isNotEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -151,8 +153,8 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
.run((context) -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
assertThat(extension.health(null).block().getBody().getDetails())
|
|
|
|
assertThat(extension.health(null).block(Duration.ofSeconds(30))
|
|
|
|
.isNotEmpty();
|
|
|
|
.getBody().getDetails()).isNotEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -164,8 +166,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
ReactiveHealthEndpointWebExtension extension = context
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
.getBean(ReactiveHealthEndpointWebExtension.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
SecurityContext securityContext = mock(SecurityContext.class);
|
|
|
|
assertThat(extension.health(securityContext).block().getBody()
|
|
|
|
assertThat(extension.health(securityContext)
|
|
|
|
.getDetails()).isEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails())
|
|
|
|
|
|
|
|
.isEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -180,8 +183,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
|
|
|
|
given(securityContext.isUserInRole("ACTUATOR")).willReturn(false);
|
|
|
|
assertThat(extension.health(securityContext).block().getBody()
|
|
|
|
assertThat(extension.health(securityContext)
|
|
|
|
.getDetails()).isEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails())
|
|
|
|
|
|
|
|
.isEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -196,8 +200,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
|
|
|
|
given(securityContext.isUserInRole("ACTUATOR")).willReturn(true);
|
|
|
|
assertThat(extension.health(securityContext).block().getBody()
|
|
|
|
assertThat(extension.health(securityContext)
|
|
|
|
.getDetails()).isNotEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails())
|
|
|
|
|
|
|
|
.isNotEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -212,8 +217,9 @@ public class ReactiveHealthEndpointWebExtensionTests {
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
given(securityContext.getPrincipal())
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
.willReturn(mock(Principal.class));
|
|
|
|
given(securityContext.isUserInRole("ADMIN")).willReturn(true);
|
|
|
|
given(securityContext.isUserInRole("ADMIN")).willReturn(true);
|
|
|
|
assertThat(extension.health(securityContext).block().getBody()
|
|
|
|
assertThat(extension.health(securityContext)
|
|
|
|
.getDetails()).isNotEmpty();
|
|
|
|
.block(Duration.ofSeconds(30)).getBody().getDetails())
|
|
|
|
|
|
|
|
.isNotEmpty();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|