use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class CookieValueMethodArgumentResolverTests method resolveCookieArgument.
@Test
public void resolveCookieArgument() {
HttpCookie expected = new HttpCookie("name", "foo");
ServerWebExchange exchange = MockServerHttpRequest.get("/").cookie(expected.getName(), expected).toExchange();
Mono<Object> mono = this.resolver.resolveArgument(this.cookieParameter, this.bindingContext, exchange);
assertEquals(expected, mono.block());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class RequestBodyArgumentResolverTests method resolveValueWithEmptyBody.
@SuppressWarnings("unchecked")
private <T> T resolveValueWithEmptyBody(MethodParameter param) {
ServerWebExchange exchange = MockServerHttpRequest.post("/path").build().toExchange();
Mono<Object> result = this.resolver.resolveArgument(param, new BindingContext(), exchange);
Object value = result.block(Duration.ofSeconds(5));
if (value != null) {
assertTrue("Unexpected parameter type: " + value, param.getParameterType().isAssignableFrom(value.getClass()));
}
//no inspection unchecked
return (T) value;
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class DefaultCorsProcessorTests method preflightRequestWithoutRequestMethod.
@Test
public void preflightRequestWithoutRequestMethod() throws Exception {
ServerWebExchange exchange = preFlightRequest().header(ACCESS_CONTROL_REQUEST_HEADERS, "Header1").toExchange();
this.processor.processRequest(this.conf, exchange);
ServerHttpResponse response = exchange.getResponse();
assertFalse(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class DefaultCorsProcessorTests method preflightRequestWithNullConfig.
@Test
public void preflightRequestWithNullConfig() throws Exception {
ServerWebExchange exchange = preFlightRequest().header(ACCESS_CONTROL_REQUEST_METHOD, "GET").toExchange();
this.conf.addAllowedOrigin("*");
this.processor.processRequest(null, exchange);
ServerHttpResponse response = exchange.getResponse();
assertFalse(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN));
assertEquals(HttpStatus.FORBIDDEN, response.getStatusCode());
}
use of org.springframework.web.server.ServerWebExchange in project spring-framework by spring-projects.
the class DefaultCorsProcessorTests method actualRequestWithOriginHeaderAndNullConfig.
@Test
public void actualRequestWithOriginHeaderAndNullConfig() throws Exception {
ServerWebExchange exchange = actualRequest();
this.processor.processRequest(null, exchange);
ServerHttpResponse response = exchange.getResponse();
assertFalse(response.getHeaders().containsKey(ACCESS_CONTROL_ALLOW_ORIGIN));
assertNull(response.getStatusCode());
}
Aggregations