mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-24 17:09:48 +00:00
Migrate RestHttpResponseHeadersIT to ESRestTestCase (#25675)
Closes #25611
This commit is contained in:
parent
5a416b9922
commit
8b846f9141
@ -20,6 +20,7 @@ package org.elasticsearch.http;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.elasticsearch.client.Response;
|
import org.elasticsearch.client.Response;
|
||||||
import org.elasticsearch.client.ResponseException;
|
import org.elasticsearch.client.ResponseException;
|
||||||
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,7 +36,7 @@ import static org.hamcrest.Matchers.is;
|
|||||||
* methods on REST endpoints should respond with status code 405</a> for more
|
* methods on REST endpoints should respond with status code 405</a> for more
|
||||||
* information.
|
* information.
|
||||||
*/
|
*/
|
||||||
public class RestHttpResponseHeadersIT extends HttpSmokeTestCase {
|
public class RestHttpResponseHeadersIT extends ESRestTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For an OPTIONS request to a valid REST endpoint, verify that a 200 HTTP
|
* For an OPTIONS request to a valid REST endpoint, verify that a 200 HTTP
|
||||||
@ -45,7 +46,7 @@ public class RestHttpResponseHeadersIT extends HttpSmokeTestCase {
|
|||||||
* - Options</a>).
|
* - Options</a>).
|
||||||
*/
|
*/
|
||||||
public void testValidEndpointOptionsResponseHttpHeader() throws Exception {
|
public void testValidEndpointOptionsResponseHttpHeader() throws Exception {
|
||||||
Response response = getRestClient().performRequest("OPTIONS", "/_tasks");
|
Response response = client().performRequest("OPTIONS", "/_tasks");
|
||||||
assertThat(response.getStatusLine().getStatusCode(), is(200));
|
assertThat(response.getStatusLine().getStatusCode(), is(200));
|
||||||
assertThat(response.getHeader("Allow"), notNullValue());
|
assertThat(response.getHeader("Allow"), notNullValue());
|
||||||
List<String> responseAllowHeaderStringArray =
|
List<String> responseAllowHeaderStringArray =
|
||||||
@ -63,7 +64,7 @@ public class RestHttpResponseHeadersIT extends HttpSmokeTestCase {
|
|||||||
*/
|
*/
|
||||||
public void testUnsupportedMethodResponseHttpHeader() throws Exception {
|
public void testUnsupportedMethodResponseHttpHeader() throws Exception {
|
||||||
try {
|
try {
|
||||||
getRestClient().performRequest("DELETE", "/_tasks");
|
client().performRequest("DELETE", "/_tasks");
|
||||||
fail("Request should have failed with 405 error");
|
fail("Request should have failed with 405 error");
|
||||||
} catch (ResponseException e) {
|
} catch (ResponseException e) {
|
||||||
Response response = e.getResponse();
|
Response response = e.getResponse();
|
||||||
@ -84,9 +85,9 @@ public class RestHttpResponseHeadersIT extends HttpSmokeTestCase {
|
|||||||
* 17853</a> for more information).
|
* 17853</a> for more information).
|
||||||
*/
|
*/
|
||||||
public void testIndexSettingsPostRequest() throws Exception {
|
public void testIndexSettingsPostRequest() throws Exception {
|
||||||
|
client().performRequest("PUT", "/testindex");
|
||||||
try {
|
try {
|
||||||
createIndex("testindex");
|
client().performRequest("POST", "/testindex/_settings");
|
||||||
getRestClient().performRequest("POST", "/testindex/_settings");
|
|
||||||
fail("Request should have failed with 405 error");
|
fail("Request should have failed with 405 error");
|
||||||
} catch (ResponseException e) {
|
} catch (ResponseException e) {
|
||||||
Response response = e.getResponse();
|
Response response = e.getResponse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user