mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-27 04:19:03 +00:00
Merge branch '4.0.x'
Closes gh-49944
This commit is contained in:
+3
-3
@@ -310,17 +310,17 @@ public final class EndpointRequest {
|
||||
public EndpointServerWebExchangeMatcher excluding(Class<?>... endpoints) {
|
||||
List<Object> excludes = new ArrayList<>(this.excludes);
|
||||
excludes.addAll(Arrays.asList((Object[]) endpoints));
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks, null);
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks, this.httpMethod);
|
||||
}
|
||||
|
||||
public EndpointServerWebExchangeMatcher excluding(String... endpoints) {
|
||||
List<Object> excludes = new ArrayList<>(this.excludes);
|
||||
excludes.addAll(Arrays.asList((Object[]) endpoints));
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks, null);
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, excludes, this.includeLinks, this.httpMethod);
|
||||
}
|
||||
|
||||
public EndpointServerWebExchangeMatcher excludingLinks() {
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, this.excludes, false, null);
|
||||
return new EndpointServerWebExchangeMatcher(this.includes, this.excludes, false, this.httpMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+3
-3
@@ -318,17 +318,17 @@ public final class EndpointRequest {
|
||||
public EndpointRequestMatcher excluding(Class<?>... endpoints) {
|
||||
List<Object> excludes = new ArrayList<>(this.excludes);
|
||||
excludes.addAll(Arrays.asList((Object[]) endpoints));
|
||||
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks, null);
|
||||
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks, this.httpMethod);
|
||||
}
|
||||
|
||||
public EndpointRequestMatcher excluding(String... endpoints) {
|
||||
List<Object> excludes = new ArrayList<>(this.excludes);
|
||||
excludes.addAll(Arrays.asList((Object[]) endpoints));
|
||||
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks, null);
|
||||
return new EndpointRequestMatcher(this.includes, excludes, this.includeLinks, this.httpMethod);
|
||||
}
|
||||
|
||||
public EndpointRequestMatcher excludingLinks() {
|
||||
return new EndpointRequestMatcher(this.includes, this.excludes, false, null);
|
||||
return new EndpointRequestMatcher(this.includes, this.excludes, false, this.httpMethod);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+27
@@ -236,6 +236,33 @@ class EndpointRequestTests {
|
||||
assertMatcher.matches("/bar/");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAnyEndpointWithHttpMethodExcludingShouldPreserveHttpMethod() {
|
||||
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint()
|
||||
.withHttpMethod(HttpMethod.POST)
|
||||
.excluding(FooEndpoint.class)
|
||||
.excluding("baz");
|
||||
List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
|
||||
endpoints.add(mockEndpoint(EndpointId.of("foo"), "foo"));
|
||||
endpoints.add(mockEndpoint(EndpointId.of("bar"), "bar"));
|
||||
endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz"));
|
||||
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
|
||||
assertMatcher(matcher, pathMappedEndpoints).matches(HttpMethod.POST, "/actuator/bar");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch(HttpMethod.GET, "/actuator/bar");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAnyEndpointWithHttpMethodExcludingLinksShouldPreserveHttpMethod() {
|
||||
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint()
|
||||
.withHttpMethod(HttpMethod.POST)
|
||||
.excludingLinks();
|
||||
assertMatcher(matcher).matches(HttpMethod.POST, "/actuator/foo");
|
||||
assertMatcher(matcher).doesNotMatch(HttpMethod.GET, "/actuator/foo");
|
||||
assertMatcher(matcher).doesNotMatch("/actuator");
|
||||
}
|
||||
|
||||
@Test
|
||||
void noEndpointPathsBeansShouldNeverMatch() {
|
||||
ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||
|
||||
+25
@@ -223,6 +223,31 @@ class EndpointRequestTests {
|
||||
assertMatcher.matches("/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAnyEndpointWithHttpMethodExcludingShouldPreserveHttpMethod() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint()
|
||||
.withHttpMethod(HttpMethod.POST)
|
||||
.excluding(FooEndpoint.class)
|
||||
.excluding("baz");
|
||||
List<ExposableEndpoint<?>> endpoints = new ArrayList<>();
|
||||
endpoints.add(mockEndpoint(EndpointId.of("foo"), "foo"));
|
||||
endpoints.add(mockEndpoint(EndpointId.of("bar"), "bar"));
|
||||
endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz"));
|
||||
PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints);
|
||||
assertMatcher(matcher, pathMappedEndpoints).matches(HttpMethod.POST, "/actuator/bar");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch(HttpMethod.GET, "/actuator/bar");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo");
|
||||
assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
void toAnyEndpointWithHttpMethodExcludingLinksShouldPreserveHttpMethod() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint().withHttpMethod(HttpMethod.POST).excludingLinks();
|
||||
assertMatcher(matcher).matches(HttpMethod.POST, "/actuator/foo");
|
||||
assertMatcher(matcher).doesNotMatch(HttpMethod.GET, "/actuator/foo");
|
||||
assertMatcher(matcher).doesNotMatch("/actuator");
|
||||
}
|
||||
|
||||
@Test
|
||||
void endpointRequestMatcherShouldUseCustomRequestMatcherProvider() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||
|
||||
Reference in New Issue
Block a user