Search in sources :

Example 16 with AuthConfig

use of org.apache.druid.server.security.AuthConfig in project druid by druid-io.

the class IntervalsResourceTest method testSimpleGetSpecificIntervals.

@Test
public void testSimpleGetSpecificIntervals() {
    EasyMock.expect(inventoryView.getInventory()).andReturn(ImmutableList.of(server)).atLeastOnce();
    EasyMock.expect(request.getAttribute(AuthConfig.DRUID_ALLOW_UNSECURED_PATH)).andReturn(null).once();
    EasyMock.expect(request.getAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED)).andReturn(null).once();
    EasyMock.expect(request.getAttribute(AuthConfig.DRUID_AUTHENTICATION_RESULT)).andReturn(new AuthenticationResult("druid", "druid", null, null)).once();
    request.setAttribute(AuthConfig.DRUID_AUTHORIZATION_CHECKED, true);
    EasyMock.expectLastCall().times(1);
    EasyMock.replay(inventoryView, request);
    List<Interval> expectedIntervals = new ArrayList<>();
    expectedIntervals.add(Intervals.of("2010-01-01T00:00:00.000Z/2010-01-02T00:00:00.000Z"));
    IntervalsResource intervalsResource = new IntervalsResource(inventoryView, new AuthConfig(), AuthTestUtils.TEST_AUTHORIZER_MAPPER);
    Response response = intervalsResource.getSpecificIntervals("2010-01-01T00:00:00.000Z/P1D", "simple", null, request);
    Map<Interval, Map<String, Object>> actualIntervals = (Map) response.getEntity();
    Assert.assertEquals(1, actualIntervals.size());
    Assert.assertTrue(actualIntervals.containsKey(expectedIntervals.get(0)));
    Assert.assertEquals(25L, actualIntervals.get(expectedIntervals.get(0)).get("size"));
    Assert.assertEquals(2, actualIntervals.get(expectedIntervals.get(0)).get("count"));
}
Also used : Response(javax.ws.rs.core.Response) ArrayList(java.util.ArrayList) AuthConfig(org.apache.druid.server.security.AuthConfig) TreeMap(java.util.TreeMap) Map(java.util.Map) AuthenticationResult(org.apache.druid.server.security.AuthenticationResult) Interval(org.joda.time.Interval) Test(org.junit.Test)

Aggregations

AuthConfig (org.apache.druid.server.security.AuthConfig)16 Response (javax.ws.rs.core.Response)11 AuthenticationResult (org.apache.druid.server.security.AuthenticationResult)11 Test (org.junit.Test)11 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 DefaultGenericQueryMetricsFactory (org.apache.druid.query.DefaultGenericQueryMetricsFactory)7 DefaultQueryConfig (org.apache.druid.query.DefaultQueryConfig)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 ImmutableList (com.google.common.collect.ImmutableList)6 AuthorizerMapper (org.apache.druid.server.security.AuthorizerMapper)6 IOException (java.io.IOException)5 List (java.util.List)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 StreamingOutput (javax.ws.rs.core.StreamingOutput)4 Result (org.apache.druid.query.Result)4 TimeBoundaryResultValue (org.apache.druid.query.timeboundary.TimeBoundaryResultValue)4 Access (org.apache.druid.server.security.Access)4