|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2012-2019 the original author or authors.
|
|
|
|
|
* Copyright 2012-2022 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.
|
|
|
|
@ -88,24 +88,28 @@ class EndpointRequestTests {
|
|
|
|
|
void toEndpointClassShouldMatchEndpointPath() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void toEndpointClassShouldNotMatchOtherPath() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/bar/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void toEndpointIdShouldMatchEndpointPath() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.to("foo");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void toEndpointIdShouldNotMatchOtherPath() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.to("foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/bar/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -136,9 +140,13 @@ class EndpointRequestTests {
|
|
|
|
|
endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz"));
|
|
|
|
|
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
|
|
|
|
|
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
|
|
|
|
|
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -146,30 +154,40 @@ class EndpointRequestTests {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks()
|
|
|
|
|
.excluding(FooEndpoint.class);
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void excludeByIdShouldNotMatchExcluded() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excluding("foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void excludeByIdShouldNotMatchLinksIfExcluded() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks().excluding("foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void excludeLinksShouldNotMatchBasePath() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks();
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator");
|
|
|
|
|
assertMatcher(matcher).doesNotMatch("/actuator/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher).matches("/actuator/bar/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -178,14 +196,18 @@ class EndpointRequestTests {
|
|
|
|
|
RequestMatcherAssert assertMatcher = assertMatcher(matcher, "");
|
|
|
|
|
assertMatcher.doesNotMatch("/");
|
|
|
|
|
assertMatcher.matches("/foo");
|
|
|
|
|
assertMatcher.matches("/foo/");
|
|
|
|
|
assertMatcher.matches("/bar");
|
|
|
|
|
assertMatcher.matches("/bar/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void noEndpointPathsBeansShouldNeverMatch() {
|
|
|
|
|
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint();
|
|
|
|
|
assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo");
|
|
|
|
|
assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo/");
|
|
|
|
|
assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar");
|
|
|
|
|
assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private RequestMatcherAssert assertMatcher(ServerWebExchangeMatcher matcher) {
|
|
|
|
|