Add bad_request to the rest-api-spec catch params (#26539)

This adds another request to the catch params. It also makes sure that
the generic request param does not allow 400 either.
This commit is contained in:
Michael Basnight 2017-09-14 14:24:03 -05:00 committed by GitHub
parent 1ca0b5e9e4
commit f385e0cf26
40 changed files with 57 additions and 54 deletions

View File

@ -602,7 +602,7 @@ invalid `size` parameter to the `_search` API:
POST /twitter/_search?size=surprise_me
----------------------------------------------------------------------
// CONSOLE
// TEST[s/surprise_me/surprise_me&error_trace=false/ catch:request]
// TEST[s/surprise_me/surprise_me&error_trace=false/ catch:bad_request]
// Since the test system sends error_trace=true by default we have to override
The response looks like:
@ -636,7 +636,7 @@ But if you set `error_trace=true`:
POST /twitter/_search?size=surprise_me&error_trace=true
----------------------------------------------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
The response looks like:

View File

@ -31,7 +31,7 @@ PUT my-index/my-type/my-id?pipeline=my_pipeline_id
}
--------------------------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
See <<ingest-apis,Ingest APIs>> for more information about creating, adding, and deleting pipelines.

View File

@ -96,7 +96,7 @@ PUT my_index2/my_type/1 <2>
}
------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
<1> Routing is required for `my_type` documents.
<2> This index request throws a `routing_missing_exception`.

View File

@ -45,7 +45,7 @@ PUT my_index/my_type/2
}
--------------------------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
<1> The `number_one` field will contain the integer `10`.
<2> This document will be rejected because coercion is disabled.
@ -88,6 +88,6 @@ PUT my_index/my_type/2
{ "number_two": "10" } <2>
--------------------------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
<1> The `number_one` field overrides the index level setting to enable coercion.
<2> This document will be rejected because the `number_two` field inherits the index-level coercion setting.

View File

@ -44,7 +44,7 @@ PUT my_index/my_type/2
}
--------------------------------------------------
// CONSOLE
// TEST[catch:request]
// TEST[catch:bad_request]
<1> This document will have the `text` field indexed, but not the `number_one` field.
<2> This document will be rejected because `number_two` does not allow malformed values.

View File

@ -6,7 +6,7 @@
version: " - 5.99.99"
reason: normalizer support in 6.0.0
- do:
catch: request
catch: bad_request
indices.analyze:
body:
text: ABc

View File

@ -142,7 +142,7 @@ teardown:
---
"Test invalid processor config":
- do:
catch: request
catch: bad_request
ingest.put_pipeline:
id: "my_pipeline"
body: >

View File

@ -122,7 +122,7 @@ teardown:
---
"Test pipeline with empty on_failure in a processor":
- do:
catch: request
catch: bad_request
ingest.put_pipeline:
id: "my_pipeline"
body: >
@ -155,7 +155,7 @@ teardown:
---
"Test pipeline with empty on_failure in pipeline":
- do:
catch: request
catch: bad_request
ingest.put_pipeline:
id: "my_pipeline"
body: >

View File

@ -79,7 +79,7 @@ teardown:
---
"Test simulate with provided invalid pipeline definition":
- do:
catch: request
catch: bad_request
ingest.simulate:
body: >
{
@ -183,7 +183,7 @@ teardown:
---
"Test simulate with no provided pipeline or pipeline_id":
- do:
catch: request
catch: bad_request
ingest.simulate:
body: >
{
@ -206,7 +206,7 @@ teardown:
---
"Test simulate with invalid processor config":
- do:
catch: request
catch: bad_request
ingest.simulate:
body: >
{

View File

@ -124,7 +124,7 @@
count: 1
- do:
catch: request
catch: bad_request
update:
index: test_1
type: test

View File

@ -302,7 +302,7 @@
indices.refresh: {}
- do:
catch: request
catch: bad_request
update_by_query:
refresh: true
index: twitter

View File

@ -163,6 +163,7 @@ be caught and tested. For instance:
The argument to `catch` can be any of:
[horizontal]
`bad_request`:: a 400 response from ES
`unauthorized`:: a 401 response from ES
`forbidden`:: a 403 response from ES
`missing`:: a 404 response from ES

View File

@ -103,7 +103,7 @@
index: index1
- do:
catch: request
catch: bad_request
cat.segments:
index: index1

View File

@ -58,7 +58,7 @@ setup:
---
"count body without query element":
- do:
catch: request
catch: bad_request
count:
index: test
body:

View File

@ -26,7 +26,7 @@
reason: validation logic only fixed from 5.1.2 onwards
- do:
catch: request
catch: bad_request
create:
index: test
type: test

View File

@ -6,7 +6,7 @@
reason: validation logic only fixed from 5.1.2 onwards
- do:
catch: request
catch: bad_request
create:
index: test
type: test
@ -20,7 +20,7 @@
- match: { error.reason: "Validation Failed: 1: create operations only support internal versioning. use index instead;" }
- do:
catch: request
catch: bad_request
create:
index: test
type: test

View File

@ -31,7 +31,7 @@ setup:
"Parent omitted":
- do:
catch: request
catch: bad_request
exists:
index: test_1
type: test

View File

@ -56,7 +56,7 @@ setup:
---
"Explain body without query element":
- do:
catch: request
catch: bad_request
explain:
index: test_1
type: test

View File

@ -34,7 +34,7 @@ setup:
---
"Parent omitted":
- do:
catch: request
catch: bad_request
get:
index: test_1
type: test

View File

@ -32,7 +32,7 @@ setup:
"Parent omitted":
- do:
catch: request
catch: bad_request
get_source:
index: test_1
type: test

View File

@ -26,7 +26,7 @@
- match: { _source: { foo: bar }}
- do:
catch: request
catch: bad_request
index:
index: idx
type: type

View File

@ -14,7 +14,7 @@ setup:
version: " - 5.99.0"
reason: delete index doesn't support aliases only from 6.0.0 on
- do:
catch: request
catch: bad_request
indices.delete:
index: alias
- do:
@ -42,7 +42,7 @@ setup:
version: " - 5.99.0"
reason: delete index doesn't support aliases only from 6.0.0 on
- do:
catch: request
catch: bad_request
indices.delete:
index: alias,index2
- do:

View File

@ -20,7 +20,7 @@
index: test_index
- do:
catch: request
catch: bad_request
search:
index: test_index

View File

@ -32,7 +32,7 @@ setup:
index: _all
- do:
catch: request
catch: bad_request
search:
index: test_index2
@ -59,7 +59,7 @@ setup:
index: test_*
- do:
catch: request
catch: bad_request
search:
index: test_index2
@ -86,7 +86,7 @@ setup:
index: '*'
- do:
catch: request
catch: bad_request
search:
index: test_index3

View File

@ -39,7 +39,7 @@
index: test_index
- do:
catch: request
catch: bad_request
indices.put_alias:
index: test_index
name: test_*
@ -55,7 +55,7 @@
index: foo
- do:
catch: request
catch: bad_request
indices.put_alias:
index: test_index
name: foo

View File

@ -100,7 +100,7 @@
- match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}}
- do:
catch: request
catch: bad_request
indices.put_template:
name: test
create: true

View File

@ -66,7 +66,7 @@
index: index1
- do:
catch: request
catch: bad_request
indices.segments:
index: index1

View File

@ -106,7 +106,7 @@ setup:
version: " - 5.0.99"
reason: strict stats handling does not exist in 5.0
- do:
catch: request
catch: bad_request
indices.stats:
metric: [ fieldata ]

View File

@ -27,7 +27,7 @@
version: " - 5.0.99"
reason: strict stats handling does not exist in 5.0
- do:
catch: request
catch: bad_request
nodes.stats:
metric: [ transprot ]

View File

@ -166,7 +166,7 @@ setup:
"Aggregating wrong datatype test":
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -166,7 +166,7 @@ setup:
"Aggregating wrong datatype test":
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -166,7 +166,7 @@ setup:
"Aggregating wrong datatype test":
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -166,7 +166,7 @@ setup:
"Aggregating wrong datatype test":
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -288,7 +288,7 @@ setup:
percents: []
- do:
catch: request
catch: bad_request
search:
body:
aggs:
@ -298,7 +298,7 @@ setup:
percents: null
- do:
catch: request
catch: bad_request
search:
body:
aggs:
@ -308,7 +308,7 @@ setup:
percents: ["foo"]
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -298,7 +298,7 @@ setup:
number_of_significant_value_digits: 10
- do:
catch: request
catch: bad_request
search:
body:
aggs:
@ -320,7 +320,7 @@ setup:
percents: []
- do:
catch: request
catch: bad_request
search:
body:
aggs:
@ -331,7 +331,7 @@ setup:
percents: null
- do:
catch: request
catch: bad_request
search:
body:
aggs:
@ -342,7 +342,7 @@ setup:
percents: ["foo"]
- do:
catch: request
catch: bad_request
search:
body:
aggs:

View File

@ -69,7 +69,7 @@ setup:
"Search body without query element":
- do:
catch: request
catch: bad_request
search:
body:
match:

View File

@ -22,7 +22,7 @@ setup:
"Test with _local preference placed in query body - should fail":
- do:
catch: request
catch: bad_request
search:
index: test
type: test

View File

@ -19,7 +19,7 @@ setup:
"Test search_type=query_and_fetch not supported from REST layer":
- do:
catch: request
catch: bad_request
search:
index: test
type: test
@ -33,7 +33,7 @@ setup:
"Test search_type=dfs_query_and_fetch not supported from REST layer":
- do:
catch: request
catch: bad_request
search:
index: test
type: test

View File

@ -65,7 +65,7 @@ setup:
body: { foo: bar }
- do:
catch: request
catch: bad_request
update:
index: test_1
type: test

View File

@ -320,6 +320,7 @@ public class DoSection implements ExecutableSection {
private static Map<String, Tuple<String, org.hamcrest.Matcher<Integer>>> catches = new HashMap<>();
static {
catches.put("bad_request", tuple("400", equalTo(400)));
catches.put("unauthorized", tuple("401", equalTo(401)));
catches.put("forbidden", tuple("403", equalTo(403)));
catches.put("missing", tuple("404", equalTo(404)));
@ -327,6 +328,7 @@ public class DoSection implements ExecutableSection {
catches.put("conflict", tuple("409", equalTo(409)));
catches.put("unavailable", tuple("503", equalTo(503)));
catches.put("request", tuple("4xx|5xx", allOf(greaterThanOrEqualTo(400),
not(equalTo(400)),
not(equalTo(401)),
not(equalTo(403)),
not(equalTo(404)),