MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / v1AuthAllowed

Method v1AuthAllowed

test/tsd/TestQueryRpc.java:738–760  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 13

newQueryMethod · 0.95
postQueryMethod · 0.95
mockChannelFutureMethod · 0.95
getMockMethod · 0.80
responseMethod · 0.80
containsMethod · 0.80
configureFromQueryMethod · 0.65
runAsyncMethod · 0.65
executeMethod · 0.65
getStatusMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected