()
| 736 | } |
| 737 | |
| 738 | @Test |
| 739 | public void v1AuthAllowed() throws Exception { |
| 740 | final TSDB tsdb = NettyMocks.getMockedHTTPTSDBWithAuthEnabled(AuthStatus.SUCCESS); |
| 741 | when(tsdb.newQuery()).thenReturn(query_result); |
| 742 | when(query_result.configureFromQuery((TSQuery)any(), anyInt())) |
| 743 | .thenReturn(Deferred.fromResult(null)); |
| 744 | when(query_result.runAsync()) |
| 745 | .thenReturn(Deferred.fromResult(new DataPoints[0])); |
| 746 | |
| 747 | final DataPoints[] datapoints = new DataPoints[1]; |
| 748 | datapoints[0] = new MockDataPoints().getMock(); |
| 749 | when(query_result.runAsync()).thenReturn(Deferred.fromResult(datapoints)); |
| 750 | |
| 751 | final HttpQuery query = NettyMocks.postQuery(tsdb,"/api/query", |
| 752 | "{\"start\":\"1h-ago\",\"queries\":" + |
| 753 | "[{\"metric\":\"sys.cpu.user\",\"aggregator\":\"sum\"}]}"); |
| 754 | |
| 755 | NettyMocks.mockChannelFuture(query); |
| 756 | rpc.execute(tsdb, query); |
| 757 | final String json = query.response().getContent().toString(Charset.forName("UTF-8")); |
| 758 | assertTrue(json.contains("\"metric\":\"system.cpu.user\"")); |
| 759 | assertEquals(HttpResponseStatus.OK, query.response().getStatus()); |
| 760 | } |
| 761 | |
| 762 | @Test |
| 763 | public void v1AuthUnauthorized() throws Exception { |
nothing calls this directly
no test coverage detected