Search in sources :

Example 6 with WebEndpointTest

use of org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest in project spring-boot by spring-projects.

the class EnvironmentEndpointWebIntegrationTests method nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty.

@WebEndpointTest
void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() {
    Map<String, Object> map = new HashMap<>();
    map.put("my.foo", "${my.bar}");
    this.context.getEnvironment().getPropertySources().addFirst(new MapPropertySource("unresolved-placeholder", map));
    this.client.get().uri("/actuator/env/my.foo").exchange().expectStatus().isOk().expectBody().jsonPath("property.value").isEqualTo("${my.bar}").jsonPath(forPropertyEntry("unresolved-placeholder")).isEqualTo("${my.bar}");
}
Also used : HashMap(java.util.HashMap) MapPropertySource(org.springframework.core.env.MapPropertySource) WebEndpointTest(org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)

Example 7 with WebEndpointTest

use of org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest in project spring-boot by spring-projects.

the class EnvironmentEndpointWebIntegrationTests method nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize.

@WebEndpointTest
void nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize() {
    Map<String, Object> map = new HashMap<>();
    map.put("my.foo", "${my.password}");
    map.put("my.password", "hello");
    this.context.getEnvironment().getPropertySources().addFirst(new MapPropertySource("placeholder", map));
    this.client.get().uri("/actuator/env?pattern=my.*").exchange().expectStatus().isOk().expectBody().jsonPath(forProperty("placeholder", "my.foo")).isEqualTo("******");
}
Also used : HashMap(java.util.HashMap) MapPropertySource(org.springframework.core.env.MapPropertySource) WebEndpointTest(org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)

Example 8 with WebEndpointTest

use of org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest in project spring-boot by spring-projects.

the class EnvironmentEndpointWebIntegrationTests method regex.

@WebEndpointTest
void regex() {
    Map<String, Object> map = new HashMap<>();
    map.put("food", null);
    this.context.getEnvironment().getPropertySources().addFirst(new MapPropertySource("null-value", map));
    this.client.get().uri("/actuator/env?pattern=foo.*").exchange().expectStatus().isOk().expectBody().jsonPath(forProperty("test", "foo")).isEqualTo("bar").jsonPath(forProperty("test", "fool")).isEqualTo("baz");
}
Also used : HashMap(java.util.HashMap) MapPropertySource(org.springframework.core.env.MapPropertySource) WebEndpointTest(org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)

Example 9 with WebEndpointTest

use of org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest in project spring-boot by spring-projects.

the class PrometheusScrapeEndpointIntegrationTests method scrapeCanProduceOpenMetrics100.

@WebEndpointTest
void scrapeCanProduceOpenMetrics100(WebTestClient client) {
    MediaType openMetrics = MediaType.parseMediaType(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
    client.get().uri("/actuator/prometheus").accept(openMetrics).exchange().expectStatus().isOk().expectHeader().contentType(openMetrics).expectBody(String.class).value((body) -> assertThat(body).contains("counter1_total").contains("counter2_total").contains("counter3_total"));
}
Also used : MediaType(org.springframework.http.MediaType) WebEndpointTest(org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)

Example 10 with WebEndpointTest

use of org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest in project spring-boot by spring-projects.

the class CachesEndpointWebIntegrationTests method clearNamedCache.

@WebEndpointTest
void clearNamedCache(WebTestClient client, ApplicationContext context) {
    Cache b = context.getBean("one", CacheManager.class).getCache("b");
    b.put("test", "value");
    client.delete().uri("/actuator/caches/b").exchange().expectStatus().isNoContent();
    assertThat(b.get("test")).isNull();
}
Also used : CacheManager(org.springframework.cache.CacheManager) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) Cache(org.springframework.cache.Cache) WebEndpointTest(org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)

Aggregations

WebEndpointTest (org.springframework.boot.actuate.endpoint.web.test.WebEndpointTest)10 HashMap (java.util.HashMap)5 MapPropertySource (org.springframework.core.env.MapPropertySource)5 LoggerConfiguration (org.springframework.boot.logging.LoggerConfiguration)2 MediaType (org.springframework.http.MediaType)2 Cache (org.springframework.cache.Cache)1 CacheManager (org.springframework.cache.CacheManager)1 ConcurrentMapCacheManager (org.springframework.cache.concurrent.ConcurrentMapCacheManager)1