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"));
}
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);
}
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();
}
Aggregations