use of com.netflix.zuul.context.RequestContext in project spring-cloud-netflix by spring-cloud.
the class PreDecorationFilterTests method routeNotFound.
@Test
public void routeNotFound() throws Exception {
this.properties.setPrefix("/api");
this.properties.setStripPrefix(true);
this.routeLocator.addRoute(new ZuulRoute("foo", "/foo/**", null, "forward:/foo", true, null, null));
this.request.setRequestURI("/api/bar/1");
this.filter.run();
RequestContext ctx = RequestContext.getCurrentContext();
assertEquals("/api/bar/1", ctx.get(FORWARD_TO_KEY));
}
use of com.netflix.zuul.context.RequestContext in project spring-cloud-netflix by spring-cloud.
the class ZuulProxyApplicationTests method setTestRequestcontext.
@Before
public void setTestRequestcontext() {
RequestContext context = new RequestContext();
RequestContext.testSetCurrentContext(context);
}
use of com.netflix.zuul.context.RequestContext in project spring-cloud-netflix by spring-cloud.
the class ProxyRequestHelperTests method getUTF8Url.
@Test
public void getUTF8Url() {
String requestURI = "/oléדרעק";
String encodedRequestURI = "/ol%C3%A9%D7%93%D7%A8%D7%A2%D7%A7";
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestURI);
request.setCharacterEncoding("UTF-8");
RequestContext context = RequestContext.getCurrentContext();
context.set(REQUEST_URI_KEY, requestURI);
ProxyRequestHelper helper = new ProxyRequestHelper();
String uri = helper.buildZuulRequestURI(request);
assertThat(uri, is(encodedRequestURI));
}
use of com.netflix.zuul.context.RequestContext in project spring-cloud-netflix by spring-cloud.
the class ProxyRequestHelperTests method getDefaultEncodingUrl.
@Test
public void getDefaultEncodingUrl() {
String requestURI = "/oléדרעק";
String encodedRequestURI = "/ol%E9%3F%3F%3F%3F";
MockHttpServletRequest request = new MockHttpServletRequest("GET", requestURI);
RequestContext context = RequestContext.getCurrentContext();
context.set(REQUEST_URI_KEY, requestURI);
ProxyRequestHelper helper = new ProxyRequestHelper();
String uri = helper.buildZuulRequestURI(request);
assertThat(uri, is(encodedRequestURI));
}
use of com.netflix.zuul.context.RequestContext in project spring-cloud-netflix by spring-cloud.
the class ProxyRequestHelperTests method buildZuulRequestURIWithUTF8.
@Test
public void buildZuulRequestURIWithUTF8() throws Exception {
String encodedURI = "/resource/esp%C3%A9cial-char";
String decodedURI = "/resource/espécial-char";
MockHttpServletRequest request = new MockHttpServletRequest("GET", encodedURI);
request.setCharacterEncoding("UTF-8");
final RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
context.set(REQUEST_URI_KEY, decodedURI);
final String requestURI = new ProxyRequestHelper().buildZuulRequestURI(request);
assertThat(requestURI, equalTo(encodedURI));
}
Aggregations