Search in sources :

Example 16 with HttpServerTransport

use of org.elasticsearch.http.HttpServerTransport in project crate by crate.

the class AuthenticationIntegrationTest method testOptionsRequestDoesNotRequireAuth.

@Test
public void testOptionsRequestDoesNotRequireAuth() throws Exception {
    HttpServerTransport httpTransport = internalCluster().getInstance(HttpServerTransport.class);
    InetSocketAddress address = httpTransport.boundAddress().publishAddress().address();
    String uri = String.format(Locale.ENGLISH, "http://%s:%s/", address.getHostName(), address.getPort());
    HttpOptions request = new HttpOptions(uri);
    request.setHeader(HttpHeaderNames.AUTHORIZATION.toString(), "Basic QXJ0aHVyOkV4Y2FsaWJ1cg==");
    request.setHeader(HttpHeaderNames.ORIGIN.toString(), "http://example.com");
    request.setHeader(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString(), "GET");
    CloseableHttpClient httpClient = HttpClients.createDefault();
    CloseableHttpResponse resp = httpClient.execute(request);
    assertThat(resp.getStatusLine().getReasonPhrase(), is("OK"));
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) InetSocketAddress(java.net.InetSocketAddress) HttpOptions(org.apache.http.client.methods.HttpOptions) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Matchers.containsString(org.hamcrest.Matchers.containsString) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) Test(org.junit.Test)

Example 17 with HttpServerTransport

use of org.elasticsearch.http.HttpServerTransport in project crate by crate.

the class BlobPathITest method launchNodeAndInitClient.

private void launchNodeAndInitClient(Settings settings) throws Exception {
    // using numDataNodes = 1 to launch the node doesn't work:
    // if globalBlobPath is created within nodeSetting it is sometimes not available for the tests
    internalCluster().startNode(settings);
    blobAdminClient = internalCluster().getInstance(BlobAdminClient.class);
    HttpServerTransport httpServerTransport = internalCluster().getInstance(HttpServerTransport.class);
    InetSocketAddress address = httpServerTransport.boundAddress().publishAddress().address();
    client = new BlobHttpClient(address);
}
Also used : BlobAdminClient(io.crate.blob.v2.BlobAdminClient) InetSocketAddress(java.net.InetSocketAddress) HttpServerTransport(org.elasticsearch.http.HttpServerTransport)

Example 18 with HttpServerTransport

use of org.elasticsearch.http.HttpServerTransport in project crate by crate.

the class BlobHttpIntegrationTest method setup.

@Before
public void setup() throws ExecutionException, InterruptedException {
    randomNode = internalCluster().getInstances(HttpServerTransport.class).iterator().next().boundAddress().publishAddress().address();
    Iterable<HttpServerTransport> transports = internalCluster().getDataNodeInstances(HttpServerTransport.class);
    Iterator<HttpServerTransport> httpTransports = transports.iterator();
    dataNode1 = httpTransports.next().boundAddress().publishAddress().address();
    dataNode2 = httpTransports.next().boundAddress().publishAddress().address();
    BlobAdminClient blobAdminClient = internalCluster().getInstance(BlobAdminClient.class);
    Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 2).put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "false").build();
    blobAdminClient.createBlobTable("test", indexSettings).get();
    blobAdminClient.createBlobTable("test_blobs2", indexSettings).get();
    client().admin().indices().prepareCreate("test_no_blobs").setSettings(Settings.builder().put("number_of_shards", 2).put("number_of_replicas", 0).build()).execute().actionGet();
    ensureGreen();
}
Also used : BlobAdminClient(io.crate.blob.v2.BlobAdminClient) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Aggregations

HttpServerTransport (org.elasticsearch.http.HttpServerTransport)18 Settings (org.elasticsearch.common.settings.Settings)7 TransportAddress (org.elasticsearch.common.transport.TransportAddress)7 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)6 ThreadPool (org.elasticsearch.threadpool.ThreadPool)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)3 BlobAdminClient (io.crate.blob.v2.BlobAdminClient)2 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)2 InetSocketAddress (java.net.InetSocketAddress)2 Path (java.nio.file.Path)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ElasticsearchTimeoutException (org.elasticsearch.ElasticsearchTimeoutException)2 ClusterState (org.elasticsearch.cluster.ClusterState)2 ClusterStateObserver (org.elasticsearch.cluster.ClusterStateObserver)2 NodeConnectionsService (org.elasticsearch.cluster.NodeConnectionsService)2 MappingUpdatedAction (org.elasticsearch.cluster.action.index.MappingUpdatedAction)2