Skip to content

Commit 183ff0f

Browse files
committed
Add YAML tests for new function
1 parent 1bdb305 commit 183ff0f

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
teardown:
3+
- do:
4+
streams.logs_disable: { }
5+
6+
---
7+
"Check User Can't Use Restricted Params On Logs Endpoint":
8+
- do:
9+
streams.logs_enable: { }
10+
- is_true: acknowledged
11+
12+
- do:
13+
streams.status: { }
14+
- is_true: logs.enabled
15+
16+
- do:
17+
bulk:
18+
refresh: true
19+
body: |
20+
{ "index": { "_index": "logs"} }
21+
{ "foo": "bar" }
22+
{ "index": { "_index": "not-logs" } }
23+
{ "foo": "bar" }
24+
- match: { errors: true }
25+
- match: { items.0.index.status: 400 }
26+
- match: { items.0.index.error.type: "illegal_argument_exception" }
27+
- match: { items.0.index.error.reason: "When writing to a stream, only the following parameters are allowed: [error_trace,timeout]" }
28+
- match: { items.1.index.status: 201 }
29+
30+
---
31+
"Check User Can't Use Restricted Params On Logs Endpoint - Single Doc":
32+
- do:
33+
streams.logs_enable: { }
34+
- is_true: acknowledged
35+
36+
- do:
37+
streams.status: { }
38+
- is_true: logs.enabled
39+
40+
- do:
41+
index:
42+
refresh: true
43+
index: logs
44+
body: { "foo": "bar" }
45+
catch: bad_request

server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.io.IOException;
4242
import java.util.ArrayDeque;
4343
import java.util.ArrayList;
44+
import java.util.LinkedHashSet;
4445
import java.util.List;
4546
import java.util.Set;
4647
import java.util.concurrent.TimeUnit;
@@ -63,7 +64,12 @@ public class RestBulkAction extends BaseRestHandler {
6364

6465
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in bulk requests is deprecated.";
6566
public static final String FAILURE_STORE_STATUS_CAPABILITY = "failure_store_status";
66-
public static final Set<String> STREAMS_ALLOWED_PARAMS = Set.of("timeout", "error_trace");
67+
public static final LinkedHashSet<String> STREAMS_ALLOWED_PARAMS = new LinkedHashSet<>(2) {
68+
{
69+
add("error_trace");
70+
add("timeout");
71+
}
72+
};
6773

6874
private final boolean allowExplicitIndex;
6975
private final IncrementalBulkService bulkHandler;

0 commit comments

Comments
 (0)