use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestRpcHandler method httpCORSNotAllowedSimple.
@Test
public void httpCORSNotAllowedSimple() {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/v1/version");
req.headers().add(HttpHeaders.ORIGIN, "42.com");
handleHttpRpc(req, new Answer<ChannelFuture>() {
public ChannelFuture answer(final InvocationOnMock args) throws Throwable {
DefaultHttpResponse response = (DefaultHttpResponse) args.getArguments()[0];
assertEquals(HttpResponseStatus.OK, response.getStatus());
assertNull(response.headers().get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
return null;
}
});
tsdb.getConfig().overrideConfig("tsd.http.request.cors_domains", "aurther.com,dent.net,beeblebrox.org");
final RpcHandler rpc = new RpcHandler(tsdb, rpc_manager);
rpc.messageReceived(ctx, message);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestRpcHandler method httpOptionsCORSNotAllowed.
@Test
public void httpOptionsCORSNotAllowed() {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/api/v1/version");
req.headers().add(HttpHeaders.ORIGIN, "42.com");
handleHttpRpc(req, new Answer<ChannelFuture>() {
public ChannelFuture answer(final InvocationOnMock args) throws Throwable {
DefaultHttpResponse response = (DefaultHttpResponse) args.getArguments()[0];
assertEquals(HttpResponseStatus.OK, response.getStatus());
assertNull(response.headers().get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
return null;
}
});
tsdb.getConfig().overrideConfig("tsd.http.request.cors_domains", "aurther.com,dent.net,beeblebrox.org");
final RpcHandler rpc = new RpcHandler(tsdb, rpc_manager);
rpc.messageReceived(ctx, message);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestRpcHandler method httpOptionsNoCORS.
@Test
public void httpOptionsNoCORS() {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/api/v1/version");
handleHttpRpc(req, new Answer<ChannelFuture>() {
public ChannelFuture answer(final InvocationOnMock args) throws Throwable {
DefaultHttpResponse response = (DefaultHttpResponse) args.getArguments()[0];
assertEquals(HttpResponseStatus.METHOD_NOT_ALLOWED, response.getStatus());
assertNull(response.headers().get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
return null;
}
});
final RpcHandler rpc = new RpcHandler(tsdb, rpc_manager);
rpc.messageReceived(ctx, message);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestTreeRpc method handleCollissionsBadMethod.
@Test(expected = BadRequestException.class)
public void handleCollissionsBadMethod() throws Exception {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.TRACE, "/api/tree/collisions");
final HttpQuery query = new HttpQuery(tsdb, req, NettyMocks.fakeChannel());
rpc.execute(tsdb, query);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestTreeRpc method handleTreeBadMethod.
@Test(expected = BadRequestException.class)
public void handleTreeBadMethod() throws Exception {
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.TRACE, "/api/tree");
final HttpQuery query = new HttpQuery(tsdb, req, NettyMocks.fakeChannel());
rpc.execute(tsdb, query);
}
Aggregations