use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-security by spring-projects.
the class ServerRequestCacheWebFilterTests method filterWhenRequestDoesNotMatchThenRequestDoesNotChange.
@Test
public void filterWhenRequestDoesNotMatchThenRequestDoesNotChange() {
MockServerHttpRequest initialRequest = MockServerHttpRequest.get("/").build();
ServerWebExchange exchange = MockServerWebExchange.from(initialRequest);
given(this.requestCache.removeMatchingRequest(any())).willReturn(Mono.empty());
this.requestCacheFilter.filter(exchange, this.chain).block();
verify(this.chain).filter(this.exchangeCaptor.capture());
ServerWebExchange updatedExchange = this.exchangeCaptor.getValue();
assertThat(updatedExchange.getRequest()).isEqualTo(initialRequest);
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-security by spring-projects.
the class HttpStatusReturningServerLogoutSuccessHandlerTests method buildFilterExchange.
private static WebFilterExchange buildFilterExchange() {
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
return new WebFilterExchange(exchange, mock(WebFilterChain.class));
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-security by spring-projects.
the class DelegatingReactiveAuthorizationManagerTests method setup.
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
this.manager = DelegatingReactiveAuthorizationManager.builder().add(new ServerWebExchangeMatcherEntry<>(this.match1, this.delegate1)).add(new ServerWebExchangeMatcherEntry<>(this.match2, this.delegate2)).build();
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
this.exchange = MockServerWebExchange.from(request);
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-cloud-open-service-broker by spring-cloud.
the class ApiVersionWebFilterTest method setUpVersionResponse.
private void setUpVersionResponse(String version) {
MockServerHttpRequest request;
if (version == null) {
request = MockServerHttpRequest.get(V2_API_PATH_PATTERN).build();
} else {
request = MockServerHttpRequest.get(V2_API_PATH_PATTERN).header("header", version).build();
}
this.exchange = MockServerWebExchange.from(request);
openMocks(this);
exchange.getResponse().setStatusCode(HttpStatus.OK);
given(chain.filter(exchange)).willReturn(Mono.empty());
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-cloud-open-service-broker by spring-cloud.
the class RequestIdentityWebFilterTest method requestIdentityHeader.
@Test
void requestIdentityHeader() {
MockServerHttpRequest request = MockServerHttpRequest.get(V2_API_PATH_PATTERN).header(ServiceBrokerRequest.REQUEST_IDENTITY_HEADER, "request-id").build();
this.exchange = MockServerWebExchange.from(request);
openMocks(this);
given(chain.filter(exchange)).willReturn(Mono.empty());
RequestIdentityWebFilter webFilter = new RequestIdentityWebFilter();
webFilter.filter(exchange, chain).block();
assertThat(exchange.getResponse().getHeaders().getFirst(ServiceBrokerRequest.REQUEST_IDENTITY_HEADER)).isEqualTo("request-id");
}
Aggregations