Replace nio and nitty test endpoint (#475)
Signed-off-by: Harold Wang <harowang@amazon.com>
This commit is contained in:
parent
70cad29af3
commit
5971a518d0
|
@ -368,7 +368,7 @@ public class Netty4HttpServerTransportTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
final Settings settings = createBuilderWithPort()
|
final Settings settings = createBuilderWithPort()
|
||||||
.put(SETTING_CORS_ENABLED.getKey(), true)
|
.put(SETTING_CORS_ENABLED.getKey(), true)
|
||||||
.put(SETTING_CORS_ALLOW_ORIGIN.getKey(), "elastic.co").build();
|
.put(SETTING_CORS_ALLOW_ORIGIN.getKey(), "test-cors.org").build();
|
||||||
|
|
||||||
try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool,
|
try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool,
|
||||||
xContentRegistry(), dispatcher, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
|
xContentRegistry(), dispatcher, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
|
||||||
|
@ -379,13 +379,13 @@ public class Netty4HttpServerTransportTests extends OpenSearchTestCase {
|
||||||
// Test pre-flight request
|
// Test pre-flight request
|
||||||
try (Netty4HttpClient client = new Netty4HttpClient()) {
|
try (Netty4HttpClient client = new Netty4HttpClient()) {
|
||||||
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/");
|
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/");
|
||||||
request.headers().add(CorsHandler.ORIGIN, "elastic.co");
|
request.headers().add(CorsHandler.ORIGIN, "test-cors.org");
|
||||||
request.headers().add(CorsHandler.ACCESS_CONTROL_REQUEST_METHOD, "POST");
|
request.headers().add(CorsHandler.ACCESS_CONTROL_REQUEST_METHOD, "POST");
|
||||||
|
|
||||||
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
||||||
try {
|
try {
|
||||||
assertThat(response.status(), equalTo(HttpResponseStatus.OK));
|
assertThat(response.status(), equalTo(HttpResponseStatus.OK));
|
||||||
assertThat(response.headers().get(CorsHandler.ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("elastic.co"));
|
assertThat(response.headers().get(CorsHandler.ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("test-cors.org"));
|
||||||
assertThat(response.headers().get(CorsHandler.VARY), equalTo(CorsHandler.ORIGIN));
|
assertThat(response.headers().get(CorsHandler.VARY), equalTo(CorsHandler.ORIGIN));
|
||||||
assertTrue(response.headers().contains(CorsHandler.DATE));
|
assertTrue(response.headers().contains(CorsHandler.DATE));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -396,7 +396,7 @@ public class Netty4HttpServerTransportTests extends OpenSearchTestCase {
|
||||||
// Test short-circuited request
|
// Test short-circuited request
|
||||||
try (Netty4HttpClient client = new Netty4HttpClient()) {
|
try (Netty4HttpClient client = new Netty4HttpClient()) {
|
||||||
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
|
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
|
||||||
request.headers().add(CorsHandler.ORIGIN, "elastic2.co");
|
request.headers().add(CorsHandler.ORIGIN, "google.com");
|
||||||
|
|
||||||
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -240,7 +240,7 @@ public class NioHttpServerTransportTests extends OpenSearchTestCase {
|
||||||
|
|
||||||
final Settings settings = createBuilderWithPort()
|
final Settings settings = createBuilderWithPort()
|
||||||
.put(SETTING_CORS_ENABLED.getKey(), true)
|
.put(SETTING_CORS_ENABLED.getKey(), true)
|
||||||
.put(SETTING_CORS_ALLOW_ORIGIN.getKey(), "elastic.co")
|
.put(SETTING_CORS_ALLOW_ORIGIN.getKey(), "test-cors.org")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (NioHttpServerTransport transport = new NioHttpServerTransport(settings, networkService, bigArrays, pageRecycler,
|
try (NioHttpServerTransport transport = new NioHttpServerTransport(settings, networkService, bigArrays, pageRecycler,
|
||||||
|
@ -252,13 +252,13 @@ public class NioHttpServerTransportTests extends OpenSearchTestCase {
|
||||||
// Test pre-flight request
|
// Test pre-flight request
|
||||||
try (NioHttpClient client = new NioHttpClient()) {
|
try (NioHttpClient client = new NioHttpClient()) {
|
||||||
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/");
|
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/");
|
||||||
request.headers().add(CorsHandler.ORIGIN, "elastic.co");
|
request.headers().add(CorsHandler.ORIGIN, "test-cors.org");
|
||||||
request.headers().add(CorsHandler.ACCESS_CONTROL_REQUEST_METHOD, "POST");
|
request.headers().add(CorsHandler.ACCESS_CONTROL_REQUEST_METHOD, "POST");
|
||||||
|
|
||||||
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
||||||
try {
|
try {
|
||||||
assertThat(response.status(), equalTo(HttpResponseStatus.OK));
|
assertThat(response.status(), equalTo(HttpResponseStatus.OK));
|
||||||
assertThat(response.headers().get(CorsHandler.ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("elastic.co"));
|
assertThat(response.headers().get(CorsHandler.ACCESS_CONTROL_ALLOW_ORIGIN), equalTo("test-cors.org"));
|
||||||
assertThat(response.headers().get(CorsHandler.VARY), equalTo(CorsHandler.ORIGIN));
|
assertThat(response.headers().get(CorsHandler.VARY), equalTo(CorsHandler.ORIGIN));
|
||||||
assertTrue(response.headers().contains(CorsHandler.DATE));
|
assertTrue(response.headers().contains(CorsHandler.DATE));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -269,7 +269,7 @@ public class NioHttpServerTransportTests extends OpenSearchTestCase {
|
||||||
// Test short-circuited request
|
// Test short-circuited request
|
||||||
try (NioHttpClient client = new NioHttpClient()) {
|
try (NioHttpClient client = new NioHttpClient()) {
|
||||||
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
|
final FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
|
||||||
request.headers().add(CorsHandler.ORIGIN, "elastic2.co");
|
request.headers().add(CorsHandler.ORIGIN, "google.com");
|
||||||
|
|
||||||
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
final FullHttpResponse response = client.send(remoteAddress.address(), request);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue