IndexClosedException to return 400 rather than 403 (#25752)
403 can be confused with security. If an API doesn't support working against closed indices and closed indices are referred to in a request, that is a bad request, hence 400 is more appropriate.
This commit is contained in:
parent
194f267110
commit
0d8b753325
|
@ -42,6 +42,6 @@ public class IndexClosedException extends ElasticsearchException {
|
|||
|
||||
@Override
|
||||
public RestStatus status() {
|
||||
return RestStatus.FORBIDDEN;
|
||||
return RestStatus.BAD_REQUEST;
|
||||
}
|
||||
}
|
|
@ -107,8 +107,15 @@ $ curl -v -XPOST 'localhost:9200/my_index/_settings'
|
|||
* Connection #0 to host localhost left intact
|
||||
--------------------------------------------
|
||||
|
||||
==== Dissallow using `_cache` and `_cache_key`
|
||||
==== Disallow using `_cache` and `_cache_key`
|
||||
|
||||
The `_cache` and `_cache_key` options in queries have been deprecated since version 2.0.0 and
|
||||
have been ignored since then, issuing a deprecation warning. These options have now been completely
|
||||
removed, so using them now will throw an error.
|
||||
|
||||
==== IndexClosedException to return 400 status code
|
||||
|
||||
An `IndexClosedException` is returned whenever an api that doesn't support
|
||||
closed indices (e.g. search) is called passing closed indices as parameters
|
||||
and `ignore_unavailable` is set to `false`. The response status code returned
|
||||
in such case changed from `403` to `400`
|
||||
|
|
|
@ -86,6 +86,10 @@
|
|||
---
|
||||
"Test cat segments on closed index behaviour":
|
||||
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: index1
|
||||
|
@ -99,7 +103,7 @@
|
|||
index: index1
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
cat.segments:
|
||||
index: index1
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
---
|
||||
"Basic test for index open/close":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
@ -16,7 +20,7 @@
|
|||
index: test_index
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
search:
|
||||
index: test_index
|
||||
|
||||
|
|
|
@ -23,12 +23,16 @@ setup:
|
|||
|
||||
---
|
||||
"All indices":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.close:
|
||||
index: _all
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
search:
|
||||
index: test_index2
|
||||
|
||||
|
@ -46,12 +50,16 @@ setup:
|
|||
|
||||
---
|
||||
"Trailing wildcard":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.close:
|
||||
index: test_*
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
search:
|
||||
index: test_index2
|
||||
|
||||
|
@ -69,12 +77,16 @@ setup:
|
|||
|
||||
---
|
||||
"Only wildcard":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.close:
|
||||
index: '*'
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
search:
|
||||
index: test_index3
|
||||
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
|
||||
---
|
||||
"closed segments test":
|
||||
- skip:
|
||||
version: " - 5.99.99"
|
||||
reason: status code on closed indices changed in 6.0.0 from 403 to 400
|
||||
|
||||
- do:
|
||||
indices.create:
|
||||
|
@ -63,7 +66,7 @@
|
|||
index: index1
|
||||
|
||||
- do:
|
||||
catch: forbidden
|
||||
catch: request
|
||||
indices.segments:
|
||||
index: index1
|
||||
|
||||
|
|
Loading…
Reference in New Issue