Search in sources :

Example 16 with HttpClient

use of org.apache.druid.java.util.http.client.HttpClient in project druid by druid-io.

the class HttpShuffleClientTest method mockClient.

private HttpShuffleClient mockClient(int numFailures) throws FileNotFoundException {
    HttpClient httpClient = EasyMock.strictMock(HttpClient.class);
    if (numFailures == 0) {
        EasyMock.expect(httpClient.go(EasyMock.anyObject(), EasyMock.anyObject())).andReturn(Futures.immediateFuture(new FileInputStream(segmentFile))).andReturn(Futures.immediateFuture(new FileInputStream(segmentFile)));
    } else {
        EasyMock.expect(httpClient.go(EasyMock.anyObject(), EasyMock.anyObject())).andReturn(Futures.immediateFailedFuture(new RuntimeException())).times(numFailures).andReturn(Futures.immediateFuture(new FileInputStream(segmentFile))).andReturn(Futures.immediateFuture(new FileInputStream(segmentFile)));
    }
    EasyMock.replay(httpClient);
    return new HttpShuffleClient(httpClient);
}
Also used : HttpClient(org.apache.druid.java.util.http.client.HttpClient) FileInputStream(java.io.FileInputStream)

Example 17 with HttpClient

use of org.apache.druid.java.util.http.client.HttpClient in project druid by druid-io.

the class AbstractAuthConfigurationTest method verifyInvalidAuthNameFails.

protected void verifyInvalidAuthNameFails(String endpoint) {
    HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    HttpUtil.makeRequestWithExpectedStatus(adminClient, HttpMethod.POST, endpoint, "SERIALIZED_DATA".getBytes(StandardCharsets.UTF_8), HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Example 18 with HttpClient

use of org.apache.druid.java.util.http.client.HttpClient in project druid by druid-io.

the class AbstractAuthConfigurationTest method verifyAdminOptionsRequest.

protected void verifyAdminOptionsRequest() {
    HttpClient adminClient = new CredentialedHttpClient(new BasicCredentials("admin", "priest"), httpClient);
    testOptionsRequests(adminClient);
}
Also used : CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) BasicCredentials(org.apache.druid.java.util.http.client.auth.BasicCredentials)

Example 19 with HttpClient

use of org.apache.druid.java.util.http.client.HttpClient in project druid by druid-io.

the class ITTLSTest method checkAccessWithRevokedCert.

@Test
public void checkAccessWithRevokedCert() {
    LOG.info("---------Testing TLS resource access when client certificate has been revoked---------");
    HttpClient revokedClient = makeCustomHttpClient("client_tls/revoked_client.jks", "revoked_druid");
    checkFailedAccessRevoked(revokedClient, HttpMethod.GET, config.getCoordinatorTLSUrl());
    checkFailedAccessRevoked(revokedClient, HttpMethod.GET, config.getOverlordTLSUrl());
    checkFailedAccessRevoked(revokedClient, HttpMethod.GET, config.getBrokerTLSUrl());
    checkFailedAccessRevoked(revokedClient, HttpMethod.GET, config.getHistoricalTLSUrl());
    checkFailedAccessRevoked(revokedClient, HttpMethod.GET, config.getRouterTLSUrl());
    makeRequest(revokedClient, HttpMethod.GET, config.getPermissiveRouterTLSUrl() + "/status", null);
    makeRequest(revokedClient, HttpMethod.GET, config.getNoClientAuthRouterTLSUrl() + "/status", null);
}
Also used : HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) Test(org.testng.annotations.Test)

Example 20 with HttpClient

use of org.apache.druid.java.util.http.client.HttpClient in project druid by druid-io.

the class ITTLSTest method checkAccessWithNotCASignedCert.

@Test
public void checkAccessWithNotCASignedCert() {
    LOG.info("---------Testing TLS resource access when client certificate is signed by a non-CA intermediate cert---------");
    HttpClient notCAClient = makeCustomHttpClient("client_tls/invalid_ca_client.jks", "invalid_ca_client");
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getCoordinatorTLSUrl());
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getOverlordTLSUrl());
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getBrokerTLSUrl());
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getHistoricalTLSUrl());
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getRouterTLSUrl());
    checkFailedAccessNotCA(notCAClient, HttpMethod.GET, config.getPermissiveRouterTLSUrl());
    makeRequest(notCAClient, HttpMethod.GET, config.getNoClientAuthRouterTLSUrl() + "/status", null);
}
Also used : HttpClient(org.apache.druid.java.util.http.client.HttpClient) CredentialedHttpClient(org.apache.druid.java.util.http.client.CredentialedHttpClient) Test(org.testng.annotations.Test)

Aggregations

HttpClient (org.apache.druid.java.util.http.client.HttpClient)36 Test (org.junit.Test)16 CredentialedHttpClient (org.apache.druid.java.util.http.client.CredentialedHttpClient)15 ArrayList (java.util.ArrayList)10 Test (org.testng.annotations.Test)10 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)9 List (java.util.List)9 CuratorFramework (org.apache.curator.framework.CuratorFramework)9 ZkPathsConfig (org.apache.druid.server.initialization.ZkPathsConfig)9 ImmutableList (com.google.common.collect.ImmutableList)8 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 DruidNodeDiscoveryProvider (org.apache.druid.discovery.DruidNodeDiscoveryProvider)8 TaskRunnerListener (org.apache.druid.indexing.overlord.TaskRunnerListener)8 TaskStorage (org.apache.druid.indexing.overlord.TaskStorage)8 HttpRemoteTaskRunnerConfig (org.apache.druid.indexing.overlord.config.HttpRemoteTaskRunnerConfig)8 Worker (org.apache.druid.indexing.worker.Worker)8 IndexerZkConfig (org.apache.druid.server.initialization.IndexerZkConfig)8 DiscoveryDruidNode (org.apache.druid.discovery.DiscoveryDruidNode)7 WorkerNodeService (org.apache.druid.discovery.WorkerNodeService)7